public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/6] [gdb/symtab] Do more zero-initialization of type::fields
Date: Wed, 30 Aug 2023 21:13:33 +0200	[thread overview]
Message-ID: <20230830191336.15885-3-tdevries@suse.de> (raw)
In-Reply-To: <20230830191336.15885-1-tdevries@suse.de>

Now that we've introduced type::{alloc_fields,copy_fields}, the places where
no zero-initialization of allocated fields is done are easy to spot:
...
$ find gdb* -type f | grep -v ChangeLog | xargs grep alloc_fields | grep false
gdb/coffread.c:  type->alloc_fields (nfields, false);
gdb/coffread.c:  type->alloc_fields (nsyms, false);
gdb/stabsread.c:	  ftype->alloc_fields (nsemi, false);
gdb/gdbtypes.c:  resolved_type->alloc_fields (nfields, false);
gdb/gdbtypes.c:  alloc_fields (nfields, false);
gdb/gdbtypes.c:  alloc_fields (nfields, false);
gdb/mdebugread.c:	t->alloc_fields (nfields, false);
gdb/mdebugread.c:		  ftype->alloc_fields (nparams, false);
...

All hits in gdbtypes.c are ok.  There are two hits in the two variants of
copy_fields, and there's already a comment for the third.

AFAICT, the other ones are not, so fix those by dropping the "false" argument.

Tested on x86_64-linux.
---
 gdb/coffread.c   | 4 ++--
 gdb/mdebugread.c | 4 ++--
 gdb/stabsread.c  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index e132dd1a1f7..e251f110ff8 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -2032,7 +2032,7 @@ coff_read_struct_type (int index, int length, int lastsym,
     }
   /* Now create the vector of fields, and record how big it is.  */
 
-  type->alloc_fields (nfields, false);
+  type->alloc_fields (nfields);
 
   /* Copy the saved-up fields into the field vector.  */
 
@@ -2110,7 +2110,7 @@ coff_read_enum_type (int index, int length, int lastsym,
   else /* Assume ints.  */
     type->set_length (gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT);
   type->set_code (TYPE_CODE_ENUM);
-  type->alloc_fields (nsyms, false);
+  type->alloc_fields (nsyms);
 
   /* Find the symbols for the values and put them into the type.
      The symbols can be found in the symlist that we put them on
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 688501e157a..ad9967b75fa 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1034,7 +1034,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
 	t->set_code (type_code);
 	t->set_length (sh->value);
-	t->alloc_fields (nfields, false);
+	t->alloc_fields (nfields);
 
 	if (type_code == TYPE_CODE_ENUM)
 	  {
@@ -1195,7 +1195,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
 	      if (nparams > 0)
 		{
-		  ftype->alloc_fields (nparams, false);
+		  ftype->alloc_fields (nparams);
 
 		  iparams = 0;
 		  for (struct symbol *sym : block_iterator_range (cblock))
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index c29d1c0d397..ad9258a9f20 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -982,7 +982,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	    }
 
 	  /* Allocate parameter information fields and fill them in.  */
-	  ftype->alloc_fields (nsemi, false);
+	  ftype->alloc_fields (nsemi);
 	  while (*p++ == ';')
 	    {
 	      struct type *ptype;
-- 
2.35.3


  parent reply	other threads:[~2023-08-30 19:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30 19:13 [PATCH 1/6] [gdb/symtab] Fix uninitialized memory in buildsym_compunit::finish_block_internal Tom de Vries
2023-08-30 19:13 ` [PATCH 2/6] [gdb/symtab] Factor out type::{alloc_fields,copy_fields} Tom de Vries
2023-08-30 20:17   ` Tom Tromey
2023-08-31  7:57     ` Tom de Vries
2023-08-30 19:13 ` Tom de Vries [this message]
2023-08-30 20:19   ` [PATCH 3/6] [gdb/symtab] Do more zero-initialization of type::fields Tom Tromey
2023-08-30 19:13 ` [PATCH 4/6] [gdb/symtab] Replace TYPE_ALLOC + memset with TYPE_ZALLOC Tom de Vries
2023-08-30 20:20   ` Tom Tromey
2023-08-30 19:13 ` [PATCH 5/6] [gdb/symtab] Replace TYPE_ALLOC + B_CLRALL " Tom de Vries
2023-08-30 20:21   ` Tom Tromey
2023-08-31  8:00     ` Tom de Vries
2023-08-30 19:13 ` [PATCH 6/6] [gdb/symtab] Replace TYPE_ALLOC with TYPE_ZALLOC where required Tom de Vries
2023-08-30 20:26   ` Tom Tromey
2023-08-30 20:15 ` [PATCH 1/6] [gdb/symtab] Fix uninitialized memory in buildsym_compunit::finish_block_internal Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230830191336.15885-3-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).