From 5099ec0306952b942f3bb25a1aab1ee8d7f01092 Mon Sep 17 00:00:00 2001 From: hniksic Date: Sun, 17 Dec 2000 10:52:52 -0800 Subject: [PATCH] [svn] Apply lint-expired fixes from . --- src/ChangeLog | 23 +++++++++++++++++++++++ src/http.c | 2 +- src/init.c | 33 +++++++++++++-------------------- src/main.c | 2 +- src/recur.c | 44 ++++++++++++++++++++++---------------------- src/url.c | 16 ++++++++-------- 6 files changed, 68 insertions(+), 52 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ef19d42a..1a0c447d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,26 @@ +2000-12-17 Hrvoje Niksic + + * 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 + + * 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 * sysdep.h: Test for __EMX__ rather than for EMXOS2 for OS/2 diff --git a/src/http.c b/src/http.c index 8f0e86d7..b9c8e585 100644 --- a/src/http.c +++ b/src/http.c @@ -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; diff --git a/src/init.c b/src/init.c index 64218de7..900f807d 100644 --- a/src/init.c +++ b/src/init.c @@ -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, diff --git a/src/main.c b/src/main.c index 7db0ba02..271d5096 100644 --- a/src/main.c +++ b/src/main.c @@ -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 (); } diff --git a/src/recur.c b/src/recur.c index 21bb40b0..e3b06425 100644 --- a/src/recur.c +++ b/src/recur.c @@ -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 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... */ diff --git a/src/url.c b/src/url.c index 0cbc3cd1..72711eaa 100644 --- 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 == '/') { -- 2.39.2