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 5/6] [gdb/symtab] Replace TYPE_ALLOC + B_CLRALL with TYPE_ZALLOC
Date: Wed, 30 Aug 2023 21:13:35 +0200	[thread overview]
Message-ID: <20230830191336.15885-5-tdevries@suse.de> (raw)
In-Reply-To: <20230830191336.15885-1-tdevries@suse.de>

I noticed some cases of TYPE_ALLOC followed by B_CLRALL.

Replace these with TYPE_ZALLOC.

Tested on x86_64-linux.
---
 gdb/dwarf2/read.c | 12 ++++--------
 gdb/stabsread.c   | 15 +++++----------
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7fe0e84cdda..bc68c290289 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12064,16 +12064,13 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
       ALLOCATE_CPLUS_STRUCT_TYPE (type);
 
       TYPE_FIELD_PRIVATE_BITS (type) =
-	(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
-      B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
+	(B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
 
       TYPE_FIELD_PROTECTED_BITS (type) =
-	(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
-      B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
+	(B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
 
       TYPE_FIELD_IGNORE_BITS (type) =
-	(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
-      B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
+	(B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
     }
 
   /* If the type has baseclasses, allocate and clear a bit vector for
@@ -12084,9 +12081,8 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
       unsigned char *pointer;
 
       ALLOCATE_CPLUS_STRUCT_TYPE (type);
-      pointer = (unsigned char *) TYPE_ALLOC (type, num_bytes);
+      pointer = (unsigned char *) TYPE_ZALLOC (type, num_bytes);
       TYPE_FIELD_VIRTUAL_BITS (type) = pointer;
-      B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), fip->baseclasses.size ());
       TYPE_N_BASECLASSES (type) = fip->baseclasses.size ();
     }
 
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 18fefd6929c..1269fc02d72 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -3067,19 +3067,17 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
   /* Some stupid compilers have trouble with the following, so break
      it up into simpler expressions.  */
   TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
-    TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
+    TYPE_ZALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
 #else
   {
     int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
     char *pointer;
 
-    pointer = (char *) TYPE_ALLOC (type, num_bytes);
+    pointer = (char *) TYPE_ZALLOC (type, num_bytes);
     TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
   }
 #endif /* 0 */
 
-  B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
-
   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
     {
       newobj = OBSTACK_ZALLOC (&fip->obstack, struct stabs_nextfield);
@@ -3295,16 +3293,13 @@ attach_fields_to_type (struct stab_field_info *fip, struct type *type,
       ALLOCATE_CPLUS_STRUCT_TYPE (type);
 
       TYPE_FIELD_PRIVATE_BITS (type) =
-	(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
-      B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
+	(B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
 
       TYPE_FIELD_PROTECTED_BITS (type) =
-	(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
-      B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
+	(B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
 
       TYPE_FIELD_IGNORE_BITS (type) =
-	(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
-      B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
+	(B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
     }
 
   /* Copy the saved-up fields into the field vector.  Start from the
-- 
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 ` [PATCH 3/6] [gdb/symtab] Do more zero-initialization of type::fields Tom de Vries
2023-08-30 20:19   ` 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 ` Tom de Vries [this message]
2023-08-30 20:21   ` [PATCH 5/6] [gdb/symtab] Replace TYPE_ALLOC + B_CLRALL " 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-5-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).