diff options
author | Davi Arnaut <davi.arnaut@oracle.com> | 2010-10-20 11:40:04 -0200 |
---|---|---|
committer | Davi Arnaut <davi.arnaut@oracle.com> | 2010-10-20 11:40:04 -0200 |
commit | b5bb13ec0380624c2e663a4e9b4b29fe574b3e05 (patch) | |
tree | 41d75684cb423d9d0f557dd29a31c4878177057a /mysys | |
parent | 1040f98ccffccbed8d1e95fe8252e402b8ee4e3f (diff) | |
download | mariadb-git-b5bb13ec0380624c2e663a4e9b4b29fe574b3e05.tar.gz |
Bug#45288: pb2 returns a lot of compilation warnings
Fix assorted compiler warnings.
include/my_pthread.h:
Like for pthread_cond_timedwait, the abstime is constant.
mysys/my_gethwaddr.c:
Instead of using a manual copy that introduce warnings due to
type mismatch, copy the buffer using memcpy and use memcmp to
check whether all bytes of the buffer are zeroed.
mysys/thr_mutex.c:
Like for pthread_cond_timedwait, the abstime is constant.
unittest/mytap/tap.h:
Introduce a ok() variant that does not take a format argument.
Since ok() is tagged with a printf attribute, GCC complains if
the fmt argument is NULL.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_gethwaddr.c | 32 | ||||
-rw-r--r-- | mysys/thr_mutex.c | 4 |
2 files changed, 15 insertions, 21 deletions
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/thr_mutex.c b/mysys/thr_mutex.c index 8f9928026ba..c7600b58c95 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -259,8 +259,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; pthread_mutex_lock(&mp->global); |