]> sjero.net Git - wget/commitdiff
[svn] Apply lint-expired fixes from <sxsn1du7ufa.fsf@florida.arsdigita.de>.
authorhniksic <devnull@localhost>
Sun, 17 Dec 2000 18:52:52 +0000 (10:52 -0800)
committerhniksic <devnull@localhost>
Sun, 17 Dec 2000 18:52:52 +0000 (10:52 -0800)
src/ChangeLog
src/http.c
src/init.c
src/main.c
src/recur.c
src/url.c

index ef19d42af15eec4ff9fb9a626c5e67f60af848e1..1a0c447d76ef0dbfa076c014931a8c8e0524c6be 100644 (file)
@@ -1,3 +1,26 @@
+2000-12-17  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * url.c (parseurl): Rename inner loop var from i to ind to avoid
+       clash with the function top-level-declared variable i.
+       (str_url): Likewise, rename inner-loop i to j.
+
+       * recur.c (parse_robots): Don't declare LEN at top of function.
+       (robots_match): Renamed parameter FORBIDDEN to avoid hiding of
+       global variable.
+
+       * main.c (main): Change erroneous use of bitwise and to logical.
+
+       * init.c (cmd_address): Don't heap-allocate `sin'; it can be on
+       the stack because it will be copied to closure.
+
+       Thanks to Csaba Raduly's run of PC-LINT over the sources.
+
+2000-12-17  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * http.c (basic_authentication_encode): Use xmalloc(), not
+       malloc().  Thanks to Csaba Raduly's run of PC-LINT over the
+       sources.
+
 2000-12-17  Csaba Raduly  <csaba.raduly@sophos.com>
 
        * sysdep.h: Test for __EMX__ rather than for EMXOS2 for OS/2
