[2/7] Remove unnecessary null check in lookup_minimal_symbol_by_pc_section

Message ID 20240217-dwarf-race-relocate-v1-2-d3d2d908c1e8@tromey.com
State New
Headers
Series Fix race in DWARF reader |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey Feb. 18, 2024, 1:10 a.m. UTC
  lookup_minimal_symbol_by_pc_section asserts that section != NULL early
in the function, rendering a later check (and comment) unnecessary.
---
 gdb/minsyms.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
  

Patch

diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index ffded3781c4..f63d0f4af61 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -876,13 +876,11 @@  lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
 		      continue;
 		    }
 
-		  /* If SECTION was specified, skip any symbol from
-		     wrong section.  */
-		  if (section
-		      /* Some types of debug info, such as COFF,
+		  /* Skip any symbol from wrong section.  */
+		  if (/* Some types of debug info, such as COFF,
 			 don't fill the bfd_section member, so don't
 			 throw away symbols on those platforms.  */
-		      && msymbol[hi].obj_section (objfile) != nullptr
+		      msymbol[hi].obj_section (objfile) != nullptr
 		      && (!matching_obj_sections
 			  (msymbol[hi].obj_section (objfile),
 			   section)))