elfedit false "may be used uninitialised"
authorAlan Modra <amodra@gmail.com>
Sun, 8 Nov 2020 23:09:53 +0000 (09:39 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 9 Nov 2020 03:50:10 +0000 (14:20 +1030)
elfedit.c:904:15: error: 'osabi' may be used uninitialised in this function [-Werror=maybe-uninitialized]
  904 |       osabi = concat (osabi, "|", osabis[i].name, NULL);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* elfedit (usage): Avoid false positive "may be used uninitialised".
Don't leak memory.

binutils/ChangeLog
binutils/elfedit.c

index 2e24fafb7678115c37f514045709114025f2f617..49e1f0518045164d44daea75155c0c428f0ea324 100644 (file)
@@ -1,3 +1,8 @@
+2020-11-09  Alan Modra  <amodra@gmail.com>
+
+       * elfedit (usage): Avoid false positive "may be used uninitialised".
+       Don't leak memory.
+
 2020-11-09  Howard Chu  <hyc@symas.com>
 
        * ar.c (main): Use plugin_target rather than "target" when
index 5fffe845d86c0d209131401dcf452205aef7dfad..55474ffbbcebc3e101708857760a6d34a07622fb 100644 (file)
@@ -895,13 +895,10 @@ ATTRIBUTE_NORETURN static void
 usage (FILE *stream, int exit_status)
 {
   unsigned int i;
-  char *osabi;
+  char *osabi = concat (osabis[0].name, NULL);
 
-  for (i = 0; i < ARRAY_SIZE (osabis); i++)
-    if (i == 0)
-      osabi = concat (osabis[i].name, NULL);
-    else
-      osabi = concat (osabi, "|", osabis[i].name, NULL);
+  for (i = 1; i < ARRAY_SIZE (osabis); i++)
+    osabi = reconcat (osabi, "|", osabis[i].name, NULL);
 
   fprintf (stream, _("Usage: %s <option(s)> elffile(s)\n"),
           program_name);
This page took 0.025535 seconds and 4 git commands to generate.