[binutils-gdb] PR26279 Work around maybe-uninitialized warning in s390-mkopc.c

Andreas Arnez arnez@sourceware.org
Wed Jul 29 17:47:30 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9811697376b3f1950419ab13b19e2995703b839b

commit 9811697376b3f1950419ab13b19e2995703b839b
Author: Andreas Arnez <arnez@linux.ibm.com>
Date:   Wed Jul 29 19:46:44 2020 +0200

    PR26279 Work around maybe-uninitialized warning in s390-mkopc.c
    
    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.

Diff:
---
 opcodes/ChangeLog    | 6 ++++++
 opcodes/s390-mkopc.c | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 522d81bd66f..4f56e1385bc 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -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.
diff --git a/opcodes/s390-mkopc.c b/opcodes/s390-mkopc.c
index c593fb60792..b6c49e6d1e2 100644
--- a/opcodes/s390-mkopc.c
+++ b/opcodes/s390-mkopc.c
@@ -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++)


More information about the Binutils-cvs mailing list