]> granicus.if.org Git - python/commitdiff
Silence warnings in MSVC++: hide unused variables, add constness back to
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 21 Jul 2001 09:42:15 +0000 (09:42 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 21 Jul 2001 09:42:15 +0000 (09:42 +0000)
inet_pton/ntop, convert htons argument to u_short.

Modules/getaddrinfo.c
Modules/getnameinfo.c
Modules/socketmodule.c

index a1f4c14096f9547fabed97087cb69e72da65a6d6..f74b5d650927f8caef0815b08c02d80c69ce35f7 100644 (file)
@@ -343,7 +343,7 @@ getaddrinfo(hostname, servname, hints, res)
                                pai->ai_socktype = SOCK_DGRAM;
                                pai->ai_protocol = IPPROTO_UDP;
                        }
-                       port = htons(atoi(servname));
+                       port = htons((u_short)atoi(servname));
                } else {
                        struct servent *sp;
                        char *proto;
@@ -417,7 +417,9 @@ getaddrinfo(hostname, servname, hints, res)
        for (i = 0; gai_afdl[i].a_af; i++) {
                if (inet_pton(gai_afdl[i].a_af, hostname, pton)) {
                        u_long v4a;
+#ifdef INET6
                        u_char pfx;
+#endif
 
                        switch (gai_afdl[i].a_af) {
                        case AF_INET:
@@ -492,7 +494,10 @@ get_name(addr, gai_afd, res, numaddr, pai, port0)
        u_short port = port0 & 0xffff;
        struct hostent *hp;
        struct addrinfo *cur;
-       int error = 0, h_error;
+       int error = 0;
+#ifdef INET6
+       int h_error;
+#endif
        
 #ifdef INET6
        hp = getipnodebyaddr(addr, gai_afd->a_addrlen, gai_afd->a_af, &h_error);
index 33d6ad3084fc4e1f8d3a2dd72b5800e4d6e95056..475b531d278c69b2025ed1c39a0034f399e46be1 100644 (file)
@@ -98,7 +98,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
        int family, len, i;
        char *addr, *p;
        u_long v4a;
+#ifdef INET6
        u_char pfx;
+#endif
        int h_error;
        char numserv[512];
        char numaddr[512];
index 1841024ebd5d102042758b6afc768d5031a84017..e4bdf410d95cf9827138bd75bc4a310f0dfece85 100644 (file)
@@ -207,8 +207,8 @@ Socket methods:
 #endif /* USE_SSL */
 
 #ifndef HAVE_INET_PTON
-int inet_pton (int af, char *src, void *dst);
-char *inet_ntop(int af, void *src, char *dst, socklen_t size);
+int inet_pton (int af, const char *src, void *dst);
+const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
 #endif
 
 /* I know this is a bad practice, but it is the easiest... */
@@ -2948,7 +2948,7 @@ init_socket(void)
 /* Simplistic emulation code for inet_pton that only works for IPv4 */
 #ifndef HAVE_INET_PTON
 int 
-inet_pton (int af, char *src, void *dst)
+inet_pton (int af, const char *src, void *dst)
 {
        if(af == AF_INET){
                long packed_addr;
@@ -2966,8 +2966,8 @@ inet_pton (int af, char *src, void *dst)
        return -1;
 }
 
-char *
-inet_ntop(int af, void *src, char *dst, socklen_t size)
+const char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
 {
        if (af == AF_INET) {
                struct in_addr packed_addr;