summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorMichael Widenius <monty@mysql.com>2010-11-30 23:11:03 +0200
committerMichael Widenius <monty@mysql.com>2010-11-30 23:11:03 +0200
commit1e5061fe3be981d6f685a2865fd1e2bcd3fcc23a (patch)
treea0c58838a4dd7bdf2ed4d739563da27727ada7b0 /mysys
parentb2e979d868d5d5964d58c97ed9580e07f6123217 (diff)
parent6f279f40145624c1ffab06c63521f96ce4ac3a02 (diff)
downloadmariadb-git-1e5061fe3be981d6f685a2865fd1e2bcd3fcc23a.tar.gz
merge with 5.1
Diffstat (limited to 'mysys')
-rw-r--r--mysys/charset.c2
-rw-r--r--mysys/my_gethostbyname.c11
-rw-r--r--mysys/my_gethwaddr.c32
-rw-r--r--mysys/my_getopt.c3
-rw-r--r--mysys/my_symlink.c15
-rw-r--r--mysys/my_sync.c7
-rw-r--r--mysys/sha1.c55
-rw-r--r--mysys/thr_mutex.c4
8 files changed, 84 insertions, 45 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index 153ef8b7e2c..7b72f1f5ae3 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -199,6 +199,7 @@ static my_bool simple_cs_is_full(CHARSET_INFO *cs)
}
+#if defined(HAVE_UCA_COLLATIONS) && (defined(HAVE_CHARSET_ucs2) || defined(HAVE_CHARSET_utf8))
static void
copy_uca_collation(struct charset_info_st *to, CHARSET_INFO *from)
{
@@ -212,6 +213,7 @@ copy_uca_collation(struct charset_info_st *to, CHARSET_INFO *from)
to->state|= MY_CS_AVAILABLE | MY_CS_LOADED |
MY_CS_STRNXFRM | MY_CS_UNICODE;
}
+#endif
static int add_collation(struct charset_info_st *cs)
diff --git a/mysys/my_gethostbyname.c b/mysys/my_gethostbyname.c
index abd388302be..12cf90271dd 100644
--- a/mysys/my_gethostbyname.c
+++ b/mysys/my_gethostbyname.c
@@ -91,12 +91,11 @@ extern pthread_mutex_t LOCK_gethostbyname_r;
is finished with the structure.
*/
-struct hostent *
-my_gethostbyname_r(const char *name,
- struct hostent *result __attribute__((unused)),
- char *buffer __attribute__((unused)),
- int buflen __attribute__((unused)),
- int *h_errnop)
+struct hostent *my_gethostbyname_r(const char *name,
+ struct hostent *res __attribute__((unused)),
+ char *buffer __attribute__((unused)),
+ int buflen __attribute__((unused)),
+ int *h_errnop)
{
struct hostent *hp;
pthread_mutex_lock(&LOCK_gethostbyname_r);
diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c
index 00e0e90f1e4..90908bd1c0d 100644
--- a/mysys/my_gethwaddr.c
+++ b/mysys/my_gethwaddr.c
@@ -21,18 +21,6 @@
#ifndef MAIN
-#if defined(__FreeBSD__) || defined(__linux__)
-static my_bool memcpy_and_test(uchar *to, uchar *from, uint len)
-{
- uint i, res=1;
-
- for (i=0; i < len; i++)
- if ((*to++= *from++))
- res=0;
- return res;
-}
-#endif /* FreeBSD || linux */
-
#ifdef __FreeBSD__
#include <net/ethernet.h>
@@ -44,10 +32,11 @@ static my_bool memcpy_and_test(uchar *to, uchar *from, uint len)
my_bool my_gethwaddr(uchar *to)
{
size_t len;
- uchar *buf, *next, *end, *addr;
+ char *buf, *next, *end;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
int res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0};
+ char zero_array[ETHER_ADDR_LEN] = {0};
if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1)
goto err;
@@ -63,9 +52,9 @@ my_bool my_gethwaddr(uchar *to)
ifm = (struct if_msghdr *)next;
if (ifm->ifm_type == RTM_IFINFO)
{
- sdl = (struct sockaddr_dl *)(ifm + 1);
- addr=LLADDR(sdl);
- res=memcpy_and_test(to, addr, ETHER_ADDR_LEN);
+ sdl= (struct sockaddr_dl *)(ifm + 1);
+ memcpy(to, LLADDR(sdl), ETHER_ADDR_LEN);
+ res= memcmp(to, zero_array, ETHER_ADDR_LEN) ? 0 : 1;
}
}
@@ -81,8 +70,9 @@ err:
my_bool my_gethwaddr(uchar *to)
{
- int fd, res=1;
+ int fd, res= 1;
struct ifreq ifr;
+ char zero_array[ETHER_ADDR_LEN] = {0};
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0)
@@ -91,9 +81,13 @@ my_bool my_gethwaddr(uchar *to)
bzero(&ifr, sizeof(ifr));
strnmov(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name) - 1);
- do {
+ do
+ {
if (ioctl(fd, SIOCGIFHWADDR, &ifr) >= 0)
- res=memcpy_and_test(to, (uchar *)&ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
+ {
+ memcpy(to, &ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
+ res= memcmp(to, zero_array, ETHER_ADDR_LEN) ? 0 : 1;
+ }
} while (res && (errno == 0 || errno == ENODEV) && ifr.ifr_name[3]++ < '6');
close(fd);
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index db6ccd230f2..5d0703f09a8 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -112,7 +112,7 @@ int handle_options(int *argc, char ***argv,
const struct my_option *longopts,
my_get_one_option get_one_option)
{
- uint opt_found, argvpos= 0, length;
+ uint UNINIT_VAR(opt_found), argvpos= 0, length;
my_bool end_of_options= 0, must_be_var, set_maximum_value,
option_is_loose;
char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN];
@@ -121,7 +121,6 @@ int handle_options(int *argc, char ***argv,
void *value;
int error, i;
- LINT_INIT(opt_found);
/* handle_options() assumes arg0 (program name) always exists */
DBUG_ASSERT(argc && *argc >= 1);
DBUG_ASSERT(argv && *argv);
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index 33f45a882e1..164533ad765 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -113,7 +113,6 @@ int my_is_symlink(const char *filename __attribute__((unused)))
#endif
}
-
/*
Resolve all symbolic links in path
'to' may be equal to 'filename'
@@ -150,7 +149,21 @@ int my_realpath(char *to, const char *filename,
}
DBUG_RETURN(result);
#else
+#ifdef _WIN32
+ int ret= GetFullPathName(filename,FN_REFLEN, to, NULL);
+ if (ret == 0 || ret > FN_REFLEN)
+ {
+ if (ret > FN_REFLEN)
+ my_errno= ENAMETOOLONG;
+ else
+ my_errno= EACCES;
+ if (MyFlags & MY_WME)
+ my_error(EE_REALPATH, MYF(0), filename, my_errno);
+ return -1;
+ }
+#else
my_load_path(to, filename, NullS);
+#endif
return 0;
#endif
}
diff --git a/mysys/my_sync.c b/mysys/my_sync.c
index a2b615a8661..dae20b0163e 100644
--- a/mysys/my_sync.c
+++ b/mysys/my_sync.c
@@ -64,7 +64,7 @@ int my_sync(File fd, myf my_flags)
/* Some file systems don't support F_FULLFSYNC and fail above: */
DBUG_PRINT("info",("fcntl(F_FULLFSYNC) failed, falling back"));
#endif
-#if defined(HAVE_FDATASYNC)
+#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
res= fdatasync(fd);
#elif defined(HAVE_FSYNC)
res= fsync(fd);
@@ -97,6 +97,7 @@ int my_sync(File fd, myf my_flags)
static const char cur_dir_name[]= {FN_CURLIB, 0};
+
/*
Force directory information to disk.
@@ -108,6 +109,7 @@ static const char cur_dir_name[]= {FN_CURLIB, 0};
RETURN
0 if ok, !=0 if error
*/
+
int my_sync_dir(const char *dir_name __attribute__((unused)),
myf my_flags __attribute__((unused)))
{
@@ -138,7 +140,6 @@ int my_sync_dir(const char *dir_name __attribute__((unused)),
#endif
}
-
/*
Force directory information to disk.
@@ -150,6 +151,7 @@ int my_sync_dir(const char *dir_name __attribute__((unused)),
RETURN
0 if ok, !=0 if error
*/
+
int my_sync_dir_by_file(const char *file_name __attribute__((unused)),
myf my_flags __attribute__((unused)))
{
@@ -162,4 +164,3 @@ int my_sync_dir_by_file(const char *file_name __attribute__((unused)),
return 0;
#endif
}
-
diff --git a/mysys/sha1.c b/mysys/sha1.c
index 3469e480c26..e5b33a9ad13 100644
--- a/mysys/sha1.c
+++ b/mysys/sha1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004, 2006 MySQL AB
+/* Copyright (c) 2002, 2004, 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -6,26 +6,57 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
/*
Original Source from: http://www.faqs.org/rfcs/rfc3174.html
+ Copyright (C) The Internet Society (2001). All Rights Reserved.
+
+ This document and translations of it may be copied and furnished to
+ others, and derivative works that comment on or otherwise explain it
+ or assist in its implementation may be prepared, copied, published
+ and distributed, in whole or in part, without restriction of any
+ kind, provided that the above copyright notice and this paragraph are
+ included on all such copies and derivative works. However, this
+ document itself may not be modified in any way, such as by removing
+ the copyright notice or references to the Internet Society or other
+ Internet organizations, except as needed for the purpose of
+ developing Internet standards in which case the procedures for
+ copyrights defined in the Internet Standards process must be
+ followed, or as required to translate it into languages other than
+ English.
+
+ The limited permissions granted above are perpetual and will not be
+ revoked by the Internet Society or its successors or assigns.
+
+ This document and the information contained herein is provided on an
+ "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
+ TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+
+ Acknowledgement
+ Funding for the RFC Editor function is currently provided by the
+ Internet Society.
+
DESCRIPTION
- This file implements the Secure Hashing Algorithm 1 as
- defined in FIPS PUB 180-1 published April 17, 1995.
-
- The SHA-1, produces a 160-bit message digest for a given data
- stream. It should take about 2**n steps to find a message with the
- same digest as a given message and 2**(n/2) to find any two
- messages with the same digest, when n is the digest size in bits.
- Therefore, this algorithm can serve as a means of providing a
- "fingerprint" for a message.
+ This file implements the Secure Hashing Algorithm 1 as
+ defined in FIPS PUB 180-1 published April 17, 1995.
+
+ The SHA-1, produces a 160-bit message digest for a given data
+ stream. It should take about 2**n steps to find a message with the
+ same digest as a given message and 2**(n/2) to find any two
+ messages with the same digest, when n is the digest size in bits.
+ Therefore, this algorithm can serve as a means of providing a
+ "fingerprint" for a message.
PORTABILITY ISSUES
SHA-1 is defined in terms of 32-bit "words". This code uses
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 5ab1e443a88..77f2286b3d1 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -527,8 +527,8 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
- struct timespec *abstime,
- const char *file, uint line)
+ const struct timespec *abstime,
+ const char *file, uint line)
{
int error;
safe_mutex_t save_state;