]> sjero.net Git - wget/blobdiff - src/host.c
[svn] Minor fixes prompted by `lint'.
[wget] / src / host.c
index a769fd9725d5d99470320526442790fc5ba9d0ae..e27383d6f44867ccf8c268fdd2456805579703c5 100644 (file)
@@ -69,7 +69,7 @@ extern int h_errno;
 
 /* Mapping between known hosts and to lists of their addresses. */
 
-struct hash_table *host_name_addresses_map;
+static struct hash_table *host_name_addresses_map;
 \f
 /* Lists of addresses.  This should eventually be extended to handle
    IPv6.  */
@@ -124,6 +124,13 @@ address_list_match_all (struct address_list *al1, struct address_list *al2)
 void
 address_list_set_faulty (struct address_list *al, int index)
 {
+#if 0
+  /* Warning: INDEX is unused, so this assumes that the address list
+     is traversed in order.  In the next release, either enable this
+     assert, or use INDEX.  */
+  assert (index == al->faulty);
+#endif
+
   ++al->faulty;
   if (al->faulty >= al->count)
     /* All addresses have been proven faulty.  Since there's not much
@@ -157,6 +164,21 @@ address_list_new (char **h_addr_list)
   return al;
 }
 
+/* Like address_list_new, but initialized with only one address. */
+
+static struct address_list *
+address_list_new_one (const char *addr)
+{
+  struct address_list *al = xmalloc (sizeof (struct address_list));
+  al->count    = 1;
+  al->faulty   = 0;
+  al->buffer   = xmalloc (IP4_ADDRESS_LENGTH);
+  al->refcount = 1;
+  memcpy (ADDR_LOCATION (al, 0), addr, IP4_ADDRESS_LENGTH);
+
+  return al;
+}
+
 static void
 address_list_delete (struct address_list *al)
 {
@@ -223,9 +245,6 @@ lookup_host (const char *host, int silent)
   addr = (unsigned long)inet_addr (host);
   if ((int)addr != -1)
     {
-      char tmpstore[IP4_ADDRESS_LENGTH];
-      char *lst[] = { tmpstore, NULL };
-
       /* ADDR is defined to be in network byte order, which is what
         this returns, so we can just copy it to STORE_IP.  However,
         on big endian 64-bit architectures the value will be stored
@@ -237,8 +256,7 @@ lookup_host (const char *host, int silent)
 #else
       offset = 0;
 #endif
-      memcpy (tmpstore, (char *)&addr + offset, IP4_ADDRESS_LENGTH);
-      return address_list_new (lst);
+      return address_list_new_one ((char *)&addr + offset);
     }
 
   /* By now we know that the host name we got is not of the form
@@ -268,6 +286,8 @@ lookup_host (const char *host, int silent)
   if (!silent)
     logprintf (LOG_VERBOSE, _("done.\n"));
 
+  /* Do all systems have h_addr_list, or is it a newer thing?  If the
+     latter, use address_list_new_one.  */
   al = address_list_new (hptr->h_addr_list);
 
   /* Cache the lookup information. */