public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add initializers to bound_minimal_symbol
@ 2022-02-08 20:42 Tom Tromey
  2022-02-11 13:34 ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2022-02-08 20:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds initializers to bound_minimal_symbol, allowing for the
removal of some calls to memset.
---
 gdb/ada-lang.c | 2 --
 gdb/findvar.c  | 3 +--
 gdb/minsyms.h  | 4 ++--
 gdb/value.c    | 7 +------
 4 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 0dd83cda8e5..d2f620cbb04 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4562,8 +4562,6 @@ ada_lookup_simple_minsym (const char *name)
 {
   struct bound_minimal_symbol result;
 
-  memset (&result, 0, sizeof (result));
-
   symbol_name_match_type match_type = name_match_type_from_name (name);
   lookup_name_info lookup_name (name, match_type);
 
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 1d22e645305..6660b006795 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -404,7 +404,7 @@ symbol_read_needs_frame (struct symbol *sym)
 struct minsym_lookup_data
 {
   /* The name of the minimal symbol we are searching for.  */
-  const char *name;
+  const char *name = nullptr;
 
   /* The field where the callback should store the minimal symbol
      if found.  It should be initialized to NULL before the search
@@ -751,7 +751,6 @@ language_defn::read_var_value (struct symbol *var,
 	struct minimal_symbol *msym;
 	struct obj_section *obj_section;
 
-	memset (&lookup_data, 0, sizeof (lookup_data));
 	lookup_data.name = var->linkage_name ();
 
 	gdbarch_iterate_over_objfiles_in_search_order
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index 5970cb3bb99..ed31d32483a 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -31,12 +31,12 @@ struct bound_minimal_symbol
   /* The minimal symbol that was found, or NULL if no minimal symbol
      was found.  */
 
-  struct minimal_symbol *minsym;
+  struct minimal_symbol *minsym = nullptr;
 
   /* If MINSYM is not NULL, then this is the objfile in which the
      symbol is defined.  */
 
-  struct objfile *objfile;
+  struct objfile *objfile = nullptr;
 
   /* Return the obj_section from OBJFILE for MINSYM.  */
 
diff --git a/gdb/value.c b/gdb/value.c
index 7bd9891b3e9..76099966f13 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3171,13 +3171,8 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
   struct bound_minimal_symbol msym;
 
   sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0).symbol;
-  if (sym != NULL)
+  if (sym == nullptr)
     {
-      memset (&msym, 0, sizeof (msym));
-    }
-  else
-    {
-      gdb_assert (sym == NULL);
       msym = lookup_bound_minimal_symbol (physname);
       if (msym.minsym == NULL)
 	return NULL;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-02-16 20:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 20:42 [PATCH] Add initializers to bound_minimal_symbol Tom Tromey
2022-02-11 13:34 ` Simon Marchi
2022-02-14 15:53   ` Simon Marchi
2022-02-15 15:41     ` Tom Tromey
2022-02-16 14:31       ` Enze Li
2022-02-16 15:29         ` Simon Marchi
2022-02-16 20:47           ` Tom Tromey

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).