Permalink
Browse files

lint fixes from netbsd camp.

remove #ifdef FAITH part, which has been broken for a long time.
(should use totd, or /etc/hosts - we shouldn't put tweak in resolver)
  • Loading branch information...
1 parent 553dc30 commit 2960a3c7161e9fd171db03863f18bcea3692a945 itojun committed Jan 23, 2000
Showing with 18 additions and 41 deletions.
  1. +18 −41 kame/kame/libinet6/getaddrinfo.c
View
59 kame/kame/libinet6/getaddrinfo.c
@@ -28,8 +28,6 @@
*/
/*
- * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
- *
* Issues to be discussed:
* - Thread safe-ness must be checked.
* - Return values. There are nonstandard return values defined and used
@@ -85,20 +83,11 @@
#include "addrinfo.h"
#endif
-#if defined(__KAME__) && defined(INET6)
-# define FAITH
-#endif
-
#define SUCCESS 0
#define ANY 0
#define YES 1
#define NO 0
-#ifdef FAITH
-static int translate = NO;
-static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT;
-#endif
-
static const char in_addrany[] = { 0, 0, 0, 0 };
static const char in6_addrany[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -173,7 +162,7 @@ static const struct explore explore[] = {
static int str_isnumber __P((const char *));
static int explore_fqdn __P((const struct addrinfo *, const char *,
const char *, struct addrinfo **));
-static int explore_null __P((const struct addrinfo *, const char *,
+static int explore_null __P((const struct addrinfo *,
const char *, struct addrinfo **));
static int explore_numeric __P((const struct addrinfo *, const char *,
const char *, struct addrinfo **));
@@ -217,35 +206,35 @@ do { \
error = EAI_MEMORY; \
goto free; \
} \
-} while (0)
+} while (/*CONSTCOND*/0)
#define GET_PORT(ai, serv) \
do { \
/* external reference: error and label free */ \
error = get_port((ai), (serv), 0); \
if (error != 0) \
goto free; \
-} while (0)
+} while (/*CONSTCOND*/0)
#define GET_CANONNAME(ai, str) \
do { \
/* external reference: pai, error and label free */ \
error = get_canonname(pai, (ai), (str)); \
if (error != 0) \
goto free; \
-} while (0)
+} while (/*CONSTCOND*/0)
#define ERR(err) \
do { \
/* external reference: error, and label bad */ \
error = (err); \
goto bad; \
-} while (0)
+} while (/*CONSTCOND*/0)
#define MATCH_FAMILY(x, y, w) \
- ((x) == (y) || ((w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
+ ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
#define MATCH(x, y, w) \
- ((x) == (y) || ((w) && ((x) == ANY || (y) == ANY)))
+ ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY)))
char *
gai_strerror(ecode)
@@ -275,9 +264,9 @@ static int
str_isnumber(p)
const char *p;
{
- char *q = (char *)p;
+ const char *q = (const char *)p;
while (*q) {
- if (! isdigit(*q))
+ if (!isdigit(*q))
return NO;
q++;
}
@@ -299,18 +288,6 @@ getaddrinfo(hostname, servname, hints, res)
const struct afd *afd;
const struct explore *ex;
-#ifdef FAITH
- static int firsttime = 1;
-
- if (firsttime) {
- /* translator hack */
- char *q = getenv("GAI");
- if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
- translate = YES;
- firsttime = 0;
- }
-#endif
-
sentinel.ai_next = NULL;
cur = &sentinel;
pai = &ai;
@@ -374,6 +351,7 @@ getaddrinfo(hostname, servname, hints, res)
|| MATCH_FAMILY(pai->ai_family, PF_INET6, 1)
#endif
) {
+ /* call to get_portmatch() can conterminate *pai */
ai0 = *pai;
if (pai->ai_family == PF_UNSPEC) {
@@ -411,7 +389,7 @@ getaddrinfo(hostname, servname, hints, res)
pai->ai_protocol = ex->e_protocol;
if (hostname == NULL)
- error = explore_null(pai, hostname, servname, &cur->ai_next);
+ error = explore_null(pai, servname, &cur->ai_next);
else
error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next);
@@ -601,7 +579,7 @@ explore_fqdn(pai, hostname, servname, res)
;
naddrs++;
aplist = (char **)malloc(sizeof(aplist[0]) * naddrs);
- apbuf = (char *)malloc(hp->h_length * naddrs);
+ apbuf = (char *)malloc((size_t)hp->h_length * naddrs);
if (aplist == NULL || apbuf == NULL) {
error = EAI_MEMORY;
goto free;
@@ -613,7 +591,7 @@ explore_fqdn(pai, hostname, servname, res)
continue;
}
memcpy(&apbuf[i * hp->h_length], hp->h_addr_list[i],
- hp->h_length);
+ (size_t)hp->h_length);
aplist[i] = &apbuf[i * hp->h_length];
}
#endif
@@ -678,9 +656,8 @@ explore_fqdn(pai, hostname, servname, res)
* non-passive socket -> localhost (127.0.0.1 or ::1)
*/
static int
-explore_null(pai, hostname, servname, res)
+explore_null(pai, servname, res)
const struct addrinfo *pai;
- const char *hostname;
const char *servname;
struct addrinfo **res;
{
@@ -927,11 +904,11 @@ get_name(addr, afd, res, numaddr, pai, servname)
GET_CANONNAME(cur, hp->h_name);
#else
/* hp will be damaged if we use gethostbyaddr() */
- if ((ap = (char *)malloc(hp->h_length)) == NULL) {
+ if ((ap = (char *)malloc((size_t)hp->h_length)) == NULL) {
error = EAI_MEMORY;
goto free;
}
- memcpy(ap, hp->h_addr_list[0], hp->h_length);
+ memcpy(ap, hp->h_addr_list[0], (size_t)hp->h_length);
if ((cn = strdup(hp->h_name)) == NULL) {
error = EAI_MEMORY;
goto free;
@@ -1000,14 +977,14 @@ get_ai(pai, afd, addr)
memcpy(ai, pai, sizeof(struct addrinfo));
ai->ai_addr = (struct sockaddr *)(ai + 1);
- memset(ai->ai_addr, 0, afd->a_socklen);
+ memset(ai->ai_addr, 0, (size_t)afd->a_socklen);
#ifdef HAVE_SOCKADDR_SA_LEN
ai->ai_addr->sa_len = afd->a_socklen;
#endif
ai->ai_addrlen = afd->a_socklen;
ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
p = (char *)(ai->ai_addr);
- memcpy(p + afd->a_off, addr, afd->a_addrlen);
+ memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen);
return ai;
}

0 comments on commit 2960a3c

Please sign in to comment.