Skip to contentSkip to conversation

(few more) Steps towards enabling -Wshadow [3 more]

PATCH In review Philippe Mathieu-Daudé 3 participants 8 messages Sep 4, 2023 – Sep 29, 2023

lore
Share & tools
lore
#0 lore raw

cover (few more) Steps towards enabling -Wshadow [3 more]

Just missed while posting v2 eh :/
(https://lore.kernel.org/qemu-devel/[email protected]/)

Philippe Mathieu-Daudé (3):
hw/core/machine: Clean up local variable shadowing hw/intc/openpic: Clean up local variable shadowing tests/qtest/pflash: Clean up local variable shadowing

 hw/core/machine.c               | 2 --
 hw/intc/openpic.c               | 7 ++-----
 tests/qtest/pflash-cfi02-test.c | 2 +-
 3 files changed, 3 insertions(+), 8 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/3 hw/core/machine: Clean up local variable shadowing

Fix:

hw/core/machine.c: In function ‘machine_initfn’:
hw/core/machine.c:1081:17: warning: declaration of ‘obj’ shadows a parameter [-Wshadow=compatible-local]
1081 | Object *obj = OBJECT(ms);
| ^~~
hw/core/machine.c:1065:36: note: shadowed declaration is here
1065 | static void machine_initfn(Object *obj)

        |                            ~~~~~~~~^~~
---
 hw/core/machine.c | 2 --
 1 file changed, 2 deletions(-)
hw/core/machine.c +0 -2
index da699cf4e1..7adc3d4e13 100644
@@ -1078,8 +1078,6 @@ static void machine_initfn(Object *obj)
     ms->maxram_size = mc->default_ram_size;
 
     if (mc->nvdimm_supported) {
-        Object *obj = OBJECT(ms);
-
         ms->nvdimms_state = g_new0(NVDIMMState, 1);
         object_property_add_bool(obj, "nvdimm",
                                  machine_get_nvdimm, machine_set_nvdimm);
Signature · 1 line
2.41.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] hw/core/machine: Clean up local variable shadowing

Quoted 9 lines · Philippe Mathieu-Daudé

Fix:

hw/core/machine.c: In function ‘machine_initfn’:
hw/core/machine.c:1081:17: warning: declaration of ‘obj’ shadows a parameter [-Wshadow=compatible-local]
1081 | Object *obj = OBJECT(ms);
| ^~~
hw/core/machine.c:1065:36: note: shadowed declaration is here
1065 | static void machine_initfn(Object *obj)

Quoted 4 lines
        |                            ~~~~~~~~^~~

---

thanks
-- PMM

#3 lore raw

PATCH 2/3 hw/intc/openpic: Clean up local variable shadowing

In reply to Philippe Mathieu-Daudé

Fix:

hw/intc/openpic.c: In function ‘openpic_gbl_write’:
hw/intc/openpic.c:614:17: warning: declaration of ‘idx’ shadows a previous local [-Wshadow=compatible-local]

    614 |             int idx;
        |                 ^~~
  hw/intc/openpic.c:568:9: note: shadowed declaration is here
    568 |     int idx;
        |         ^~~
---
 hw/intc/openpic.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/intc/openpic.c +2 -5
index c757adbe53..a6f91d4bcd 100644
@@ -610,11 +610,8 @@ static void openpic_gbl_write(void *opaque, hwaddr addr, uint64_t val,
     case 0x10B0:
     case 0x10C0:
     case 0x10D0:
-        {
-            int idx;
-            idx = (addr - 0x10A0) >> 4;
-            write_IRQreg_ivpr(opp, opp->irq_ipi0 + idx, val);
-        }
+        idx = (addr - 0x10A0) >> 4;
+        write_IRQreg_ivpr(opp, opp->irq_ipi0 + idx, val);
         break;
     case 0x10E0: /* SPVE */
         opp->spve = val & opp->vector_mask;
Signature · 1 line
2.41.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] hw/intc/openpic: Clean up local variable shadowing

Quoted 5 lines · Philippe Mathieu-Daudé

Fix:

hw/intc/openpic.c: In function ‘openpic_gbl_write’:
hw/intc/openpic.c:614:17: warning: declaration of ‘idx’ shadows a previous local [-Wshadow=compatible-local]

Quoted 8 lines
    614 |             int idx;
        |                 ^~~
  hw/intc/openpic.c:568:9: note: shadowed declaration is here
    568 |     int idx;
        |         ^~~

---

thanks
-- PMM

#5 lore raw

PATCH 3/3 tests/qtest/pflash: Clean up local variable shadowing

In reply to Philippe Mathieu-Daudé

Fix:

tests/qtest/pflash-cfi02-test.c: In function ‘test_geometry’:
tests/qtest/pflash-cfi02-test.c:409:22: warning: declaration of ‘byte_addr’ shadows a previous local [-Wshadow=compatible-local]

    409 |             uint64_t byte_addr = (uint64_t)i * c->sector_len[region];
        |                      ^~~~~~~~~
  tests/qtest/pflash-cfi02-test.c:342:14: note: shadowed declaration is here
    342 |     uint64_t byte_addr = 0;
        |              ^~~~~~~~~
---
 tests/qtest/pflash-cfi02-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/pflash-cfi02-test.c +1 -1
index 0b52c2ca5c..8c073efcb4 100644
@@ -406,7 +406,7 @@ static void test_geometry(const void *opaque)
 
     for (int region = 0; region < nb_erase_regions; ++region) {
         for (uint32_t i = 0; i < c->nb_blocs[region]; ++i) {
-            uint64_t byte_addr = (uint64_t)i * c->sector_len[region];
+            byte_addr = (uint64_t)i * c->sector_len[region];
             g_assert_cmphex(flash_read(c, byte_addr), ==, bank_mask(c));
         }
     }
Signature · 1 line
2.41.0
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] tests/qtest/pflash: Clean up local variable shadowing

Quoted 5 lines · Philippe Mathieu-Daudé

Fix:

tests/qtest/pflash-cfi02-test.c: In function ‘test_geometry’:
tests/qtest/pflash-cfi02-test.c:409:22: warning: declaration of ‘byte_addr’ shadows a previous local [-Wshadow=compatible-local]

Quoted 8 lines
    409 |             uint64_t byte_addr = (uint64_t)i * c->sector_len[region];
        |                      ^~~~~~~~~
  tests/qtest/pflash-cfi02-test.c:342:14: note: shadowed declaration is here
    342 |     uint64_t byte_addr = 0;
        |              ^~~~~~~~~

---

thanks
-- PMM