From nobody Tue Nov 26 19:43:43 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=DuJ0wd/jTMc8/8gD03m00C9N2jxcFQSBfTx0qu6cZ/WIVwl9HwugBLHJihlYZEvg/383+u5qUGC6wf9q8DYgehqk1VMzjVWHcm1A2Q1KfjoFPMJQHLXd5FwSlVtAHmvlzWxezGN/8Au6aZ15g2Gfj38+TueBj+N3vE12xe2OZNA= 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=RXJkelt17p21iChlHdyIQJpyyWudaM9AOBguHLeeMgQ=; b=ivkhZDa0p+aA6+SplosQaoLUJzBDx1EgQBEt7N7u56tBjtTetEwUhtDYUhaD/Epea1uOYAC1nMAeIueIpUez+C3eE/L8hmvVnx9ncpfy38Fdsd5JZV3m0SZCUiwssQT6kOv0zgTebiybCYJLrgFTRFTtMgCjgz3Q79TDkV25fIk= 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 1705961823729674.3100354103851; 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 1rS2aD-0004px-O4; Mon, 22 Jan 2024 17:15:57 -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 1rS2a5-0004oe-5q for qemu-devel@nongnu.org; Mon, 22 Jan 2024 17:15:51 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rS2a2-0005vF-68 for qemu-devel@nongnu.org; Mon, 22 Jan 2024 17:15:47 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d746856d85so8173745ad.0 for ; Mon, 22 Jan 2024 14:15:45 -0800 (PST) Received: from grind.. ([152.234.127.94]) by smtp.gmail.com with ESMTPSA id kr8-20020a170903080800b001d7338977e6sm4029104plb.223.2024.01.22.14.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 14:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1705961744; x=1706566544; 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=RXJkelt17p21iChlHdyIQJpyyWudaM9AOBguHLeeMgQ=; b=lp7lBg0KgWu7fwwE4/vN/jAoWT+vfwdO+9Yiz+Jw6gjMNJIX80cBbp2d+ABEz6ZIMO g3SNvinrbjhXGgr1CNMlVL9oYUQ5G/qQK/Z4LjWEeDSt7Rf35JWAWgwDq/IfF6QvbNQa YkhkBWY5+dgWbeflRmMFouVIOzMJ0eb5EuAf7HFt0U82QLIFpgXfWd/U5klbuZdyQSBK ei49dqui62X1MQJwyPb2D1fRZi3qlRkz3IhGqTCP6AxcPOvcuimUN+2kuf2U+2dX3a74 FsXkG6Tkh5D/ZeEcPqNc9OWEIzKoHi2ZlDPZN0NBEAItBiT4NHZzJqIaQRejnu72y9Py ulFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705961744; x=1706566544; 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=RXJkelt17p21iChlHdyIQJpyyWudaM9AOBguHLeeMgQ=; b=jXXjACBjz3gvrzoRJPc3aHQMDtDZYUxgyDOQK2vpLIwdrPAQd8+PoLL6GGbth+4PRi QKBjZAuAquWZ5YDGMlCkd/qWHQnH/9h92FzvdneVaBVmWPK/G6EVNu9zKiYINUvGmHY+ IB+haNq0mjLoWnSiqpUww6j2CYbN/PZRSgZwcWZfegRJaGw0ST5jMz2zDNJzVICgXBUi fODpI5hYxMEeElE+K0YL/HPGJ7YJbAdNn0f6XD1F9QqhvAq2VLl0rZqWVvkW3FjBe5gK xu6i53mvanDj+hWB6nbinIL8+RgW4tOfF4DJWgr2U30r/5b7KTCGyY0VAdI35ZODEWUc ssFA== X-Gm-Message-State: AOJu0Yw1cDHwL1CxEv0+kd5iqJf/I3ey5hLoK8vSWsyvvQMbVXS1F3KW dBcKu/tk5Vx8cyK1naO3iYUw7t9qaPQflqMH2xg7DapbgL6BjBj1aTpSJW9tpJIo/xXK4/kcQCp U X-Google-Smtp-Source: AGHT+IHbmrRzoDHuMPAm+9RhG728+lpTXnTIbB5f/SqVjXPWWMy/EmeBdxl0eXAAmPSKdisro603Ag== X-Received: by 2002:a17:902:ea92:b0:1d6:ee5c:42c2 with SMTP id x18-20020a170902ea9200b001d6ee5c42c2mr2027491plb.115.1705961744093; Mon, 22 Jan 2024 14:15:44 -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 3/7] hw/riscv/virt.c: use g_autofree in create_fdt_socket_cpus() Date: Mon, 22 Jan 2024 19:15:25 -0300 Message-ID: <20240122221529.86562-4-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::634; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x634.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: 1705961825967100006 Content-Type: text/plain; charset="utf-8" Move all char pointers to the loop. Use g_autofree in all of them to avoid the g_free() calls. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/riscv/virt.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index f9fd1341fc..373b1dd96b 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -215,12 +215,16 @@ static void create_fdt_socket_cpus(RISCVVirtState *s,= int socket, int cpu; uint32_t cpu_phandle; MachineState *ms =3D MACHINE(s); - char *name, *cpu_name, *core_name, *intc_name, *sv_name; bool is_32_bit =3D riscv_is_32bit(&s->soc[0]); uint8_t satp_mode_max; =20 for (cpu =3D s->soc[socket].num_harts - 1; cpu >=3D 0; cpu--) { RISCVCPU *cpu_ptr =3D &s->soc[socket].harts[cpu]; + g_autofree char *name =3D NULL; + g_autofree char *cpu_name =3D NULL; + g_autofree char *core_name =3D NULL; + g_autofree char *intc_name =3D NULL; + g_autofree char *sv_name =3D NULL; =20 cpu_phandle =3D (*phandle)++; =20 @@ -233,12 +237,10 @@ static void create_fdt_socket_cpus(RISCVVirtState *s,= int socket, sv_name =3D g_strdup_printf("riscv,%s", satp_mode_str(satp_mode_max, is_32_b= it)); qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", sv_name= ); - g_free(sv_name); } =20 name =3D riscv_isa_string(cpu_ptr); qemu_fdt_setprop_string(ms->fdt, cpu_name, "riscv,isa", name); - g_free(name); =20 if (cpu_ptr->cfg.ext_zicbom) { qemu_fdt_setprop_cell(ms->fdt, cpu_name, "riscv,cbom-block-siz= e", @@ -277,10 +279,6 @@ static void create_fdt_socket_cpus(RISCVVirtState *s, = int socket, core_name =3D g_strdup_printf("%s/core%d", clust_name, cpu); qemu_fdt_add_subnode(ms->fdt, core_name); qemu_fdt_setprop_cell(ms->fdt, core_name, "cpu", cpu_phandle); - - g_free(core_name); - g_free(intc_name); - g_free(cpu_name); } } =20 --=20 2.43.0