SCP: Static Analyzer cleanups suggested by Peter Schorn

This commit is contained in:
Mark Pizzolato 2013-12-27 07:08:17 -08:00
parent bf58edfaab
commit 2bb502ee64
2 changed files with 5 additions and 2 deletions

3
scp.c
View file

@ -3390,7 +3390,9 @@ if (dir) {
char FileName[PATH_MAX + 1], *MatchName; char FileName[PATH_MAX + 1], *MatchName;
char *c; char *c;
struct tm *local; struct tm *local;
#if defined (HAVE_GLOB)
int i; int i;
#endif
MatchName = 1 + strrchr (cptr, '/'); MatchName = 1 + strrchr (cptr, '/');
printf (" Directory of %s\n\n", DirName[0] ? DirName : "/"); printf (" Directory of %s\n\n", DirName[0] ? DirName : "/");
@ -7959,6 +7961,7 @@ t_stat scp_vhelpFromFile (FILE *st, struct sim_device *dptr,
#define XPANDQ 512 #define XPANDQ 512
p = (char *) realloc (help, ((size_t)size) + XPANDQ +1); p = (char *) realloc (help, ((size_t)size) + XPANDQ +1);
if (!p) { if (!p) {
free (help);
fclose (fp); fclose (fp);
return SCPE_MEM; return SCPE_MEM;
} }

View file

@ -334,7 +334,7 @@ else {
fixed[1] = NULL; fixed[1] = NULL;
ips = fixed; ips = fixed;
} }
for (ip=ips; *ip != NULL; ++ip) { for (ip=ips; (ip != NULL) && (*ip != NULL); ++ip) {
ai = (struct addrinfo *)calloc(1, sizeof(*ai)); ai = (struct addrinfo *)calloc(1, sizeof(*ai));
if (NULL == ai) { if (NULL == ai) {
s_freeaddrinfo(result); s_freeaddrinfo(result);
@ -556,7 +556,7 @@ if ((host != NULL) && (host_len != 0))
if ((port != NULL) && (port_len != 0)) if ((port != NULL) && (port_len != 0))
memset (port, 0, port_len); memset (port, 0, port_len);
if ((cptr == NULL) || (*cptr == 0)) { if ((cptr == NULL) || (*cptr == 0)) {
if (((default_host == NULL) || (*default_host == 0)) && ((default_port == NULL) || (*default_port == 0))) if (((default_host == NULL) || (*default_host == 0)) || ((default_port == NULL) || (*default_port == 0)))
return SCPE_ARG; return SCPE_ARG;
if ((strlen(default_host) >= host_len) || (strlen(default_port) >= port_len)) if ((strlen(default_host) >= host_len) || (strlen(default_port) >= port_len))
return SCPE_ARG; /* no room */ return SCPE_ARG; /* no room */