qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Harsh Prateek Bora <harsh.prateek.bora@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	Daniel Henrique Barboza <danielhb413@gmail.com>,
	David Gibson <david@gibson.dropbear.id.au>,
	 Nicholas Piggin <npiggin@gmail.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH 3/8] spapr: Clean up local variable shadowing in spapr_dt_cpus()
Date: Tue, 19 Sep 2023 20:29:18 +0530	[thread overview]
Message-ID: <CAEuJdmrbS2Jh6_zOQX=3EtN0xjHFQt3wGtHHnsh7CfvBt-1RCQ@mail.gmail.com> (raw)
In-Reply-To: <CAEuJdmpsG_SEpBcb33-NJKtYr2WNqNaKrKMsfAOQtiRg8NxFJA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3873 bytes --]

On Tue, 19 Sept, 2023, 6:34 pm Harsh Prateek Bora, <
harsh.prateek.bora@gmail.com> wrote:

>
>
> On Tue, 19 Sept, 2023, 4:37 pm Cédric Le Goater, <clg@kaod.org> wrote:
>
>> On 9/19/23 09:28, Harsh Prateek Bora wrote:
>> >
>> >
>> > On 9/18/23 20:28, Cédric Le Goater wrote:
>> >> Introduce a helper routine defining one CPU device node to fix this
>> >> warning :
>> >>
>> >>    ../hw/ppc/spapr.c: In function ‘spapr_dt_cpus’:
>> >>    ../hw/ppc/spapr.c:812:19: warning: declaration of ‘cs’ shadows a
>> previous local [-Wshadow=compatible-local]
>> >>      812 |         CPUState *cs = rev[i];
>> >>          |                   ^~
>> >>    ../hw/ppc/spapr.c:786:15: note: shadowed declaration is here
>> >>      786 |     CPUState *cs;
>> >>          |               ^~
>> >>
>> >> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> >> ---
>> >>   hw/ppc/spapr.c | 36 +++++++++++++++++++++---------------
>> >>   1 file changed, 21 insertions(+), 15 deletions(-)
>> >>
>> >> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> >> index de3c616b4637..d89f0fd496b6 100644
>> >> --- a/hw/ppc/spapr.c
>> >> +++ b/hw/ppc/spapr.c
>> >> @@ -780,6 +780,26 @@ static void spapr_dt_cpu(CPUState *cs, void *fdt,
>> int offset,
>> >>                                 pcc->lrg_decr_bits)));
>> >>   }
>> >> +static void spapr_dt_one_cpu(void *fdt, SpaprMachineState *spapr,
>> CPUState *cs,
>> >> +                             int cpus_offset)
>> >> +{
>> >> +    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)) {
>> >> +        return;
>> >> +    }
>> >> +
>> >> +    nodename = g_strdup_printf("%s@%x", dc->fw_name, index);
>> >> +    offset = fdt_add_subnode(fdt, cpus_offset, nodename);
>> >> +    _FDT(offset);
>> >> +    spapr_dt_cpu(cs, fdt, offset, spapr);
>> >> +}
>> >> +
>> >> +
>> >>   static void spapr_dt_cpus(void *fdt, SpaprMachineState *spapr)
>> >>   {
>> >>       CPUState **rev;
>> >> @@ -809,21 +829,7 @@ static void spapr_dt_cpus(void *fdt,
>> SpaprMachineState *spapr)
>> >>       }
>> >>       for (i = n_cpus - 1; i >= 0; i--) {
>> >> -        CPUState *cs = rev[i];
>> >> -        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)) {
>> >> -            continue;
>> >> -        }
>> >> -
>> >> -        nodename = g_strdup_printf("%s@%x", dc->fw_name, index);
>> >> -        offset = fdt_add_subnode(fdt, cpus_offset, nodename);
>> >> -        _FDT(offset);
>> >> -        spapr_dt_cpu(cs, fdt, offset, spapr);
>> >> +        spapr_dt_one_cpu(fdt, spapr, rev[i], cpus_offset);
>> >
>> > Do we want to replace the call to spapr_dt_cpu in
>> > spapr_core_dt_populate() with the _one_ as well?
>> > Not sure about the implication of additional instructions there.
>>
>> yeah may be we could rework spapr_dt_one_cpu() and
>> spapr_core_dt_populate()
>> in a single routine. They are similar. It can come later.
>>
>> > Also, could this code insider wrapper become part of spapr_dt_cpu()
>> itself?
>> > If can't, do we want a better renaming of wrapper here?
>>
>> I am open to proposal :)
>>
>
> How about spapr_dt_cpu_prepare() ?
>

