- constify some read-only members and remove superfluous casts
[oweals/busybox.git] / docs / ipv4_ipv6.txt
index 5a63aa7764beaa1ee1aad455b1d55bb287844c46..92010b59cda5cbf8773513e3543872ac3c6a8685 100644 (file)
@@ -166,7 +166,7 @@ Modified IPv6-aware C code:
     int error;
 
     /* Get host address. Any type of address will do. */
-    bzero(&hints, sizeof(hints));
+    memset(&hints, 0, sizeof(hints));
     hints.ai_flags = AI_ALL|AI_ADDRCONFIG;
     hints.ai_socktype = SOCK_STREAM;
 
@@ -175,7 +175,7 @@ Modified IPv6-aware C code:
        (void) fprintf(stderr,
           "getaddrinfo: %s for host %s service %s\n",
           gai_strerror(error), hostname, servicename);
-       return (-1);
+       return -1;
     }
     /* Try all returned addresses until one works */
     for (aip = res; aip != NULL; aip = aip->ai_next) {
@@ -187,7 +187,7 @@ Modified IPv6-aware C code:
        if (sock == -1) {
           perror("socket");
           freeaddrinfo(res);
-          return (-1);
+          return -1;
        }
 
        /* Connect to the host. */
@@ -212,7 +212,8 @@ structure the code differently.
 Here's the corresponding server C code for a dual-stack platform:
 
     int ServSock, csock;
-    struct sockaddr addr, from;
+    /* struct sockaddr is too small! */
+    struct sockaddr_storage addr, from;
     ...
     ServSock = socket(AF_INET6, SOCK_STREAM, PF_INET6);
     bind(ServSock, &addr, sizeof(addr));