From: Jouke Witteveen Date: Sun, 19 Dec 2021 21:09:07 +0000 (-0500) Subject: [SV 60798] Silence bogus GCC10 and GCC11 warnings X-Git-Tag: 4.3.90~124 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f440c3ebe2601b48893cd510335818a8bcfdf342;p=thirdparty%2Fmake.git [SV 60798] Silence bogus GCC10 and GCC11 warnings * src/main.c (main): Use a separate variable to track final character. * src/read.c (eval): Track the semicolon position not one beyond it. * src/variable.c (do_variable_definition): Include a default switch case to ease the work of the exhaustiveness prover. --- diff --git a/src/main.c b/src/main.c index 7b0a1f60..2d98a64b 100644 --- a/src/main.c +++ b/src/main.c @@ -1923,7 +1923,7 @@ main (int argc, char **argv, char **envp) if (eval_strings) { - char *p, *value; + char *p, *endp, *value; unsigned int i; size_t len = (CSTRLEN ("--eval=") + 1) * eval_strings->idx; @@ -1935,15 +1935,16 @@ main (int argc, char **argv, char **envp) free (p); } - p = value = alloca (len); + p = endp = value = alloca (len); for (i = 0; i < eval_strings->idx; ++i) { strcpy (p, "--eval="); p += CSTRLEN ("--eval="); p = quote_for_env (p, eval_strings->list[i]); - *(p++) = ' '; + endp = p++; + *endp = ' '; } - p[-1] = '\0'; + *endp = '\0'; define_variable_cname ("-*-eval-flags-*-", value, o_automatic, 0); } diff --git a/src/read.c b/src/read.c index 77bbdb5e..ae1ddabc 100644 --- a/src/read.c +++ b/src/read.c @@ -1000,7 +1000,7 @@ eval (struct ebuffer *ebuf, int set_default) { enum make_word_type wtype; - char *cmdleft, *semip, *lb_next; + char *cmdleft, *semip = 0, *lb_next; size_t plen = 0; char *colonp; const char *end, *beg; /* Helpers for whitespace stripping. */ @@ -1020,9 +1020,11 @@ eval (struct ebuffer *ebuf, int set_default) cmdleft = 0; } else if (cmdleft != 0) - /* Found one. Cut the line short there before expanding it. */ - *(cmdleft++) = '\0'; - semip = cmdleft; + { + /* Found one. Cut the line short there before expanding it. */ + semip = cmdleft++; + *semip = '\0'; + } collapse_continuations (line); @@ -1193,7 +1195,7 @@ eval (struct ebuffer *ebuf, int set_default) if (semip) { size_t l = p2 - variable_buffer; - *(--semip) = ';'; + *semip = ';'; collapse_continuations (semip); variable_buffer_output (p2 + strlen (p2), semip, strlen (semip)+1); diff --git a/src/variable.c b/src/variable.c index 9f66c649..e1632e37 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1194,9 +1194,6 @@ do_variable_definition (const floc *flocp, const char *varname, switch (flavor) { - case f_bogus: - /* Should not be possible. */ - abort (); case f_simple: /* A simple variable definition "var := value". Expand the value. We have to allocate memory since otherwise it'll clobber the @@ -1317,8 +1314,12 @@ do_variable_definition (const floc *flocp, const char *varname, free (tp); } - break; } + break; + case f_bogus: + default: + /* Should not be possible. */ + abort (); } #ifdef __MSDOS__