From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id A1D513858D35 for ; Wed, 30 Aug 2023 19:13:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1D513858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C6FD421854 for ; Wed, 30 Aug 2023 19:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1693422786; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jYI6vEmvNmzhjLA4bG4TsfxIHCoGggiHCreVpvImKrk=; b=WYfVU1TvRyKi+xuvFUWGu6HL3/xq3AMcTD7YvDAMwxmqfh5zADN353Jw14nvj2rvhW6e7S I2rrMO8fqn8BT9NPH2k5UGnOo6Rth8+q/LYRo/46DIHeb18nGG5lGEeCzo+53fmolSsG+G r3wW/IMjOqjmFYCEhYnwo53GdzH157o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1693422786; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jYI6vEmvNmzhjLA4bG4TsfxIHCoGggiHCreVpvImKrk=; b=VLvI83JqwobWxNBbUye5/a8QOHMgKwiWPPobc0MGgbUwVay2KI6dRE2ktG3PGBZ0zjFWJA wLKcAlGYM82wZwAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B5DE2139F5 for ; Wed, 30 Aug 2023 19:13:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wNVhK8KU72Q2IQAAMHmgww (envelope-from ) for ; Wed, 30 Aug 2023 19:13:06 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 6/6] [gdb/symtab] Replace TYPE_ALLOC with TYPE_ZALLOC where required Date: Wed, 30 Aug 2023 21:13:36 +0200 Message-Id: <20230830191336.15885-6-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230830191336.15885-1-tdevries@suse.de> References: <20230830191336.15885-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Handle the remaining uses of TYPE_ALLOC, either by: - replacing with TYPE_ZALLOC, or - adding a comment explaining why zero-initialization is not necessary. Tested on x86_64-linux. --- gdb/dwarf2/read.c | 10 ++++++++-- gdb/gdbtypes.c | 8 +++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index bc68c290289..527e0770502 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -12376,8 +12376,8 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type, ALLOCATE_CPLUS_STRUCT_TYPE (type); TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *) - TYPE_ALLOC (type, - sizeof (struct fn_fieldlist) * fip->fnfieldlists.size ()); + TYPE_ZALLOC (type, + sizeof (struct fn_fieldlist) * fip->fnfieldlists.size ()); for (int i = 0; i < fip->fnfieldlists.size (); i++) { @@ -12386,6 +12386,8 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type, TYPE_FN_FIELDLIST_NAME (type, i) = nf.name; TYPE_FN_FIELDLIST_LENGTH (type, i) = nf.fnfields.size (); + /* No need to zero-initialize, initialization is done by the copy in + the loop below. */ fn_flp->fn_fields = (struct fn_field *) TYPE_ALLOC (type, sizeof (struct fn_field) * nf.fnfields.size ()); @@ -13088,6 +13090,8 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) int count = fi.typedef_field_list.size (); ALLOCATE_CPLUS_STRUCT_TYPE (type); + /* No zero-initialization is need, the elements are initialized by + the copy in the loop below. */ TYPE_TYPEDEF_FIELD_ARRAY (type) = ((struct decl_field *) TYPE_ALLOC (type, @@ -13106,6 +13110,8 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) int count = fi.nested_types_list.size (); ALLOCATE_CPLUS_STRUCT_TYPE (type); + /* No zero-initialization is need, the elements are initialized by + the copy in the loop below. */ TYPE_NESTED_TYPES_ARRAY (type) = ((struct decl_field *) TYPE_ALLOC (type, sizeof (struct decl_field) * count)); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 766107a7013..fd67c4bafdb 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3207,7 +3207,7 @@ check_stub_method (struct type *type, int method_id, int signature_id) /* We need one extra slot, for the THIS pointer. */ argtypes = (struct field *) - TYPE_ALLOC (type, (argcount + 1) * sizeof (struct field)); + TYPE_ZALLOC (type, (argcount + 1) * sizeof (struct field)); p = argtypetext; /* Add THIS pointer for non-static methods. */ @@ -3297,7 +3297,7 @@ allocate_cplus_struct_type (struct type *type) TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF; TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *) - TYPE_ALLOC (type, sizeof (struct cplus_struct_type)); + TYPE_ZALLOC (type, sizeof (struct cplus_struct_type)); *(TYPE_RAW_CPLUS_SPECIFIC (type)) = cplus_struct_default; set_type_vptr_fieldno (type, -1); } @@ -3314,7 +3314,7 @@ allocate_gnat_aux_type (struct type *type) { TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF; TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *) - TYPE_ALLOC (type, sizeof (struct gnat_aux_type)); + TYPE_ZALLOC (type, sizeof (struct gnat_aux_type)); *(TYPE_GNAT_SPECIFIC (type)) = gnat_aux_default; } @@ -3454,6 +3454,8 @@ init_complex_type (const char *name, struct type *target_type) { if (name == nullptr && target_type->name () != nullptr) { + /* No zero-initialization required, initialized by strcpy/strcat + below. */ char *new_name = (char *) TYPE_ALLOC (target_type, strlen (target_type->name ()) -- 2.35.3