From: David Gibson <david@gibson.dropbear.id.au>
To: Daniel Henrique Barboza <danielhb413@gmail.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org
Subject: Re: [PATCH v1 1/2] spapr.c: use g_auto* with 'nodename' in CPU DT functions
Date: Thu, 21 Jan 2021 11:27:56 +1100 [thread overview]
Message-ID: <20210121002756.GB5174@yekko.fritz.box> (raw)
In-Reply-To: <20210120232305.241521-2-danielhb413@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2378 bytes --]
On Wed, Jan 20, 2021 at 08:23:04PM -0300, Daniel Henrique Barboza wrote:
> Next patch will use the 'nodename' string in spapr_core_dt_populate()
> after the point it's being freed today.
>
> Instead of moving 'g_free(nodename)' around, let's do a QoL change in
> both CPU DT functions where 'nodename' is being freed, and use
> g_autofree to avoid the 'g_free()' call altogether.
>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Applied, thanks.
> ---
> hw/ppc/spapr.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 6c47466fc2..cc1b709615 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -790,7 +790,6 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState *spapr)
> CPUState *cs;
> int n_cpus;
> int cpus_offset;
> - char *nodename;
> int i;
>
> cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
> @@ -818,6 +817,7 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState *spapr)
> PowerPCCPU *cpu = POWERPC_CPU(cs);
> int index = spapr_get_vcpu_id(cpu);
> DeviceClass *dc = DEVICE_GET_CLASS(cs);
> + g_autofree char *nodename = NULL;
> int offset;
>
> if (!spapr_is_thread0_in_vcore(spapr, cpu)) {
> @@ -826,7 +826,6 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState *spapr)
>
> nodename = g_strdup_printf("%s@%x", dc->fw_name, index);
> offset = fdt_add_subnode(fdt, cpus_offset, nodename);
> - g_free(nodename);
> _FDT(offset);
> spapr_dt_cpu(cs, fdt, offset, spapr);
> }
> @@ -3743,12 +3742,11 @@ int spapr_core_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
> PowerPCCPU *cpu = POWERPC_CPU(cs);
> DeviceClass *dc = DEVICE_GET_CLASS(cs);
> int id = spapr_get_vcpu_id(cpu);
> - char *nodename;
> + g_autofree char *nodename = NULL;
> int offset;
>
> nodename = g_strdup_printf("%s@%x", dc->fw_name, id);
> offset = fdt_add_subnode(fdt, 0, nodename);
> - g_free(nodename);
>
> spapr_dt_cpu(cs, fdt, offset, spapr);
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2021-01-21 0:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 23:23 [PATCH v1 0/2] spapr.c: add 'name' property for hotplugged CPUs nodes Daniel Henrique Barboza
2021-01-20 23:23 ` [PATCH v1 1/2] spapr.c: use g_auto* with 'nodename' in CPU DT functions Daniel Henrique Barboza
2021-01-21 0:27 ` David Gibson [this message]
2021-01-20 23:23 ` [PATCH v1 2/2] spapr.c: add 'name' property for hotplugged CPUs nodes Daniel Henrique Barboza
2021-01-21 0:43 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210121002756.GB5174@yekko.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=danielhb413@gmail.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).