summaryrefslogtreecommitdiffstats
path: root/libc/netbsd
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2010-06-16 16:36:41 -0700
committerDavid 'Digit' Turner <digit@google.com>2010-06-22 17:51:41 -0700
commit50ace4fec5e8cb5afcbc656a4556fa528adfd760 (patch)
tree04647e039a457f69ba48a8301bebdd605fda7fca /libc/netbsd
parent6a9b888d7c4b246f6f66360789c72b754ff85021 (diff)
downloadbionic-50ace4fec5e8cb5afcbc656a4556fa528adfd760.zip
bionic-50ace4fec5e8cb5afcbc656a4556fa528adfd760.tar.gz
bionic-50ace4fec5e8cb5afcbc656a4556fa528adfd760.tar.bz2
Remove compiler warnings when building Bionic.
Also add missing declarations to misc. functions. Fix clearerr() implementation (previous was broken). Handle feature test macros like _POSIX_C_SOURCE properly. Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4
Diffstat (limited to 'libc/netbsd')
-rw-r--r--libc/netbsd/isc/ev_timers.c1
-rw-r--r--libc/netbsd/nameser/ns_ttl.c2
-rw-r--r--libc/netbsd/net/base64.c2
-rw-r--r--libc/netbsd/net/getaddrinfo.c27
-rw-r--r--libc/netbsd/net/getnameinfo.c7
5 files changed, 25 insertions, 14 deletions
diff --git a/libc/netbsd/isc/ev_timers.c b/libc/netbsd/isc/ev_timers.c
index 9674687..a584f99 100644
--- a/libc/netbsd/isc/ev_timers.c
+++ b/libc/netbsd/isc/ev_timers.c
@@ -33,6 +33,7 @@ __RCSID("$NetBSD: ev_timers.c,v 1.2 2004/05/20 19:52:31 christos Exp $");
/* Import. */
#include <errno.h>
+#include <time.h>
#include <isc/assertions.h>
#include <isc/eventlib.h>
diff --git a/libc/netbsd/nameser/ns_ttl.c b/libc/netbsd/nameser/ns_ttl.c
index 0878194..cc98331 100644
--- a/libc/netbsd/nameser/ns_ttl.c
+++ b/libc/netbsd/nameser/ns_ttl.c
@@ -47,7 +47,7 @@ static int fmt1(int t, char s, char **buf, size_t *buflen);
/* Macros. */
-#define T(x) if ((x) < 0) return (-1); else
+#define T(x) do { if ((x) < 0) return (-1); } while(0)
/* Public. */
diff --git a/libc/netbsd/net/base64.c b/libc/netbsd/net/base64.c
index 70caaf7..7270703 100644
--- a/libc/netbsd/net/base64.c
+++ b/libc/netbsd/net/base64.c
@@ -141,7 +141,7 @@ b64_ntop(src, srclength, target, targsize)
size_t targsize;
{
size_t datalength = 0;
- u_char input[3];
+ u_char input[3] = { 0, 0, 0 }; /* make compiler happy */
u_char output[4];
size_t i;
diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c
index 51079ae..e7564c4 100644
--- a/libc/netbsd/net/getaddrinfo.c
+++ b/libc/netbsd/net/getaddrinfo.c
@@ -100,6 +100,12 @@
#include <stdarg.h>
#include "nsswitch.h"
+typedef union sockaddr_union {
+ struct sockaddr generic;
+ struct sockaddr_in in;
+ struct sockaddr_in6 in6;
+} sockaddr_union;
+
#define SUCCESS 0
#define ANY 0
#define YES 1
@@ -349,13 +355,14 @@ _have_ipv6() {
{{{ 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}},
/* scope ID */
0};
- static const struct sockaddr *sa_test = (struct sockaddr *) &sin6_test;
+ sockaddr_union addr_test;
+ addr_test.in6 = sin6_test;
int s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (s < 0)
return 0;
int ret;
do {
- ret = connect(s, sa_test, sizeof(sin6_test));
+ ret = connect(s, &addr_test.generic, sizeof(addr_test.in6));
} while (ret < 0 && errno == EINTR);
int have_ipv6 = (ret == 0);
do {
@@ -1261,7 +1268,7 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
struct addrinfo_sort_elem {
struct addrinfo *ai;
int has_src_addr;
- struct sockaddr_in6 src_addr; /* Large enough to hold IPv4 or IPv6. */
+ sockaddr_union src_addr;
int original_order;
};
@@ -1433,11 +1440,11 @@ _rfc3484_compare(const void *ptr1, const void* ptr2)
}
/* Rule 2: Prefer matching scope. */
- scope_src1 = _get_scope((const struct sockaddr *)&a1->src_addr);
+ scope_src1 = _get_scope(&a1->src_addr.generic);
scope_dst1 = _get_scope(a1->ai->ai_addr);
scope_match1 = (scope_src1 == scope_dst1);
- scope_src2 = _get_scope((const struct sockaddr *)&a2->src_addr);
+ scope_src2 = _get_scope(&a2->src_addr.generic);
scope_dst2 = _get_scope(a2->ai->ai_addr);
scope_match2 = (scope_src2 == scope_dst2);
@@ -1456,11 +1463,11 @@ _rfc3484_compare(const void *ptr1, const void* ptr2)
*/
/* Rule 5: Prefer matching label. */
- label_src1 = _get_label((const struct sockaddr *)&a1->src_addr);
+ label_src1 = _get_label(&a1->src_addr.generic);
label_dst1 = _get_label(a1->ai->ai_addr);
label_match1 = (label_src1 == label_dst1);
- label_src2 = _get_label((const struct sockaddr *)&a2->src_addr);
+ label_src2 = _get_label(&a2->src_addr.generic);
label_dst2 = _get_label(a2->ai->ai_addr);
label_match2 = (label_src2 == label_dst2);
@@ -1493,9 +1500,9 @@ _rfc3484_compare(const void *ptr1, const void* ptr2)
*/
if (a1->has_src_addr && a1->ai->ai_addr->sa_family == AF_INET6 &&
a2->has_src_addr && a2->ai->ai_addr->sa_family == AF_INET6) {
- const struct sockaddr_in6 *a1_src = (const struct sockaddr_in6 *)&a1->src_addr;
+ const struct sockaddr_in6 *a1_src = &a1->src_addr.in6;
const struct sockaddr_in6 *a1_dst = (const struct sockaddr_in6 *)a1->ai->ai_addr;
- const struct sockaddr_in6 *a2_src = (const struct sockaddr_in6 *)&a2->src_addr;
+ const struct sockaddr_in6 *a2_src = &a2->src_addr.in6;
const struct sockaddr_in6 *a2_dst = (const struct sockaddr_in6 *)a2->ai->ai_addr;
prefixlen1 = _common_prefix_len(&a1_src->sin6_addr, &a1_dst->sin6_addr);
prefixlen2 = _common_prefix_len(&a2_src->sin6_addr, &a2_dst->sin6_addr);
@@ -1600,7 +1607,7 @@ _rfc3484_sort(struct addrinfo *list_sentinel)
elems[i].ai = cur;
elems[i].original_order = i;
- has_src_addr = _find_src_addr(cur->ai_addr, (struct sockaddr *)&elems[i].src_addr);
+ has_src_addr = _find_src_addr(cur->ai_addr, &elems[i].src_addr.generic);
if (has_src_addr == -1) {
goto error;
}
diff --git a/libc/netbsd/net/getnameinfo.c b/libc/netbsd/net/getnameinfo.c
index db04fbf..3666443 100644
--- a/libc/netbsd/net/getnameinfo.c
+++ b/libc/netbsd/net/getnameinfo.c
@@ -339,11 +339,14 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags)
assert(addr != NULL);
assert(host != NULL);
+ if (hostlen < 0)
+ return EAI_OVERFLOW;
+
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
return EAI_SYSTEM;
numaddrlen = strlen(numaddr);
- if (numaddrlen + 1 > hostlen) /* don't forget terminator */
+ if (numaddrlen + 1 > (size_t)hostlen) /* don't forget terminator */
return EAI_OVERFLOW;
strlcpy(host, numaddr, hostlen);
@@ -356,7 +359,7 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags)
zonebuf, sizeof(zonebuf), flags);
if (zonelen < 0)
return EAI_OVERFLOW;
- if ((size_t) zonelen + 1 + numaddrlen + 1 > hostlen)
+ if ((size_t) zonelen + 1 + numaddrlen + 1 > (size_t)hostlen)
return EAI_OVERFLOW;
/* construct <numeric-addr><delim><zoneid> */
memcpy(host + numaddrlen + 1, zonebuf,