Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/net Partially delint.



details:   https://anonhg.NetBSD.org/src/rev/0837e009b6db
branches:  trunk
changeset: 480907:0837e009b6db
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Sat Jan 22 23:54:20 2000 +0000

description:
Partially delint.

diffstat:

 lib/libc/net/getaddrinfo.c |  41 ++++++++++++++++++-----------------------
 lib/libc/net/getnameinfo.c |  26 ++++++++++++++------------
 2 files changed, 32 insertions(+), 35 deletions(-)

diffs (238 lines):

diff -r 48d34f39f1f1 -r 0837e009b6db lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c        Sat Jan 22 23:53:08 2000 +0000
+++ b/lib/libc/net/getaddrinfo.c        Sat Jan 22 23:54:20 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getaddrinfo.c,v 1.19 2000/01/17 15:57:29 itojun Exp $  */
+/*     $NetBSD: getaddrinfo.c,v 1.20 2000/01/22 23:54:20 mycroft Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
 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 **));
@@ -192,7 +192,7 @@
                error = EAI_MEMORY; \
                goto free; \
        } \
-} while (0)
+} while (/*CONSTCOND*/0)
 
 #define GET_PORT(ai, serv) \
 do { \
@@ -200,7 +200,7 @@
        error = get_port((ai), (serv), 0); \
        if (error != 0) \
                goto free; \
-} while (0)
+} while (/*CONSTCOND*/0)
 
 #define GET_CANONNAME(ai, str) \
 do { \
@@ -208,19 +208,19 @@
        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)
@@ -250,9 +250,9 @@
 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++;
        }
@@ -346,15 +346,11 @@
         */
        if (MATCH_FAMILY(pai->ai_family, PF_INET, 1)
         || MATCH_FAMILY(pai->ai_family, PF_INET6, 1)) {
-               ai0 = *pai;
-
                if (pai->ai_family == PF_UNSPEC)
                        pai->ai_family = PF_INET6;
                error = get_portmatch(pai, servname);
                if (error)
                        ERR(error);
-
-               *pai = ai0;
        }
 
        ai0 = *pai;
@@ -378,7 +374,7 @@
                        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);
 
@@ -568,7 +564,7 @@
                ;
        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;
@@ -580,7 +576,7 @@
                        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
@@ -643,9 +639,8 @@
  * 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;
 {
@@ -892,11 +887,11 @@
                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;
@@ -965,12 +960,12 @@
 
        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);
        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);
-       memcpy(p + afd->a_off, addr, afd->a_addrlen);
+       memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen);
        return ai;
 }
 
diff -r 48d34f39f1f1 -r 0837e009b6db lib/libc/net/getnameinfo.c
--- a/lib/libc/net/getnameinfo.c        Sat Jan 22 23:53:08 2000 +0000
+++ b/lib/libc/net/getnameinfo.c        Sat Jan 22 23:54:20 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getnameinfo.c,v 1.8 2000/01/17 08:34:05 itojun Exp $   */
+/*     $NetBSD: getnameinfo.c,v 1.9 2000/01/22 23:59:46 mycroft Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -99,9 +99,12 @@
        struct hostent *hp;
        u_short port;
        int family, i;
-       char *addr, *p;
+       const char *addr;
+       char *p;
        u_int32_t v4a;
+#ifdef USE_GETIPNODEBY
        int h_error;
+#endif
        char numserv[512];
        char numaddr[512];
 
@@ -123,8 +126,8 @@
        if (salen != afd->a_socklen)
                return ENI_SALEN;
        
-       port = ((struct sockinet *)sa)->si_port; /* network byte order */
-       addr = (char *)sa + afd->a_off;
+       port = ((const struct sockinet *)sa)->si_port; /* network byte order */
+       addr = (const char *)sa + afd->a_off;
 
        if (serv == NULL || servlen == 0) {
                /*
@@ -155,7 +158,7 @@
        switch (sa->sa_family) {
        case AF_INET:
                v4a = (u_int32_t)
-                       ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
+                       ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
                if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
                        flags |= NI_NUMERICHOST;
                v4a >>= IN_CLASSA_NSHIFT;
@@ -165,8 +168,8 @@
 #ifdef INET6
        case AF_INET6:
            {
-               struct sockaddr_in6 *sin6;
-               sin6 = (struct sockaddr_in6 *)sa;
+               const struct sockaddr_in6 *sin6;
+               sin6 = (const struct sockaddr_in6 *)sa;
                switch (sin6->sin6_addr.s6_addr[0]) {
                case 0x00:
                        if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
@@ -207,16 +210,16 @@
                strcpy(host, numaddr);
 #if defined(INET6) && defined(NI_WITHSCOPEID)
                if (afd->a_af == AF_INET6 &&
-                   (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
-                    IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
-                   ((struct sockaddr_in6 *)sa)->sin6_scope_id) {
+                   (IN6_IS_ADDR_LINKLOCAL((const struct in6_addr *)addr) ||
+                    IN6_IS_ADDR_MULTICAST((const struct in6_addr *)addr)) &&
+                   ((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
 #ifndef ALWAYS_WITHSCOPE
                        if (flags & NI_WITHSCOPEID)
 #endif /* !ALWAYS_WITHSCOPE */
                        {
                                char *ep = strchr(host, '\0');
                                unsigned int ifindex =
-                                       ((struct sockaddr_in6 *)sa)->sin6_scope_id;
+                                       ((const struct sockaddr_in6 *)sa)->sin6_scope_id;
 
                                *ep = SCOPE_DELIMITER;
                                if ((if_indextoname(ifindex, ep + 1)) == NULL)
@@ -230,7 +233,6 @@
                hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
 #else
                hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-               h_error = h_errno;
 #endif
 
                if (hp) {



Home | Main Index | Thread Index | Old Index