From nobody Sun Jul 26 11:04:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1782858760; cv=none; d=zohomail.com; s=zohoarc; b=cL+5TjIf0bE0BLYbjNH7yXsmRvzZcTXEQnkfGtU1GwYPLshAOduEAsWwk/vxEVQJWYu9VRxobvfTJjKeYMQD5Qo1n46g8H3tcJ6xjvjP/Ic3V6zvyYcFZ8fmAjHA3Pf/Dc/jbhUkYmqxNY3g8Uf5vQDJw3RG1ne5C2FilG9QpKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782858760; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=GdyzAyxccl5bxMSbIUYTBW1C0tHwD4tBpKVEjbdiMCY=; b=RLg8gKQpm3UEU90fxOxHvuMXHM9ag0y0dsGdKoPjdzqsVnUqGr6lSeB/vVvn9EbZd6e4L0PnvSO56LINc7qq4NkwNFlw6xghObiL1Jf/8M1jbZYb9dIxuxynCq29RrQFu8LxoLQnTVYNNGOLkrvySlYI8bRCoReL5Hh8oYJWJGQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782858760893676.2039082820069; Tue, 30 Jun 2026 15:32:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1weh0B-00017i-R0; Tue, 30 Jun 2026 18:32:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1weh08-000174-08 for qemu-devel@nongnu.org; Tue, 30 Jun 2026 18:32:20 -0400 Received: from mail-08.mail-europe.com ([57.129.93.249]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1weh03-0008Fp-LR for qemu-devel@nongnu.org; Tue, 30 Jun 2026 18:32:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=mc4mt4vr2vhbzps6izri3ctnwa.protonmail; t=1782858729; x=1783117929; bh=GdyzAyxccl5bxMSbIUYTBW1C0tHwD4tBpKVEjbdiMCY=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=iaATYGkZsl9fgT9pfGSV1jWvHSvg9nqODXQq5UCTJvGXIA1COT/8Viv5731lUznmk cVDnU+tJ8amCtiH2PNKgNBoafRN/fYTC243KXTF0RQs6NXNeOYMH0r6q+gcUjY2VQB IwgyCcWcCjIF4LmD//Zw4gYnRDN2VL4W04yVqMSz+syMXqlOnotLBx34cV3FCFvFBp rWRWUovqVUgSq3S5iFm4rVHAyCjfqHx0F4g8v3vD8Lxvd9rZ3n/+q9JOmB975Gc7KK xOs44Pxfq8tbeChBmVVmADkLYe6Za+MKX3Bx3HLBHkPbz4fM5ZD1MW0AXrd17XDQc2 VTW9ucP53FHPA== Date: Tue, 30 Jun 2026 22:32:04 +0000 To: qemu-devel@nongnu.org, Laurent Vivier From: "Christian S. Lima" Subject: [PATCH v2] disas: converts malloc to g_new0 Message-ID: <20260630223159.68737-1-christianslima@proton.me> Feedback-ID: 169431447:user:proton X-Pm-Message-ID: d81b2355e94e7fa004395ffaaf2656853aebe49e MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=57.129.93.249; envelope-from=christianslima@proton.me; helo=mail-08.mail-europe.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1782858762389158500 Content-Type: text/plain; charset="utf-8" Following the qemu coding style change from malloc to g_new0, the advantages are that g_new0 catch multiplication overflowing size_t, allows for better detection of type errors because it returns the type itself and initialize memory with zeros to detect if something go wrong. Signed-off-by: Christian S. Lima Reviewed-by: Markus Armbruster --- Changes in v2: - Change from g_malloc0 to g_new0 --- disas/m68k.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/disas/m68k.c b/disas/m68k.c index 800b4145ac..c3571783b0 100644 --- a/disas/m68k.c +++ b/disas/m68k.c @@ -1887,8 +1887,7 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *i= nfo) =20 /* Then create a sorted table of pointers that point into the unsorted table. */ - opc_pointer[0] =3D malloc (sizeof (struct m68k_opcode *) - * m68k_numopcodes); + opc_pointer[0] =3D g_new0(const struct m68k_opcode *, m68k_numopcode= s); opcodes[0] =3D opc_pointer[0]; =20 for (i =3D 1; i < 16; i++) --=20 2.53.0