[PATCH 1/8] hw/ppc: Clean up local variable shadowing in _FDT helper routine

Cédric Le Goater posted 8 patches 11 months, 3 weeks ago
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Nicholas Piggin <npiggin@gmail.com>, "Frédéric Barrat" <fbarrat@linux.ibm.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Harsh Prateek Bora <harshpb@linux.ibm.com>
[PATCH 1/8] hw/ppc: Clean up local variable shadowing in _FDT helper routine
Posted by Cédric Le Goater 11 months, 3 weeks ago
this fixes numerous warnings of this type :

  In file included from ../hw/ppc/spapr_pci.c:43:
  ../hw/ppc/spapr_pci.c: In function ‘spapr_dt_phb’:
  ../include/hw/ppc/fdt.h:18:13: warning: declaration of ‘ret’ shadows a previous local [-Wshadow=compatible-local]
     18 |         int ret = (exp);                                           \
        |             ^~~
  ../hw/ppc/spapr_pci.c:2355:5: note: in expansion of macro ‘_FDT’
   2355 |     _FDT(bus_off = fdt_add_subnode(fdt, 0, phb->dtbusname));
        |     ^~~~
  ../hw/ppc/spapr_pci.c:2311:24: note: shadowed declaration is here
   2311 |     int bus_off, i, j, ret;
        |                        ^~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 include/hw/ppc/fdt.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/hw/ppc/fdt.h b/include/hw/ppc/fdt.h
index a8cd85069fe0..b56ac2a8cbb5 100644
--- a/include/hw/ppc/fdt.h
+++ b/include/hw/ppc/fdt.h
@@ -15,10 +15,10 @@
 
 #define _FDT(exp)                                                  \
     do {                                                           \
-        int ret = (exp);                                           \
-        if (ret < 0) {                                             \
-            error_report("error creating device tree: %s: %s",   \
-                    #exp, fdt_strerror(ret));                      \
+        int _ret = (exp);                                          \
+        if (_ret < 0) {                                            \
+            error_report("error creating device tree: %s: %s",     \
+                    #exp, fdt_strerror(_ret));                     \
             exit(1);                                               \
         }                                                          \
     } while (0)
-- 
2.41.0


Re: [PATCH 1/8] hw/ppc: Clean up local variable shadowing in _FDT helper routine
Posted by Harsh Prateek Bora 11 months, 3 weeks ago

On 9/18/23 20:28, Cédric Le Goater wrote:
> this fixes numerous warnings of this type :
> 
>    In file included from ../hw/ppc/spapr_pci.c:43:
>    ../hw/ppc/spapr_pci.c: In function ‘spapr_dt_phb’:
>    ../include/hw/ppc/fdt.h:18:13: warning: declaration of ‘ret’ shadows a previous local [-Wshadow=compatible-local]
>       18 |         int ret = (exp);                                           \
>          |             ^~~
>    ../hw/ppc/spapr_pci.c:2355:5: note: in expansion of macro ‘_FDT’
>     2355 |     _FDT(bus_off = fdt_add_subnode(fdt, 0, phb->dtbusname));
>          |     ^~~~
>    ../hw/ppc/spapr_pci.c:2311:24: note: shadowed declaration is here
>     2311 |     int bus_off, i, j, ret;
>          |                        ^~~
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

> ---
>   include/hw/ppc/fdt.h | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/hw/ppc/fdt.h b/include/hw/ppc/fdt.h
> index a8cd85069fe0..b56ac2a8cbb5 100644
> --- a/include/hw/ppc/fdt.h
> +++ b/include/hw/ppc/fdt.h
> @@ -15,10 +15,10 @@
>   
>   #define _FDT(exp)                                                  \
>       do {                                                           \
> -        int ret = (exp);                                           \
> -        if (ret < 0) {                                             \
> -            error_report("error creating device tree: %s: %s",   \
> -                    #exp, fdt_strerror(ret));                      \
> +        int _ret = (exp);                                          \
> +        if (_ret < 0) {                                            \
> +            error_report("error creating device tree: %s: %s",     \
> +                    #exp, fdt_strerror(_ret));                     \
>               exit(1);                                               \
>           }                                                          \
>       } while (0)