This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ob] Fix uninitialize "index"; Was: PATCH: Fix PR 1171


Just FYI,

I checked in the attached cleanup. It stops an uninitialized "index" GCC warning (by deleting the variable :-). While there I cleaned up the STREQs and adds some missing periods (both were there before the last change).

Andrew

Ref: Compiler Warnings
http://sources.redhat.com/gdb/current/onlinedocs/gdbint_13.html#SEC118
2003-06-07  Andrew Cagney  <cagney@redhat.com>

	* elfread.c (elf_symtab_read): Replace "special_local_sym_p" and
	"index" with "special_local_sect".  Use strcmp instead of STREQ.
	Append period to coments.

Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.32
diff -u -r1.32 elfread.c
--- elfread.c	6 Jun 2003 23:32:58 -0000	1.32
+++ elfread.c	7 Jun 2003 15:46:07 -0000
@@ -177,7 +177,6 @@
   asymbol **symbol_table;
   long number_of_symbols;
   long i;
-  int index;
   struct cleanup *back_to;
   CORE_ADDR symaddr;
   CORE_ADDR offset;
@@ -372,28 +371,21 @@
 		    }
 		  else if (sym->flags & BSF_LOCAL)
 		    {
-		      int special_local_sym_p = 0;
-		      /* Named Local variable in a Data section.  Check its
-		         name for stabs-in-elf.  The STREQ macro checks the
-		         first character inline, so we only actually do a
-		         strcmp function call on names that start with 'B'
-		         or 'D' */
-		      if (STREQ ("Bbss.bss", sym->name))
-			{
-			  index = SECT_OFF_BSS (objfile);
-			  special_local_sym_p = 1;
-			}
-		      else if (STREQ ("Ddata.data", sym->name))
-			{
-			  index = SECT_OFF_DATA (objfile);
-			  special_local_sym_p = 1;
-			}
-		      else if (STREQ ("Drodata.rodata", sym->name))
-			{
-			  index = SECT_OFF_RODATA (objfile);
-			  special_local_sym_p = 1;
-			}
-		      if (special_local_sym_p)
+		      /* Named Local variable in a Data section.
+		         Check its name for stabs-in-elf.  The STREQ
+		         macro checks the first character inline, so
+		         we only actually do a strcmp function call on
+		         names that start with 'B' or 'D'.  */
+		      int special_local_sect;
+		      if (strcmp ("Bbss.bss", sym->name) == 0)
+			special_local_sect = SECT_OFF_BSS (objfile);
+		      else if (strcmp ("Ddata.data", sym->name) == 0)
+			special_local_sect = SECT_OFF_DATA (objfile);
+		      else if (strcmp ("Drodata.rodata", sym->name) == 0)
+			special_local_sect = SECT_OFF_RODATA (objfile);
+		      else
+			special_local_sect = -1;
+		      if (special_local_sect >= 0)
 			{
 			  /* Found a special local symbol.  Allocate a
 			     sectinfo, if needed, and fill it in.  */
@@ -425,36 +417,23 @@
 				    (char *) filesym->name;
 				}
 			    }
-			  if (index != -1)
-			    { 
-			      if (sectinfo->sections[index] != 0)
-				{
-				  complaint (&symfile_complaints,
-					     "duplicated elf/stab section information for %s",
-					     sectinfo->filename);
-				}
-			    }
-			  else
-			    internal_error (__FILE__, __LINE__,
-					    "Section index uninitialized.");
-			  /* Bfd symbols are section relative. */
+			  if (sectinfo->sections[special_local_sect] != 0)
+			    complaint (&symfile_complaints,
+				       "duplicated elf/stab section information for %s",
+				       sectinfo->filename);
+			  /* BFD symbols are section relative.  */
 			  symaddr = sym->value + sym->section->vma;
-			  /* Relocate non-absolute symbols by the section offset. */
+			  /* Relocate non-absolute symbols by the
+                             section offset.  */
 			  if (sym->section != &bfd_abs_section)
-			    {
-			      symaddr += offset;
-			    }
-			  if (index != -1)
-			    sectinfo->sections[index] = symaddr;
-			  else
-			    internal_error (__FILE__, __LINE__,
-					    "Section index uninitialized.");
+			    symaddr += offset;
+			  sectinfo->sections[special_local_sect] = symaddr;
 			  /* The special local symbols don't go in the
-			     minimal symbol table, so ignore this one. */
+			     minimal symbol table, so ignore this one.  */
 			  continue;
 			}
 		      /* Not a special stabs-in-elf symbol, do regular
-		         symbol processing. */
+		         symbol processing.  */
 		      if (sym->section->flags & SEC_LOAD)
 			{
 			  ms_type = mst_file_data;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]