From nobody Tue Feb 10 11:13:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541680508627374.6959379952581; Thu, 8 Nov 2018 04:35:08 -0800 (PST) Received: from localhost ([::1]:56348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKjWd-0003rW-7i for importer@patchew.org; Thu, 08 Nov 2018 07:35:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKjFQ-0005KA-Og for qemu-devel@nongnu.org; Thu, 08 Nov 2018 07:17:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKjFM-0003zL-Or for qemu-devel@nongnu.org; Thu, 08 Nov 2018 07:17:20 -0500 Received: from ozlabs.org ([203.11.71.1]:36259) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKjFM-0003eX-8k; Thu, 08 Nov 2018 07:17:16 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 42rMj12hmcz9sN9; Thu, 8 Nov 2018 23:16:52 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1541679413; bh=sG23we4mf4vbCP0sK/3D1wdd5rDieAjzCWU+SBN9XBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P8x1u0D+1pHIvS7HGMSNHObLpu0yNbqndWgdAwUnBpFoNr1IBCAmvRrKK1MpaPZkq epEUVLrAE2vq/CCNBcS5VMI7YtbuUxPBnTpSxiEYcFMEsE90TG8ZNm0+Z6G8JtFmxp gO0+5J4MTFaI3yi9MLD1pSpWMtddYmazWTu6pxj0= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 8 Nov 2018 23:16:37 +1100 Message-Id: <20181108121646.26173-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108121646.26173-1-david@gibson.dropbear.id.au> References: <20181108121646.26173-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 13/22] spapr_pci: convert g_malloc() to g_new() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, agraf@suse.de, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz When allocating an array, it is a recommended coding practice to call g_new(FooType, n) instead of g_malloc(n * sizeof(FooType)) because it takes care to avoid overflow when calculating the size of the allocated block and it returns FooType *, which allows the compiler to perform type checking. Signed-off-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Gibson --- hw/ppc/spapr_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 58afa46204..2374d55fc1 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1882,7 +1882,7 @@ static int spapr_pci_pre_save(void *opaque) if (!sphb->msi_devs_num) { return 0; } - sphb->msi_devs =3D g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_= mig)); + sphb->msi_devs =3D g_new(spapr_pci_msi_mig, sphb->msi_devs_num); =20 g_hash_table_iter_init(&iter, sphb->msi); for (i =3D 0; g_hash_table_iter_next(&iter, &key, &value); ++i) { --=20 2.19.1