[binutils-gdb] gdb/xcoffread: replace 2 switches with if

Simon Marchi simark@sourceware.org
Fri Jan 9 05:40:31 GMT 2026


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

commit 3048609bec6146681354c4ffbfa6df84888d60cd
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Thu Jan 8 14:33:25 2026 -0500

    gdb/xcoffread: replace 2 switches with if
    
    Replace these 2 switches that have only one case with a single if
    statement.  It is highly unlikely that we'll ever need to check for
    other values.
    
    Change-Id: I6a48d4f27ba4d1d128aaa39d5f3d693a11e99fc9
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/xcoffread.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index a3cf8174078..b7b5aefec05 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -187,24 +187,18 @@ scan_xcoff_symtab (struct objfile *objfile)
 	    else
 	      csect_aux = main_aux[0];
 
-	    switch (csect_aux.x_csect.x_smtyp & 0x7)
+	    if ((csect_aux.x_csect.x_smtyp & 0x7) == XTY_SD
+		&& csect_aux.x_csect.x_smclas == XMC_TC0)
 	      {
-	      case XTY_SD:
-		switch (csect_aux.x_csect.x_smclas)
-		  {
-		  case XMC_TC0:
-		    if (toc_offset)
-		      warning (_("More than one XMC_TC0 symbol found."));
-		    toc_offset = symbol.n_value;
-
-		    /* Make TOC offset relative to start address of
-		       section.  */
-		    asection *bfd_sect
-		      = xcoff_secnum_to_section (symbol.n_scnum, objfile);
-		    if (bfd_sect)
-		      toc_offset -= bfd_section_vma (bfd_sect);
-		    break;
-		  }
+		if (toc_offset)
+		  warning (_("More than one XMC_TC0 symbol found."));
+		toc_offset = symbol.n_value;
+
+		/* Make TOC offset relative to start address of section.  */
+		asection *bfd_sect
+		  = xcoff_secnum_to_section (symbol.n_scnum, objfile);
+		if (bfd_sect)
+		  toc_offset -= bfd_section_vma (bfd_sect);
 		break;
 	      }
 	  }


More information about the Gdb-cvs mailing list