[7/8] gdb: remove unnecessary nullptr check in free_objfile observers

Message ID 20231004022305.298534-8-simon.marchi@polymtl.ca
State New
Headers
Series Split new_objfile observable |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Patch failed to apply

Commit Message

Simon Marchi Oct. 4, 2023, 2:20 a.m. UTC
  From: Simon Marchi <simon.marchi@efficios.com>

The free_objfile observable is never called with a nullptr objfile.

Change-Id: I1e990edeb45bc38009ccb129c623911097ab65fe
---
 gdb/breakpoint.c | 3 ---
 gdb/printcmd.c   | 7 +------
 gdb/symfile.c    | 3 +--
 3 files changed, 2 insertions(+), 11 deletions(-)
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f378edf865ea..db7d2e6a8e53 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8065,9 +8065,6 @@  disable_breakpoints_in_unloaded_shlib (program_space *pspace, so_list *solib)
 static void
 disable_breakpoints_in_freed_objfile (struct objfile *objfile)
 {
-  if (objfile == NULL)
-    return;
-
   /* OBJF_SHARED|OBJF_USERLOADED objfiles are dynamic modules manually
      managed by the user with add-symbol-file/remove-symbol-file.
      Similarly to how breakpoints in shared libraries are handled in
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 7e5f062caec3..d29a57f89b55 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2355,12 +2355,7 @@  disable_display_command (const char *args, int from_tty)
 static void
 clear_dangling_display_expressions (struct objfile *objfile)
 {
-  struct program_space *pspace;
-
-  /* With no symbol file we cannot have a block or expression from it.  */
-  if (objfile == NULL)
-    return;
-  pspace = objfile->pspace;
+  program_space *pspace = objfile->pspace;
   if (objfile->separate_debug_objfile_backlink)
     {
       objfile = objfile->separate_debug_objfile_backlink;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d8b67d094ab2..c2779681cd21 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3736,8 +3736,7 @@  static void
 symfile_free_objfile (struct objfile *objfile)
 {
   /* Remove the target sections owned by this objfile.  */
-  if (objfile != NULL)
-    current_program_space->remove_target_sections ((void *) objfile);
+  current_program_space->remove_target_sections (objfile);
 }
 
 /* Wrapper around the quick_symbol_functions expand_symtabs_matching "method".