]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 60798] Silence bogus GCC10 and GCC11 warnings
authorJouke Witteveen <j.witteveen@gmail.com>
Sun, 19 Dec 2021 21:09:07 +0000 (16:09 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 19 Dec 2021 21:55:50 +0000 (16:55 -0500)
* 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.

src/main.c
src/read.c
src/variable.c

index 7b0a1f60a795d17d1fe0fef178b05b0f967d7127..2d98a64b9e71efb4e5fbcc6697ea0bd2a2e30506 100644 (file)
@@ -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);
     }
index 77bbdb5e8e1ac448cdaeecac7fd470b50397c368..ae1ddabc1725e18b6237d8a48bedb59651939c4c 100644 (file)
@@ -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);
index 9f66c6492a1592dba6b98c9ecce71c5ac9115a76..e1632e379ab68ad8f8d633e648b7b10fb8c2dd65 100644 (file)
@@ -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__