[07/14] gdb: bool-ify a few functions in objfiles.{c,h}

Message ID 20240711195307.1544451-8-simon.marchi@polymtl.ca
State New
Headers
Series Some random program space cleanups |

Checks

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

Commit Message

Simon Marchi July 11, 2024, 7:52 p.m. UTC
  Change return types to bool, and make a few stylistic adjustments.

Change-Id: I784c3c33af0394a77c25064b06eb3e128e69222f
---
 gdb/objfiles.c | 77 +++++++++++++++++++++-----------------------------
 gdb/objfiles.h | 23 +++++++++++----
 2 files changed, 50 insertions(+), 50 deletions(-)
  

Patch

diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 0c10841ba123..e4ab73775a22 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -731,56 +731,49 @@  objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
   if (changed)
     breakpoint_re_set ();
 }
-
-/* Return non-zero if OBJFILE has full symbols.  */
 
-int
-objfile_has_full_symbols (struct objfile *objfile)
+/* See objfiles.h.  */
+
+bool
+objfile_has_full_symbols (objfile *objfile)
 {
-  return objfile->compunit_symtabs != NULL;
+  return objfile->compunit_symtabs != nullptr;
 }
 
-/* Return non-zero if OBJFILE has full or partial symbols, either directly
-   or through a separate debug file.  */
+/* See objfiles.h.  */
 
-int
-objfile_has_symbols (struct objfile *objfile)
+bool
+objfile_has_symbols (objfile *objfile)
 {
   for (::objfile *o : objfile->separate_debug_objfiles ())
     if (o->has_partial_symbols () || objfile_has_full_symbols (o))
-      return 1;
-  return 0;
-}
+      return true;
 
+  return false;
+}
 
-/* Many places in gdb want to test just to see if we have any partial
-   symbols available.  This function returns zero if none are currently
-   available, nonzero otherwise.  */
+/* See objfiles.h.  */
 
-int
-have_partial_symbols (void)
+bool
+have_partial_symbols ()
 {
   for (objfile *ofp : current_program_space->objfiles ())
-    {
-      if (ofp->has_partial_symbols ())
-	return 1;
-    }
-  return 0;
+    if (ofp->has_partial_symbols ())
+      return true;
+
+  return false;
 }
 
-/* Many places in gdb want to test just to see if we have any full
-   symbols available.  This function returns zero if none are currently
-   available, nonzero otherwise.  */
+/* See objfiles.h.  */
 
-int
-have_full_symbols (void)
+bool
+have_full_symbols ()
 {
   for (objfile *ofp : current_program_space->objfiles ())
-    {
-      if (objfile_has_full_symbols (ofp))
-	return 1;
-    }
-  return 0;
+    if (objfile_has_full_symbols (ofp))
+      return true;
+
+  return false;
 }
 
 
@@ -799,22 +792,16 @@  objfile_purge_solibs (program_space *pspace)
     }
 }
 
+/* See objfiles.h.  */
 
-/* Many places in gdb want to test just to see if we have any minimal
-   symbols available.  This function returns zero if none are currently
-   available, nonzero otherwise.  */
-
-int
-have_minimal_symbols (void)
+bool
+have_minimal_symbols ()
 {
   for (objfile *ofp : current_program_space->objfiles ())
-    {
-      if (ofp->per_bfd->minimal_symbol_count > 0)
-	{
-	  return 1;
-	}
-    }
-  return 0;
+    if (ofp->per_bfd->minimal_symbol_count > 0)
+      return true;
+
+  return false;
 }
 
 /* Qsort comparison function.  */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 7e56cae4c7dd..e81cfe68c2de 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -918,13 +918,23 @@  extern void free_objfile_separate_debug (struct objfile *);
 extern void objfile_relocate (struct objfile *, const section_offsets &);
 extern void objfile_rebase (struct objfile *, CORE_ADDR);
 
-extern int objfile_has_full_symbols (struct objfile *objfile);
+/* Return true if OBJFILE has full symbols.  */
 
-extern int objfile_has_symbols (struct objfile *objfile);
+extern bool objfile_has_full_symbols (objfile *objfile);
 
-extern int have_partial_symbols (void);
+/* Return true if OBJFILE has full or partial symbols, either directly
+   or through a separate debug file.  */
 
-extern int have_full_symbols (void);
+extern bool objfile_has_symbols (objfile *objfile);
+
+/* Return true if any objfile of the current program space has partial
+   symbols.  */
+
+extern bool have_partial_symbols ();
+
+/* Return true if any objfile of the current program space has full symbols.  */
+
+extern bool have_full_symbols ();
 
 extern void objfile_set_sym_fns (struct objfile *objfile,
 				 const struct sym_fns *sf);
@@ -951,7 +961,10 @@  extern void objfile_purge_solibs (program_space *pspace);
 /* Functions for dealing with the minimal symbol table, really a misc
    address<->symbol mapping for things we don't have debug symbols for.  */
 
-extern int have_minimal_symbols (void);
+/* Return true if any objfile of the current program space has minimal
+   symbols.  */
+
+extern bool have_minimal_symbols ();
 
 extern struct obj_section *find_pc_section (CORE_ADDR pc);