Message ID | 20230918145850.241074-8-clg@kaod.org |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | ppc: Clean up local variable shadowing | expand |
On 9/18/23 20:28, Cédric Le Goater wrote: > Rename SysBusDevice variable to avoid this warning : > > ../hw/ppc/spapr_pci.c: In function ‘spapr_phb_realize’: > ../hw/ppc/spapr_pci.c:1872:24: warning: declaration of ‘s’ shadows a previous local [-Wshadow=local] > 1872 | SpaprPhbState *s; > | ^ > ../hw/ppc/spapr_pci.c:1829:19: note: shadowed declaration is here > 1829 | SysBusDevice *s = SYS_BUS_DEVICE(dev); > | ^ > > Signed-off-by: Cédric Le Goater <clg@kaod.org> > --- > hw/ppc/spapr_pci.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c > index ce1495931744..370c5a90f218 100644 > --- a/hw/ppc/spapr_pci.c > +++ b/hw/ppc/spapr_pci.c > @@ -1826,9 +1826,9 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) > (SpaprMachineState *) object_dynamic_cast(qdev_get_machine(), > TYPE_SPAPR_MACHINE); > SpaprMachineClass *smc = spapr ? SPAPR_MACHINE_GET_CLASS(spapr) : NULL; > - SysBusDevice *s = SYS_BUS_DEVICE(dev); > - SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(s); > - PCIHostState *phb = PCI_HOST_BRIDGE(s); > + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); > + SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(sbd); Declaration of SpaprPhbState *s later in the code could be brought here? Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com> > + PCIHostState *phb = PCI_HOST_BRIDGE(sbd); > MachineState *ms = MACHINE(spapr); > char *namebuf; > int i;
On 9/19/23 10:38, Harsh Prateek Bora wrote: > > > On 9/18/23 20:28, Cédric Le Goater wrote: >> Rename SysBusDevice variable to avoid this warning : >> >> ../hw/ppc/spapr_pci.c: In function ‘spapr_phb_realize’: >> ../hw/ppc/spapr_pci.c:1872:24: warning: declaration of ‘s’ shadows a previous local [-Wshadow=local] >> 1872 | SpaprPhbState *s; >> | ^ >> ../hw/ppc/spapr_pci.c:1829:19: note: shadowed declaration is here >> 1829 | SysBusDevice *s = SYS_BUS_DEVICE(dev); >> | ^ >> >> Signed-off-by: Cédric Le Goater <clg@kaod.org> >> --- >> hw/ppc/spapr_pci.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c >> index ce1495931744..370c5a90f218 100644 >> --- a/hw/ppc/spapr_pci.c >> +++ b/hw/ppc/spapr_pci.c >> @@ -1826,9 +1826,9 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) >> (SpaprMachineState *) object_dynamic_cast(qdev_get_machine(), >> TYPE_SPAPR_MACHINE); >> SpaprMachineClass *smc = spapr ? SPAPR_MACHINE_GET_CLASS(spapr) : NULL; >> - SysBusDevice *s = SYS_BUS_DEVICE(dev); >> - SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(s); >> - PCIHostState *phb = PCI_HOST_BRIDGE(s); >> + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); >> + SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(sbd); > > Declaration of SpaprPhbState *s later in the code could be brought here? nah. 's' is really local. It could be even called 'tmp' IMO. Thanks, C. > > Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com> > >> + PCIHostState *phb = PCI_HOST_BRIDGE(sbd); >> MachineState *ms = MACHINE(spapr); >> char *namebuf; >> int i;
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index ce1495931744..370c5a90f218 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1826,9 +1826,9 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) (SpaprMachineState *) object_dynamic_cast(qdev_get_machine(), TYPE_SPAPR_MACHINE); SpaprMachineClass *smc = spapr ? SPAPR_MACHINE_GET_CLASS(spapr) : NULL; - SysBusDevice *s = SYS_BUS_DEVICE(dev); - SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(s); - PCIHostState *phb = PCI_HOST_BRIDGE(s); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(sbd); + PCIHostState *phb = PCI_HOST_BRIDGE(sbd); MachineState *ms = MACHINE(spapr); char *namebuf; int i;
Rename SysBusDevice variable to avoid this warning : ../hw/ppc/spapr_pci.c: In function ‘spapr_phb_realize’: ../hw/ppc/spapr_pci.c:1872:24: warning: declaration of ‘s’ shadows a previous local [-Wshadow=local] 1872 | SpaprPhbState *s; | ^ ../hw/ppc/spapr_pci.c:1829:19: note: shadowed declaration is here 1829 | SysBusDevice *s = SYS_BUS_DEVICE(dev); | ^ Signed-off-by: Cédric Le Goater <clg@kaod.org> --- hw/ppc/spapr_pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)