Fix all resolv warnings and turn on -Werror.
The res_init.c changes bring us a bit closer to upstream too, though there's still work to be done there. Some of the remaining differences look like bugs we'd want to fix, so we should definitely try to come back to that. Change-Id: I50baa148e967c90d55d711e9904ad54c7d724d4d
This commit is contained in:
parent
99e2a2f04c
commit
37b1b5bbcd
@ -637,7 +637,6 @@ LOCAL_CFLAGS := \
|
|||||||
-I$(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
|
-I$(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
|
||||||
-I$(LOCAL_PATH)/upstream-netbsd/android/include \
|
-I$(LOCAL_PATH)/upstream-netbsd/android/include \
|
||||||
-include netbsd-compat.h \
|
-include netbsd-compat.h \
|
||||||
-Wno-error \
|
|
||||||
|
|
||||||
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
|
@ -34,7 +34,6 @@ struct servent *
|
|||||||
getservbyname(const char *name, const char *proto)
|
getservbyname(const char *name, const char *proto)
|
||||||
{
|
{
|
||||||
res_static rs = __res_get_static();
|
res_static rs = __res_get_static();
|
||||||
struct servent* s;
|
|
||||||
|
|
||||||
if (rs == NULL || proto == NULL || name == NULL) {
|
if (rs == NULL || proto == NULL || name == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
@ -33,7 +33,6 @@ struct servent *
|
|||||||
getservbyport(int port, const char *proto)
|
getservbyport(int port, const char *proto)
|
||||||
{
|
{
|
||||||
res_static rs = __res_get_static();
|
res_static rs = __res_get_static();
|
||||||
struct servent* s;
|
|
||||||
|
|
||||||
if (rs == NULL || proto == NULL) {
|
if (rs == NULL || proto == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
@ -2043,7 +2043,7 @@ _resolv_populate_res_for_net(res_state statp)
|
|||||||
register char **pp = statp->dnsrch;
|
register char **pp = statp->dnsrch;
|
||||||
register int *p = info->dnsrch_offset;
|
register int *p = info->dnsrch_offset;
|
||||||
while (pp < statp->dnsrch + MAXDNSRCH && *p != -1) {
|
while (pp < statp->dnsrch + MAXDNSRCH && *p != -1) {
|
||||||
*pp++ = &statp->defdname + *p++;
|
*pp++ = &statp->defdname[0] + *p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&_res_cache_list_lock);
|
pthread_mutex_unlock(&_res_cache_list_lock);
|
||||||
|
@ -104,10 +104,6 @@ __RCSID("$NetBSD: res_init.c,v 1.8 2006/03/19 03:10:08 christos Exp $");
|
|||||||
#include <sys/system_properties.h>
|
#include <sys/system_properties.h>
|
||||||
#endif /* ANDROID_CHANGES */
|
#endif /* ANDROID_CHANGES */
|
||||||
|
|
||||||
#ifndef MIN
|
|
||||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ensure that sockaddr_in6 and IN6ADDR_ANY_INIT are declared / defined */
|
/* ensure that sockaddr_in6 and IN6ADDR_ANY_INIT are declared / defined */
|
||||||
#ifdef ANDROID_CHANGES
|
#ifdef ANDROID_CHANGES
|
||||||
#include "resolv_netid.h"
|
#include "resolv_netid.h"
|
||||||
@ -125,9 +121,11 @@ __RCSID("$NetBSD: res_init.c,v 1.8 2006/03/19 03:10:08 christos Exp $");
|
|||||||
|
|
||||||
static void res_setoptions __P((res_state, const char *, const char *));
|
static void res_setoptions __P((res_state, const char *, const char *));
|
||||||
|
|
||||||
|
#ifdef RESOLVSORT
|
||||||
static const char sort_mask[] = "/&";
|
static const char sort_mask[] = "/&";
|
||||||
#define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL)
|
#define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL)
|
||||||
static u_int32_t net_mask __P((struct in_addr));
|
static uint32_t net_mask(struct in_addr);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(isascii) /* XXX - could be a function */
|
#if !defined(isascii) /* XXX - could be a function */
|
||||||
# define isascii(c) (!(c & 0200))
|
# define isascii(c) (!(c & 0200))
|
||||||
@ -168,15 +166,25 @@ res_ninit(res_state statp) {
|
|||||||
/* This function has to be reachable by res_data.c but not publicly. */
|
/* This function has to be reachable by res_data.c but not publicly. */
|
||||||
int
|
int
|
||||||
__res_vinit(res_state statp, int preinit) {
|
__res_vinit(res_state statp, int preinit) {
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
|
#endif
|
||||||
register char *cp, **pp;
|
register char *cp, **pp;
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
register int n;
|
register int n;
|
||||||
|
#endif
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int nserv = 0; /* number of nameserver records read from file */
|
int nserv = 0; /* number of nameserver records read from file */
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
int haveenv = 0;
|
int haveenv = 0;
|
||||||
|
#endif
|
||||||
int havesearch = 0;
|
int havesearch = 0;
|
||||||
|
#ifdef RESOLVSORT
|
||||||
int nsort = 0;
|
int nsort = 0;
|
||||||
|
#endif
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
char *net;
|
char *net;
|
||||||
|
#endif
|
||||||
int dots;
|
int dots;
|
||||||
union res_sockaddr_union u[2];
|
union res_sockaddr_union u[2];
|
||||||
|
|
||||||
@ -235,7 +243,7 @@ __res_vinit(res_state statp, int preinit) {
|
|||||||
statp->nsort = 0;
|
statp->nsort = 0;
|
||||||
res_setservers(statp, u, nserv);
|
res_setservers(statp, u, nserv);
|
||||||
|
|
||||||
#if 0 /* IGNORE THE ENVIRONMENT */
|
#if !defined(__ANDROID__) /* IGNORE THE ENVIRONMENT */
|
||||||
/* Allow user to override the local domain definition */
|
/* Allow user to override the local domain definition */
|
||||||
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
|
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
|
||||||
(void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
|
(void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
|
||||||
@ -593,12 +601,12 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RESOLVSORT
|
||||||
/* XXX - should really support CIDR which means explicit masks always. */
|
/* XXX - should really support CIDR which means explicit masks always. */
|
||||||
static u_int32_t
|
static uint32_t
|
||||||
net_mask(in) /* XXX - should really use system's version of this */
|
net_mask(struct in_addr in) /*!< XXX - should really use system's version of this */
|
||||||
struct in_addr in;
|
|
||||||
{
|
{
|
||||||
register u_int32_t i = ntohl(in.s_addr);
|
register uint32_t i = ntohl(in.s_addr);
|
||||||
|
|
||||||
if (IN_CLASSA(i))
|
if (IN_CLASSA(i))
|
||||||
return (htonl(IN_CLASSA_NET));
|
return (htonl(IN_CLASSA_NET));
|
||||||
@ -606,6 +614,7 @@ net_mask(in) /* XXX - should really use system's version of this */
|
|||||||
return (htonl(IN_CLASSB_NET));
|
return (htonl(IN_CLASSB_NET));
|
||||||
return (htonl(IN_CLASSC_NET));
|
return (htonl(IN_CLASSC_NET));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ANDROID_CHANGES
|
#ifdef ANDROID_CHANGES
|
||||||
static int
|
static int
|
||||||
@ -617,8 +626,7 @@ real_randomid(u_int *random_value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* read from the random device, returning -1 on failure (or too many retries)*/
|
/* read from the random device, returning -1 on failure (or too many retries)*/
|
||||||
u_int retry = 5;
|
for (u_int retry = 5; retry > 0; retry--) {
|
||||||
for (retry; retry > 0; retry--) {
|
|
||||||
int retval = read(random_device, random_value, sizeof(u_int));
|
int retval = read(random_device, random_value, sizeof(u_int));
|
||||||
if (retval == sizeof(u_int)) {
|
if (retval == sizeof(u_int)) {
|
||||||
*random_value &= 0xffff;
|
*random_value &= 0xffff;
|
||||||
@ -649,7 +657,7 @@ res_randomid(void) {
|
|||||||
return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
|
return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*%
|
||||||
* This routine is for closing the socket if a virtual circuit is used and
|
* This routine is for closing the socket if a virtual circuit is used and
|
||||||
* the program wants to close it. This provides support for endhostent()
|
* the program wants to close it. This provides support for endhostent()
|
||||||
* which expects to close the socket.
|
* which expects to close the socket.
|
||||||
@ -657,7 +665,8 @@ res_randomid(void) {
|
|||||||
* This routine is not expected to be user visible.
|
* This routine is not expected to be user visible.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
res_nclose(res_state statp) {
|
res_nclose(res_state statp)
|
||||||
|
{
|
||||||
int ns;
|
int ns;
|
||||||
|
|
||||||
if (statp->_vcsock >= 0) {
|
if (statp->_vcsock >= 0) {
|
||||||
@ -674,7 +683,8 @@ res_nclose(res_state statp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
res_ndestroy(res_state statp) {
|
res_ndestroy(res_state statp)
|
||||||
|
{
|
||||||
res_nclose(statp);
|
res_nclose(statp);
|
||||||
if (statp->_u._ext.ext != NULL)
|
if (statp->_u._ext.ext != NULL)
|
||||||
free(statp->_u._ext.ext);
|
free(statp->_u._ext.ext);
|
||||||
@ -683,21 +693,24 @@ res_ndestroy(res_state statp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
res_get_nibblesuffix(res_state statp) {
|
res_get_nibblesuffix(res_state statp)
|
||||||
|
{
|
||||||
if (statp->_u._ext.ext)
|
if (statp->_u._ext.ext)
|
||||||
return (statp->_u._ext.ext->nsuffix);
|
return (statp->_u._ext.ext->nsuffix);
|
||||||
return ("ip6.arpa");
|
return ("ip6.arpa");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
res_get_nibblesuffix2(res_state statp) {
|
res_get_nibblesuffix2(res_state statp)
|
||||||
|
{
|
||||||
if (statp->_u._ext.ext)
|
if (statp->_u._ext.ext)
|
||||||
return (statp->_u._ext.ext->nsuffix2);
|
return (statp->_u._ext.ext->nsuffix2);
|
||||||
return ("ip6.int");
|
return ("ip6.int");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
|
res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt)
|
||||||
|
{
|
||||||
int i, nserv;
|
int i, nserv;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
@ -718,10 +731,8 @@ res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
|
|||||||
if (size <= sizeof(statp->nsaddr_list[nserv]))
|
if (size <= sizeof(statp->nsaddr_list[nserv]))
|
||||||
memcpy(&statp->nsaddr_list[nserv],
|
memcpy(&statp->nsaddr_list[nserv],
|
||||||
&set->sin, size);
|
&set->sin, size);
|
||||||
#ifdef notdef
|
|
||||||
else
|
else
|
||||||
statp->nsaddr_list[nserv].sin_family = 0;
|
statp->nsaddr_list[nserv].sin_family = 0;
|
||||||
#endif
|
|
||||||
nserv++;
|
nserv++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -750,10 +761,11 @@ res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) {
|
res_getservers(res_state statp, union res_sockaddr_union *set, int cnt)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
size_t size;
|
size_t size;
|
||||||
u_int16_t family;
|
uint16_t family;
|
||||||
|
|
||||||
for (i = 0; i < statp->nscount && i < cnt; i++) {
|
for (i = 0; i < statp->nscount && i < cnt; i++) {
|
||||||
if (statp->_u._ext.ext)
|
if (statp->_u._ext.ext)
|
||||||
|
@ -764,7 +764,7 @@ send_vc(res_state statp,
|
|||||||
struct sockaddr_storage peer;
|
struct sockaddr_storage peer;
|
||||||
socklen_t size = sizeof peer;
|
socklen_t size = sizeof peer;
|
||||||
unsigned old_mark;
|
unsigned old_mark;
|
||||||
int mark_size = sizeof(old_mark);
|
socklen_t mark_size = sizeof(old_mark);
|
||||||
if (getpeername(statp->_vcsock,
|
if (getpeername(statp->_vcsock,
|
||||||
(struct sockaddr *)(void *)&peer, &size) < 0 ||
|
(struct sockaddr *)(void *)&peer, &size) < 0 ||
|
||||||
!sock_eq((struct sockaddr *)(void *)&peer, nsap) ||
|
!sock_eq((struct sockaddr *)(void *)&peer, nsap) ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user