From nobody Tue Nov 26 20:04:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1705961823; cv=none; d=zohomail.com; s=zohoarc; b=b2Ffyg1CWZPYTBdZWvCZ3D8tLPGY/caVCTmibHJEC5gHPKwBuqve+2LHbcXFZlDFWGHIfPmvXp2rn2WdmWqUTtq9gfzJIVP/L+ImgPwW6GaUqVcAA9z2lyp3oym21BCdfY1mXAj2omLTMpZbdZkoCNNKMR3/nmbJpv9aoxfrrv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705961823; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WX7OqCyKznH6Xg+YgqFqeDU+3oQq1TVExI/mQG8+wFY=; b=mMl/cwwSqTvbTfadj0MZqYX33PEfMh27BVYGHMxYFXBYafbeohl5GlXApf6kFMl5Rz99GOlBwzbwyTQmutAxL9vUjmx3SI2FvAx7faJI8e0qOsgmHh0HtWJaPGK+SHKHlbotkMKnaULhYYl7lpUtbzhe9eG/g+pi04R2TqkTuEA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705961823820691.304981749626; Mon, 22 Jan 2024 14:17:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rS2aS-0004sm-Ra; Mon, 22 Jan 2024 17:16:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rS2a7-0004ow-RZ for qemu-devel@nongnu.org; Mon, 22 Jan 2024 17:15:53 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rS2a5-0005vh-55 for qemu-devel@nongnu.org; Mon, 22 Jan 2024 17:15:51 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d71e24845aso19500145ad.0 for ; Mon, 22 Jan 2024 14:15:48 -0800 (PST) Received: from grind.. ([152.234.127.94]) by smtp.gmail.com with ESMTPSA id kr8-20020a170903080800b001d7338977e6sm4029104plb.223.2024.01.22.14.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 14:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1705961747; x=1706566547; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WX7OqCyKznH6Xg+YgqFqeDU+3oQq1TVExI/mQG8+wFY=; b=dh0pyy1SBx1XhX3Rlh4NRfnJuwwnPYS9qZZF2NW28RSsWaAayE3tSLHlEp4i2QPSFn e9C08FTRJwGk1Mcva3LmSmmEcbbE1HO2QpPV4iaAJ1WuDIValvyu2y2YbDP8bDi6Dlkl drxKp8nDxCHEJSXRb9g4RkXmfZWmbm/4jpbbYd3rpgbqWmslqo6essqvpAjtT2l54UPR 9mkHUuxv+Vut9c2qA0DT4p5PIn2mM8v/d7NivD2m9h/snjEmC43pjuG7KA4/4UDsn3pC UixHf94Fa9L9bYs71qRW7cC+drdI/wOB4EtQb7wNj3WRv+v/7dgrm9YYgbQ/o1M3Cd7/ pNtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705961747; x=1706566547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WX7OqCyKznH6Xg+YgqFqeDU+3oQq1TVExI/mQG8+wFY=; b=Hy8jokd2rwbZQ5WlZxygxC31PQyiLA6ZJkp7qxTjmeFWxHalioGQYPJDYKcuc97xyI xJCsktyY8ScpeiKTLvaCmicOpO+M3pr4XxlrSrEONPXmGIbI5IaX+LBXv9h62g2iIM3A A0VmWwbkjIcyTbD5pMcU7roIPfssgDrlu08gPvY85Z597BnvSTpX2LW1811nU34j5Vfv NxuN3NySgnAhQq/iQBdfxghtq7qkP3heKyDV/8EAaHpEPgJcVRk1tlLB4xVcrWmh/jP+ ltbMuBGHLEqs+Tl21k+trELJG4DYq1fIDnokEgy7KeSUOW8v8wblcRl6TtAYp4ErTU04 nccA== X-Gm-Message-State: AOJu0YykA/4FqB8p/O3+UPn1c8rqVQFeuRfFKmxnVW1fgrswqP6tb9wC fDz1vXuJEKrA3fDolDn5KfGRiinFN7efDasQmxEkg4qoWIbIZx5EdyZBEQyMH4Vglbqhaa690uB d X-Google-Smtp-Source: AGHT+IEUeRkhNeTWUoJFpnmdmj8HsTlZKD7bvdHdJHpp/3Cnr9klbj89tzwsW2Rk0d76hZHPblV3uQ== X-Received: by 2002:a17:903:2348:b0:1d7:600c:cc3b with SMTP id c8-20020a170903234800b001d7600ccc3bmr1352388plh.22.1705961746992; Mon, 22 Jan 2024 14:15:46 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH 4/7] hw/riscv/virt.c: use g_autofree in create_fdt_sockets() Date: Mon, 22 Jan 2024 19:15:26 -0300 Message-ID: <20240122221529.86562-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122221529.86562-1-dbarboza@ventanamicro.com> References: <20240122221529.86562-1-dbarboza@ventanamicro.com> 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1705961825967100005 Content-Type: text/plain; charset="utf-8" Move 'clust_name' inside the loop, and g_autofree, to avoid having to g_free() manually in each loop iteration. 'intc_phandles' is also g_autofreed to avoid another manual g_free(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- hw/riscv/virt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 373b1dd96b..d0f402e0d5 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -721,11 +721,11 @@ static void create_fdt_sockets(RISCVVirtState *s, con= st MemMapEntry *memmap, uint32_t *irq_virtio_phandle, uint32_t *msi_pcie_phandle) { - char *clust_name; int socket, phandle_pos; MachineState *ms =3D MACHINE(s); uint32_t msi_m_phandle =3D 0, msi_s_phandle =3D 0; - uint32_t *intc_phandles, xplic_phandles[MAX_NODES]; + uint32_t xplic_phandles[MAX_NODES]; + g_autofree uint32_t *intc_phandles =3D NULL; int socket_count =3D riscv_socket_count(ms); =20 qemu_fdt_add_subnode(ms->fdt, "/cpus"); @@ -739,6 +739,7 @@ static void create_fdt_sockets(RISCVVirtState *s, const= MemMapEntry *memmap, =20 phandle_pos =3D ms->smp.cpus; for (socket =3D (socket_count - 1); socket >=3D 0; socket--) { + g_autofree char *clust_name =3D NULL; phandle_pos -=3D s->soc[socket].num_harts; =20 clust_name =3D g_strdup_printf("/cpus/cpu-map/cluster%d", socket); @@ -749,8 +750,6 @@ static void create_fdt_sockets(RISCVVirtState *s, const= MemMapEntry *memmap, =20 create_fdt_socket_memory(s, memmap, socket); =20 - g_free(clust_name); - if (tcg_enabled()) { if (s->have_aclint) { create_fdt_socket_aclint(s, memmap, socket, @@ -793,8 +792,6 @@ static void create_fdt_sockets(RISCVVirtState *s, const= MemMapEntry *memmap, } } =20 - g_free(intc_phandles); - if (kvm_enabled() && virt_use_kvm_aia(s)) { *irq_mmio_phandle =3D xplic_phandles[0]; *irq_virtio_phandle =3D xplic_phandles[0]; --=20 2.43.0