Fix for Coverity CID#2: false bug, but still a problem.

Analysis:
internal_errorf(int, fmt, ...) was only a __dead function if the int argument
was non-0, which the Prevent probably was unable to follow. Change all uses of
internal_errorf(0, fmt, ...) to internal_warningf(fmt, ...); change the pro-
totype of internal_errorf() to internal_errorf(fmt, ...) and all remaining
uses remove the non-0 int argument; add __dead to internal_errorf() proto;
flesh out guts of internal_errorf() and internal_warningf() into a new local
function for optimisation purposes.

Some whitespace cleanup and dead code removal (return after internal_errorf(1))
This commit is contained in:
tg
2007-05-13 17:51:24 +00:00
parent d2d035355f
commit 0989f7da67
13 changed files with 91 additions and 74 deletions

8
eval.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.25 2007/03/14 02:41:08 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.26 2007/05/13 17:51:21 tg Exp $");
#ifdef MKSH_SMALL
#define MKSH_NOPWNAM
@ -63,7 +63,7 @@ substitute(const char *cp, int f)
s->start = s->str = cp;
source = s;
if (yylex(ONEWORD) != LWORD)
internal_errorf(1, "substitute");
internal_errorf("substitute");
source = sold;
afree(s, ATEMP);
return evalstr(yylval.cp, f);
@ -168,7 +168,7 @@ expand(const char *cp, /* input word */
size_t len;
if (cp == NULL)
internal_errorf(1, "expand(NULL)");
internal_errorf("expand(NULL)");
/* for alias, readonly, set, typeset commands */
if ((f & DOVACHECK) && is_wdvarassign(cp)) {
f &= ~(DOVACHECK|DOBLANK|DOGLOB|DOTILDE);
@ -580,7 +580,7 @@ expand(const char *cp, /* input word */
if ((p = str_nsave(null, 0, ATEMP))
== NULL)
internal_errorf(1, "unable "
internal_errorf("unable "
"to allocate memory");
XPput(*wp, p);
}