]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR26279 Work around maybe-uninitialized warning in s390-mkopc.c
authorAndreas Arnez <arnez@linux.ibm.com>
Wed, 29 Jul 2020 17:46:44 +0000 (19:46 +0200)
committerAndreas Arnez <arnez@linux.ibm.com>
Wed, 29 Jul 2020 17:46:44 +0000 (19:46 +0200)
In s390-mkopc.c, the function insertExpandedMnemonic() searches for the
first occurrence of '*' or '$' in the given mnemonic, and, if a match is
found, chooses an extension table using a switch() on that character.  The
switch statement contains a default case that prints an error message and
does not set the extension table.  Although this case cannot occur, some
GCC versions obviously conclude that the extension table might have been
left uninitialized after the switch statement and consequently emit
maybe-uninitialized warnings for the variables 'ext_table' and
'ext_table_length'.

Circumvent the warning by handling the unreachable default case with
abort().

opcodes/
* s390-mkopc.c (insertExpandedMnemonic): Handle unreachable
default case with abort() instead of printing an error message and
continuing, to avoid a maybe-uninitialized warning.

opcodes/ChangeLog
opcodes/s390-mkopc.c

index 522d81bd66f6a7f3cc458e800611a5ee1fc3a139..4f56e1385bc9d103c7cc48fbab3594d98000b329 100644 (file)
@@ -1,3 +1,9 @@
+2020-07-29  Andreas Arnez  <arnez@linux.ibm.com>
+
+       * s390-mkopc.c (insertExpandedMnemonic): Handle unreachable
+       default case with abort() instead of printing an error message and
+       continuing, to avoid a maybe-uninitialized warning.
+
 2020-07-24  Nick Clifton  <nickc@redhat.com>
 
        * po/de.po: Updated German translation.
index c593fb60792594ad71f479d5cbb2fb6ead1e1a67..b6c49e6d1e24bb4dcfe57ad8880610dc1714d94b 100644 (file)
@@ -240,7 +240,8 @@ insertExpandedMnemonic (char *opcode, char *mnemonic, char *format,
       ext_table = s390_crb_extensions;
       ext_table_length = NUM_CRB_EXTENSIONS;
       break;
-    default: fprintf (stderr, "Unknown tag char: %c\n", *tag);
+    default:
+      abort ();                        /* Should be unreachable.  */
     }
 
   for (i = 0; i < ext_table_length; i++)