public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] gdb: change bcache::insert `added` parameter to bool
@ 2020-09-01 16:56 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2020-09-01 16:56 UTC (permalink / raw)
  To: gdb-patches

It is currently an int, but it is used as a bool.

gdb/ChangeLog:

	* bcache.h (struct bcache) <insert>: Change type of `added` to
	pointer to bool.
	* bcache.c (bcache::insert): Likewise.
	* gdbtypes.c (check_types_worklist): Adjust.
	* psymtab.c (add_psymbol_to_bcache): Adjust.

Change-Id: I06b1041636c656782a89cb6106c9ae2593f61616
---
 gdb/ChangeLog  |  8 ++++++++
 gdb/bcache.c   | 10 +++++-----
 gdb/bcache.h   |  4 ++--
 gdb/gdbtypes.c |  2 +-
 gdb/psymtab.c  | 11 ++++-------
 5 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4840de8591a4..ab003afa3e44 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2020-09-01  Simon Marchi  <simon.marchi@polymtl.ca>
+
+	* bcache.h (struct bcache) <insert>: Change type of `added` to
+	pointer to bool.
+	* bcache.c (bcache::insert): Likewise.
+	* gdbtypes.c (check_types_worklist): Adjust.
+	* psymtab.c (add_psymbol_to_bcache): Adjust.
+
 2020-08-31  Kevin Buettner  <kevinb@redhat.com>
 
 	* corelow.c (unordered_set): Include.
diff --git a/gdb/bcache.c b/gdb/bcache.c
index 49d9d3f486ba..9a8fb87bbe0f 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -140,15 +140,15 @@ bcache::expand_hash_table ()
    returning an old entry.  */
 
 const void *
-bcache::insert (const void *addr, int length, int *added)
+bcache::insert (const void *addr, int length, bool *added)
 {
   unsigned long full_hash;
   unsigned short half_hash;
   int hash_index;
   struct bstring *s;
 
-  if (added)
-    *added = 0;
+  if (added != nullptr)
+    *added = false;
 
   /* Lazily initialize the obstack.  This can save quite a bit of
      memory in some cases.  */
@@ -203,8 +203,8 @@ bcache::insert (const void *addr, int length, int *added)
     m_unique_size += length;
     m_structure_size += BSTRING_SIZE (length);
 
-    if (added)
-      *added = 1;
+    if (added != nullptr)
+      *added = true;
 
     return &newobj->d.data;
   }
diff --git a/gdb/bcache.h b/gdb/bcache.h
index 929375642046..d8b18dcc441b 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -161,12 +161,12 @@ struct bcache
   /* Find a copy of the LENGTH bytes at ADDR in BCACHE.  If BCACHE has
      never seen those bytes before, add a copy of them to BCACHE.  In
      either case, return a pointer to BCACHE's copy of that string.
-     Since the cached value is ment to be read-only, return a const
+     Since the cached value is meant to be read-only, return a const
      buffer.  If ADDED is not NULL, set *ADDED to true if the bytes
      were newly added to the cache, or to false if the bytes were
      found in the cache.  */
 
-  const void *insert (const void *addr, int length, int *added = nullptr);
+  const void *insert (const void *addr, int length, bool *added = nullptr);
 
   /* Print statistics on this bcache's memory usage and efficacity at
      eliminating duplication.  TYPE should be a string describing the
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index c1eb03d89844..ab44ec3bc00a 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4088,7 +4088,7 @@ check_types_worklist (std::vector<type_equality_entry> *worklist,
 {
   while (!worklist->empty ())
     {
-      int added;
+      bool added;
 
       struct type_equality_entry entry = std::move (worklist->back ());
       worklist->pop_back ();
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 47e31aab61e0..59db469e5597 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1590,9 +1590,8 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
    different domain (or address) is possible and correct.  */
 
 static struct partial_symbol *
-add_psymbol_to_bcache (const partial_symbol &psymbol,
-		       struct objfile *objfile,
-		       int *added)
+add_psymbol_to_bcache (const partial_symbol &psymbol, struct objfile *objfile,
+		       bool *added)
 {
   /* Stash the partial symbol away in the cache.  */
   return ((struct partial_symbol *)
@@ -1618,12 +1617,10 @@ add_psymbol_to_list (const partial_symbol &psymbol,
 		     psymbol_placement where,
 		     struct objfile *objfile)
 {
-  struct partial_symbol *psym;
-
-  int added;
+  bool added;
 
   /* Stash the partial symbol away in the cache.  */
-  psym = add_psymbol_to_bcache (psymbol, objfile, &added);
+  partial_symbol *psym = add_psymbol_to_bcache (psymbol, objfile, &added);
 
   /* Do not duplicate global partial symbols.  */
   if (where == psymbol_placement::GLOBAL && !added)
-- 
2.28.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-01 16:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 16:56 [pushed] gdb: change bcache::insert `added` parameter to bool Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).