index 8f0e86d799076a2bedb3ebdf8075d007c9d3085a..b9c8e5856453d4f7523de93905362d6c8cd17f14 100644 (file)
@@ -1851,7 +1851,7 @@ basic_authentication_encode (const char *user, const char *passwd,
   sprintf (t1, "%s:%s", user, passwd);
   t2 = (char *)alloca (1 + len2);
   base64_encode (t1, t2, len1);
-  res = (char *)malloc (len2 + 11 + strlen (header));
+  res = (char *)xmalloc (len2 + 11 + strlen (header));
   sprintf (res, "%s: Basic %s\r\n", header, t2);
 
   return res;
index 64218de7af5c54b2d7497bad1a1b38d74ab01de9..900f807d4ce8084e7b8e5e6fb8af89fcbe2ce536 100644 (file)
@@ -493,28 +493,21 @@ static int myatoi PARAMS ((const char *s));
 static int
 cmd_address (const char *com, const char *val, void *closure)
 {
-    struct sockaddr_in *sin;
-    
-    sin = (struct sockaddr_in *) malloc(sizeof *sin);
-    if (sin == NULL)
-    {
-       fprintf (stderr, _("%s: Out of memory.\n"), exec_name);
-       return 0;
-    }
-    
-    if (!store_hostaddress ((unsigned char *)&sin->sin_addr, val))
+  struct sockaddr_in sin;
+
+  if (!store_hostaddress ((unsigned char *)&sin.sin_addr, val))
     {
-       fprintf (stderr, _("%s: %s: Cannot convert `%s' to an IP address.\n"),
-                exec_name, com, val);
-       return 0;
+      fprintf (stderr, _("%s: %s: Cannot convert `%s' to an IP address.\n"),
+              exec_name, com, val);
+      return 0;
     }
-    
-    sin->sin_family = AF_INET;
-    sin->sin_port = 0;
-    
-    * (struct sockaddr_in **) closure = sin;
-    
-    return 1;
+
+  sin.sin_family = AF_INET;
+  sin.sin_port = 0;
+
+  memcpy (closure, &sin, sizeof (sin));
+
+  return 1;
 }
 
 /* Store the boolean value from VAL to CLOSURE.  COM is ignored,
index 7db0ba0288f076b3306ca28f6f837bc948d4de5c..271d509697ca7093703e23f47de784886d817bce 100644 (file)
@@ -807,7 +807,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
                   _("Download quota (%s bytes) EXCEEDED!\n"),
                   legible (opt.quota));
     }
-  if (opt.convert_links & !opt.delete_after)
+  if (opt.convert_links && !opt.delete_after)
     {
       convert_all_links ();
     }
index 21bb40b09bb71f6463f52b09ed6a683be0a3d31a..e3b06425ba4c926dcd50e07b6b6e45fff09fa6ce 100644 (file)
@@ -703,7 +703,7 @@ parse_robots (const char *robots_filename)
   char **entries;
   char *line, *cmd, *str, *p;
   char *base_version, *version;
-  int len, num, i;
+  int num, i;
   int wget_matched;            /* is the part meant for Wget?  */
 
   entries = NULL;
@@ -714,19 +714,19 @@ parse_robots (const char *robots_filename)
     return NULL;
 
   /* Kill version number.  */
-    if (opt.useragent)
-      {
-       STRDUP_ALLOCA (base_version, opt.useragent);
-       STRDUP_ALLOCA (version, opt.useragent);
-      }
-    else
-      {
-       int len = 10 + strlen (version_string);
-       base_version = (char *)alloca (len);
-       sprintf (base_version, "Wget/%s", version_string);
-       version = (char *)alloca (len);
-       sprintf (version, "Wget/%s", version_string);
-      }
+  if (opt.useragent)
+    {
+      STRDUP_ALLOCA (base_version, opt.useragent);
+      STRDUP_ALLOCA (version, opt.useragent);
+    }
+  else
+    {
+      int len = 10 + strlen (version_string);
+      base_version = (char *)alloca (len);
+      sprintf (base_version, "Wget/%s", version_string);
+      version = (char *)alloca (len);
+      sprintf (version, "Wget/%s", version_string);
+    }
   for (p = version; *p; p++)
     *p = TOLOWER (*p);
   for (p = base_version; *p && *p != '/'; p++)
@@ -755,7 +755,7 @@ parse_robots (const char *robots_filename)
   wget_matched = 1;
   while ((line = read_whole_line (fp)))
     {
-      len = strlen (line);
+      int len = strlen (line);
       /* Destroy <CR><LF> if present.  */
       if (len && line[len - 1] == '\n')
        line[--len] = '\0';
@@ -874,19 +874,19 @@ parse_robots (const char *robots_filename)
 /* May the URL url be loaded according to disallowing rules stored in
    forbidden?  */
 static int
-robots_match (struct urlinfo *u, char **forbidden)
+robots_match (struct urlinfo *u, char **fb)
 {
   int l;
 
-  if (!forbidden)
+  if (!fb)
     return 1;
   DEBUGP (("Matching %s against: ", u->path));
-  for (; *forbidden; forbidden++)
+  for (; *fb; fb++)
     {
-      DEBUGP (("%s ", *forbidden));
-      l = strlen (*forbidden);
-      /* If dir is forbidden, we may not load the file.  */
-      if (strncmp (u->path, *forbidden, l) == 0)
+      DEBUGP (("%s ", *fb));
+      l = strlen (*fb);
+      /* If dir is fb, we may not load the file.  */
+      if (strncmp (u->path, *fb, l) == 0)
        {
          DEBUGP (("matched.\n"));
          return 0; /* Matches, i.e. does not load...  */
index 0cbc3cd18275f003021ed02314a28d7c725d6f13..72711eaa93e446df5e0bc3e1314c2fcf1d09e787 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -475,13 +475,13 @@ parseurl (const char *url, struct urlinfo *u, int strict)
     u->proto = type = URLHTTP;
   if (!u->port)
     {
-      int i;
-      for (i = 0; i < ARRAY_SIZE (sup_protos); i++)
-       if (sup_protos[i].ind == type)
+      int ind;
+      for (ind = 0; ind < ARRAY_SIZE (sup_protos); ind++)
+       if (sup_protos[ind].ind == type)
          break;
-      if (i == ARRAY_SIZE (sup_protos))
+      if (ind == ARRAY_SIZE (sup_protos))
        return URLUNKNOWN;
-      u->port = sup_protos[i].port;
+      u->port = sup_protos[ind].port;
     }
   /* Some delimiter troubles...  */
   if (url[i] == '/' && url[i - 1] != ':')
@@ -688,11 +688,11 @@ str_url (const struct urlinfo *u, int hide)
     user = CLEANDUP (u->user);
   if (u->passwd)
     {
-      int i;
+      int j;
       passwd = CLEANDUP (u->passwd);
       if (hide)
-       for (i = 0; passwd[i]; i++)
-         passwd[i] = 'x';
+       for (j = 0; passwd[j]; j++)
+         passwd[j] = 'x';
     }
   if (u->proto == URLFTP && *dir == '/')
     {