[svn] Apply lint-expired fixes from <sxsn1du7ufa.fsf@florida.arsdigita.de>.

This commit is contained in:
hniksic 2000-12-17 10:52:52 -08:00
parent f6a41b5669
commit 5099ec0306
6 changed files with 68 additions and 52 deletions

View 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> 2000-12-17 Csaba Raduly <csaba.raduly@sophos.com>
* sysdep.h: Test for __EMX__ rather than for EMXOS2 for OS/2 * sysdep.h: Test for __EMX__ rather than for EMXOS2 for OS/2

View File

@ -1851,7 +1851,7 @@ basic_authentication_encode (const char *user, const char *passwd,
sprintf (t1, "%s:%s", user, passwd); sprintf (t1, "%s:%s", user, passwd);
t2 = (char *)alloca (1 + len2); t2 = (char *)alloca (1 + len2);
base64_encode (t1, t2, len1); 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); sprintf (res, "%s: Basic %s\r\n", header, t2);
return res; return res;

View File

@ -493,28 +493,21 @@ static int myatoi PARAMS ((const char *s));
static int static int
cmd_address (const char *com, const char *val, void *closure) cmd_address (const char *com, const char *val, void *closure)
{ {
struct sockaddr_in *sin; struct sockaddr_in sin;
sin = (struct sockaddr_in *) malloc(sizeof *sin); if (!store_hostaddress ((unsigned char *)&sin.sin_addr, val))
if (sin == NULL)
{ {
fprintf (stderr, _("%s: Out of memory.\n"), exec_name); fprintf (stderr, _("%s: %s: Cannot convert `%s' to an IP address.\n"),
return 0; exec_name, com, val);
return 0;
} }
if (!store_hostaddress ((unsigned char *)&sin->sin_addr, val)) sin.sin_family = AF_INET;
{ sin.sin_port = 0;
fprintf (stderr, _("%s: %s: Cannot convert `%s' to an IP address.\n"),
exec_name, com, val);
return 0;
}
sin->sin_family = AF_INET; memcpy (closure, &sin, sizeof (sin));
sin->sin_port = 0;
* (struct sockaddr_in **) closure = sin; return 1;
return 1;
} }
/* Store the boolean value from VAL to CLOSURE. COM is ignored, /* Store the boolean value from VAL to CLOSURE. COM is ignored,

View File

@ -807,7 +807,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
_("Download quota (%s bytes) EXCEEDED!\n"), _("Download quota (%s bytes) EXCEEDED!\n"),
legible (opt.quota)); legible (opt.quota));
} }
if (opt.convert_links & !opt.delete_after) if (opt.convert_links && !opt.delete_after)
{ {
convert_all_links (); convert_all_links ();
} }

View File

@ -703,7 +703,7 @@ parse_robots (const char *robots_filename)
char **entries; char **entries;
char *line, *cmd, *str, *p; char *line, *cmd, *str, *p;
char *base_version, *version; char *base_version, *version;
int len, num, i; int num, i;
int wget_matched; /* is the part meant for Wget? */ int wget_matched; /* is the part meant for Wget? */
entries = NULL; entries = NULL;
@ -714,19 +714,19 @@ parse_robots (const char *robots_filename)
return NULL; return NULL;
/* Kill version number. */ /* Kill version number. */
if (opt.useragent) if (opt.useragent)
{ {
STRDUP_ALLOCA (base_version, opt.useragent); STRDUP_ALLOCA (base_version, opt.useragent);
STRDUP_ALLOCA (version, opt.useragent); STRDUP_ALLOCA (version, opt.useragent);
} }
else else
{ {
int len = 10 + strlen (version_string); int len = 10 + strlen (version_string);
base_version = (char *)alloca (len); base_version = (char *)alloca (len);
sprintf (base_version, "Wget/%s", version_string); sprintf (base_version, "Wget/%s", version_string);
version = (char *)alloca (len); version = (char *)alloca (len);
sprintf (version, "Wget/%s", version_string); sprintf (version, "Wget/%s", version_string);
} }
for (p = version; *p; p++) for (p = version; *p; p++)
*p = TOLOWER (*p); *p = TOLOWER (*p);
for (p = base_version; *p && *p != '/'; p++) for (p = base_version; *p && *p != '/'; p++)
@ -755,7 +755,7 @@ parse_robots (const char *robots_filename)
wget_matched = 1; wget_matched = 1;
while ((line = read_whole_line (fp))) while ((line = read_whole_line (fp)))
{ {
len = strlen (line); int len = strlen (line);
/* Destroy <CR><LF> if present. */ /* Destroy <CR><LF> if present. */
if (len && line[len - 1] == '\n') if (len && line[len - 1] == '\n')
line[--len] = '\0'; 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 /* May the URL url be loaded according to disallowing rules stored in
forbidden? */ forbidden? */
static int static int
robots_match (struct urlinfo *u, char **forbidden) robots_match (struct urlinfo *u, char **fb)
{ {
int l; int l;
if (!forbidden) if (!fb)
return 1; return 1;
DEBUGP (("Matching %s against: ", u->path)); DEBUGP (("Matching %s against: ", u->path));
for (; *forbidden; forbidden++) for (; *fb; fb++)
{ {
DEBUGP (("%s ", *forbidden)); DEBUGP (("%s ", *fb));
l = strlen (*forbidden); l = strlen (*fb);
/* If dir is forbidden, we may not load the file. */ /* If dir is fb, we may not load the file. */
if (strncmp (u->path, *forbidden, l) == 0) if (strncmp (u->path, *fb, l) == 0)
{ {
DEBUGP (("matched.\n")); DEBUGP (("matched.\n"));
return 0; /* Matches, i.e. does not load... */ return 0; /* Matches, i.e. does not load... */

View File

@ -475,13 +475,13 @@ parseurl (const char *url, struct urlinfo *u, int strict)
u->proto = type = URLHTTP; u->proto = type = URLHTTP;
if (!u->port) if (!u->port)
{ {
int i; int ind;
for (i = 0; i < ARRAY_SIZE (sup_protos); i++) for (ind = 0; ind < ARRAY_SIZE (sup_protos); ind++)
if (sup_protos[i].ind == type) if (sup_protos[ind].ind == type)
break; break;
if (i == ARRAY_SIZE (sup_protos)) if (ind == ARRAY_SIZE (sup_protos))
return URLUNKNOWN; return URLUNKNOWN;
u->port = sup_protos[i].port; u->port = sup_protos[ind].port;
} }
/* Some delimiter troubles... */ /* Some delimiter troubles... */
if (url[i] == '/' && url[i - 1] != ':') if (url[i] == '/' && url[i - 1] != ':')
@ -688,11 +688,11 @@ str_url (const struct urlinfo *u, int hide)
user = CLEANDUP (u->user); user = CLEANDUP (u->user);
if (u->passwd) if (u->passwd)
{ {
int i; int j;
passwd = CLEANDUP (u->passwd); passwd = CLEANDUP (u->passwd);
if (hide) if (hide)
for (i = 0; passwd[i]; i++) for (j = 0; passwd[j]; j++)
passwd[i] = 'x'; passwd[j] = 'x';
} }
if (u->proto == URLFTP && *dir == '/') if (u->proto == URLFTP && *dir == '/')
{ {