I guess spapr_dt_cpu_process() may be more apt since it calls the
spapr_dt_cpu internally.


>
>> Thanks
>>
>> C.
>>
>>
>> >
>> > Otherwise,
>> > Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
>> >
>> >>       }
>> >>       g_free(rev);
>>
>>
>>

[-- Attachment #2: Type: text/html, Size: 5999 bytes --]

  reply	other threads:[~2023-09-19 15:00 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 14:58 [PATCH 0/8] ppc: Clean up local variable shadowing Cédric Le Goater
2023-09-18 14:58 ` [PATCH 1/8] hw/ppc: Clean up local variable shadowing in _FDT helper routine Cédric Le Goater
2023-09-19  6:53   ` Harsh Prateek Bora
2023-09-18 14:58 ` [PATCH 2/8] pnv/psi: Clean up local variable shadowing Cédric Le Goater
2023-09-19  6:57   ` Harsh Prateek Bora
2023-09-19  9:03     ` Cédric Le Goater
2023-09-29  5:30       ` Markus Armbruster
2023-09-29  6:13         ` Cédric Le Goater
2023-09-18 14:58 ` [PATCH 3/8] spapr: Clean up local variable shadowing in spapr_dt_cpus() Cédric Le Goater
2023-09-19  7:28   ` Harsh Prateek Bora
2023-09-19 11:05     ` Cédric Le Goater
2023-09-19 13:04       ` Harsh Prateek Bora
2023-09-19 14:59         ` Harsh Prateek Bora [this message]
2023-09-19 15:05           ` Cédric Le Goater
2023-09-18 14:58 ` [PATCH 4/8] spapr: Clean up local variable shadowing in spapr_init_cpus() Cédric Le Goater
2023-09-19  7:30   ` Harsh Prateek Bora
2023-09-18 14:58 ` [PATCH 5/8] spapr: Clean up local variable shadowing in spapr_get_fw_dev_path() Cédric Le Goater
2023-09-18 15:29   ` Philippe Mathieu-Daudé
2023-09-19  8:23   ` Harsh Prateek Bora
2023-09-19 11:54     ` Cédric Le Goater
2023-09-18 14:58 ` [PATCH 6/8] spapr/drc: Clean up local variable shadowing in rtas_ibm_configure_connector() Cédric Le Goater
2023-09-19  8:29   ` Harsh Prateek Bora
2023-09-19 12:02     ` Cédric Le Goater
2023-09-19 13:01       ` Harsh Prateek Bora
2023-09-29  5:34         ` Markus Armbruster
2023-09-29  5:43           ` Harsh Prateek Bora
2023-09-18 14:58 ` [PATCH 7/8] spapr/pci: Clean up local variable shadowing in spapr_phb_realize() Cédric Le Goater
2023-09-19  8:38   ` Harsh Prateek Bora
2023-09-19 12:04     ` Cédric Le Goater
2023-09-18 14:58 ` [PATCH 8/8] spapr/drc: Clean up local variable shadowing in prop_get_fdt() Cédric Le Goater
2023-09-18 15:30   ` Philippe Mathieu-Daudé
2023-09-19  8:48   ` Harsh Prateek Bora
2023-09-19 12:07     ` Cédric Le Goater
2023-09-19 12:55       ` Harsh Prateek Bora
2023-09-29  5:39         ` Markus Armbruster
2023-09-29  6:07           ` Cédric Le Goater
2023-09-29  6:18             ` Harsh Prateek Bora
2023-10-04 10:26 ` [PATCH 0/8] ppc: Clean up local variable shadowing Markus Armbruster
2023-10-04 11:56   ` Cédric Le Goater

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='CAEuJdmrbS2Jh6_zOQX=3EtN0xjHFQt3wGtHHnsh7CfvBt-1RCQ@mail.gmail.com' \
    --to=harsh.prateek.bora@gmail.com \
    --cc=armbru@redhat.com \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=harshpb@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --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).