diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index b5310181e741..d32b2cde24a1 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.35 2000/03/16 13:51:43 itojun Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.36 2000/04/02 21:30:37 christos Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -296,6 +296,7 @@ do { \ /* external reference: error, and label bad */ \ error = (err); \ goto bad; \ + /*NOTREACHED*/ \ } while (/*CONSTCOND*/0) #define MATCH_FAMILY(x, y, w) \ @@ -682,7 +683,6 @@ explore_numeric(pai, hostname, servname, res) struct addrinfo sentinel; int error; char pton[PTON_MAX]; - int flags; *res = NULL; sentinel.ai_next = NULL; @@ -695,7 +695,6 @@ explore_numeric(pai, hostname, servname, res) return 0; afd = find_afd(pai->ai_family); - flags = pai->ai_flags; switch (afd->a_af) { #if 0 /*X/Open spec*/ @@ -800,7 +799,7 @@ explore_numeric_scope(pai, hostname, servname, res) for (cur = *res; cur; cur = cur->ai_next) { if (cur->ai_family != AF_INET6) continue; - sin6 = (struct sockaddr_in6 *)cur->ai_addr; + sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr; if ((scopeid = ip6_str2scopeid(scope, sin6)) == -1) { free(hostname2); return(EAI_NONAME); /* XXX: is return OK? */ @@ -845,12 +844,12 @@ get_ai(pai, afd, addr) return NULL; memcpy(ai, pai, sizeof(struct addrinfo)); - ai->ai_addr = (struct sockaddr *)(ai + 1); + ai->ai_addr = (struct sockaddr *)(void *)(ai + 1); memset(ai->ai_addr, 0, (size_t)afd->a_socklen); ai->ai_addr->sa_len = afd->a_socklen; ai->ai_addrlen = afd->a_socklen; ai->ai_addr->sa_family = ai->ai_family = afd->a_af; - p = (char *)(ai->ai_addr); + p = (char *)(void *)(ai->ai_addr); memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen); return ai; } @@ -862,6 +861,7 @@ get_portmatch(ai, servname) { /* get_port does not touch first argument. when matchonly == 1. */ + /* LINTED const cast */ return get_port((struct addrinfo *)ai, servname, 1); } @@ -929,11 +929,13 @@ get_port(ai, servname, matchonly) if (!matchonly) { switch (ai->ai_family) { case AF_INET: - ((struct sockaddr_in *)ai->ai_addr)->sin_port = port; + ((struct sockaddr_in *)(void *) + ai->ai_addr)->sin_port = port; break; #ifdef INET6 case AF_INET6: - ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port; + ((struct sockaddr_in6 *)(void *) + ai->ai_addr)->sin6_port = port; break; #endif } @@ -1044,14 +1046,12 @@ getanswer(answer, anslen, qname, qtype, pai) int type, class, buflen, ancount, qdcount; int haveanswer, had_error; char tbuf[MAXDNAME]; - const char *tname; int (*name_ok) __P((const char *)); char hostbuf[8*1024]; memset(&sentinel, 0, sizeof(sentinel)); cur = &sentinel; - tname = qname; canonname = NULL; eom = answer->buf + anslen; switch (qtype) { @@ -1186,7 +1186,7 @@ getanswer(answer, anslen, qname, qtype, pai) cp += n; continue; } - cur->ai_next = get_ai(&ai, afd, cp); + cur->ai_next = get_ai(&ai, afd, (const char *)cp); if (cur->ai_next == NULL) had_error++; while (cur && cur->ai_next) @@ -1225,7 +1225,6 @@ _dns_getaddrinfo(rv, cb_data, ap) const struct addrinfo *pai; struct addrinfo sentinel, *cur; struct res_target q, q2; - int ancount; name = va_arg(ap, char *); pai = va_arg(ap, const struct addrinfo *); @@ -1263,7 +1262,7 @@ _dns_getaddrinfo(rv, cb_data, ap) default: return NS_UNAVAIL; } - if ((ancount = res_searchN(name, &q)) < 0) + if (res_searchN(name, &q) < 0) return NS_NOTFOUND; ai = getanswer(&buf, q.n, q.name, q.type, pai); if (ai) { @@ -1415,13 +1414,13 @@ _yphostent(line, pai) const char *addr, *canonname; char *nextline; char *cp; - int more; addr = canonname = NULL; -nextline: - more = 0; + memset(&sentinel, 0, sizeof(sentinel)); + cur = &sentinel; +nextline: /* terminate line */ cp = strchr(p, '\n'); if (cp) {