SCP: Minor Coverity cleanup

This commit is contained in:
Mark Pizzolato 2022-01-02 09:47:33 -08:00
parent 0c7bf366ae
commit ff4c7b154e

38
scp.c
View file

@ -2908,23 +2908,25 @@ if (SCPE_BARE_STATUS(stat) == SCPE_OPENERR)
stat = docmdp->action (-1, "simh.ini"); /* simh.ini proc cmd file */ stat = docmdp->action (-1, "simh.ini"); /* simh.ini proc cmd file */
if (*cbuf) /* cmd file arg? */ if (*cbuf) /* cmd file arg? */
stat = docmdp->action (0, cbuf); /* proc cmd file */ stat = docmdp->action (0, cbuf); /* proc cmd file */
else if (*argv[0]) { /* sim name arg? */ else {
char *np; /* "path.ini" */ if (*argv[0]) { /* sim name arg? */
nbuf[0] = '"'; /* starting " */ char *np; /* "path.ini" */
strlcpy (nbuf + 1, argv[0], PATH_MAX + 2); /* copy sim name */ nbuf[0] = '"'; /* starting " */
if ((np = (char *)match_ext (nbuf, "EXE"))) /* remove .exe */ strlcpy (nbuf + 1, argv[0], PATH_MAX + 2); /* copy sim name */
*np = 0; if ((np = (char *)match_ext (nbuf, "EXE"))) /* remove .exe */
strlcat (nbuf, ".ini\"", sizeof (nbuf)); /* add .ini" */ *np = 0;
stat = docmdp->action (-1, nbuf) & ~SCPE_NOMESSAGE; /* proc default cmd file */ strlcat (nbuf, ".ini\"", sizeof (nbuf)); /* add .ini" */
if (stat == SCPE_OPENERR) { /* didn't exist/can't open? */ stat = docmdp->action (-1, nbuf) & ~SCPE_NOMESSAGE; /* proc default cmd file */
np = strrchr (nbuf, '/'); /* stript path and try again in cwd */ if (stat == SCPE_OPENERR) { /* didn't exist/can't open? */
if (np == NULL) np = strrchr (nbuf, '/'); /* stript path and try again in cwd */
np = strrchr (nbuf, '\\'); /* windows path separator */ if (np == NULL)
if (np == NULL) np = strrchr (nbuf, '\\'); /* windows path separator */
np = strrchr (nbuf, ']'); /* VMS path separator */ if (np == NULL)
if (np != NULL) { np = strrchr (nbuf, ']'); /* VMS path separator */
*np = '"'; if (np != NULL) {
stat = docmdp->action (-1, np) & ~SCPE_NOMESSAGE;/* proc default cmd file */ *np = '"';
stat = docmdp->action (-1, np) & ~SCPE_NOMESSAGE;/* proc default cmd file */
}
} }
} }
} }
@ -3182,7 +3184,7 @@ if ((strlen (buf) >= max_width) &&
size_t front_gap_size = front_gap - buf + 1; size_t front_gap_size = front_gap - buf + 1;
line_pos = 0; line_pos = 0;
end = buf + (buf ? strlen (buf) : 0); end = buf + strlen (buf);
while (1) { while (1) {
chunk_size = (end - buf); chunk_size = (end - buf);
if (line_pos + chunk_size >= max_width) if (line_pos + chunk_size >= max_width)