All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 00/56] -Wshadow=local patches patches for 2023-09-29
@ 2023-09-29  8:49 Markus Armbruster
  2023-09-29  8:49 ` [PULL 01/56] migration/rdma: Fix save_page method to fail on polling error Markus Armbruster
                   ` (56 more replies)
  0 siblings, 57 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha

The following changes since commit 36e9aab3c569d4c9ad780473596e18479838d1aa:

  migration: Move return path cleanup to main migration thread (2023-09-27 13:58:02 -0400)

are available in the Git repository at:

  https://repo.or.cz/qemu/armbru.git tags/pull-shadow-2023-09-29

for you to fetch changes up to 4dba9141f97e66fdd920df37c4aa7b2ffe0d6a4a:

  disas/m68k: clean up local variable shadowing (2023-09-29 10:07:21 +0200)

----------------------------------------------------------------
-Wshadow=local patches patches for 2023-09-29

----------------------------------------------------------------
Alberto Garcia (1):
      test-throttle: don't shadow 'index' variable in do_test_accounting()

Alistair Francis (4):
      hw/riscv: opentitan: Fixup local variables shadowing
      target/riscv: cpu: Fixup local variables shadowing
      target/riscv: vector_helper: Fixup local variables shadowing
      softmmu/device_tree: Fixup local variables shadowing

Ani Sinha (1):
      hw/acpi: changes towards enabling -Wshadow=local

Cédric Le Goater (12):
      hw/ppc: Clean up local variable shadowing in _FDT helper routine
      pnv/psi: Clean up local variable shadowing
      spapr: Clean up local variable shadowing in spapr_dt_cpus()
      spapr: Clean up local variable shadowing in spapr_init_cpus()
      spapr: Clean up local variable shadowing in spapr_get_fw_dev_path()
      spapr/drc: Clean up local variable shadowing in rtas_ibm_configure_connector()
      spapr/pci: Clean up local variable shadowing in spapr_phb_realize()
      spapr/drc: Clean up local variable shadowing in prop_get_fdt()
      aspeed/i2c: Clean up local variable shadowing
      aspeed: Clean up local variable shadowing
      aspeed/i3c: Rename variable shadowing a local
      aspeed/timer: Clean up local variable shadowing

Daniel P. Berrangé (2):
      crypto: remove shadowed 'ret' variable
      seccomp: avoid shadowing of 'action' variable

Eric Blake (1):
      qemu-nbd: changes towards enabling -Wshadow=local

Klaus Jensen (1):
      hw/nvme: Clean up local variable shadowing in nvme_ns_init()

Laurent Vivier (1):
      disas/m68k: clean up local variable shadowing

Markus Armbruster (7):
      migration/rdma: Fix save_page method to fail on polling error
      migration: Clean up local variable shadowing
      ui: Clean up local variable shadowing
      block/dirty-bitmap: Clean up local variable shadowing
      block/vdi: Clean up local variable shadowing
      block: Clean up local variable shadowing
      qobject atomics osdep: Make a few macros more hygienic

Peter Maydell (4):
      hw/intc/arm_gicv3_its: Avoid shadowing variable in do_process_its_cmd()
      hw/misc/arm_sysctl.c: Avoid shadowing local variable
      hw/arm/smmuv3.c: Avoid shadowing variable
      hw/arm/smmuv3-internal.h: Don't use locals in statement macros

Peter Xu (1):
      intel_iommu: Fix shadow local variables on "size"

Philippe Mathieu-Daudé (21):
      tcg: Clean up local variable shadowing
      target/arm/tcg: Clean up local variable shadowing
      target/arm/hvf: Clean up local variable shadowing
      target/mips: Clean up local variable shadowing
      target/m68k: Clean up local variable shadowing
      target/tricore: Clean up local variable shadowing
      hw/arm/armv7m: Clean up local variable shadowing
      hw/arm/virt: Clean up local variable shadowing
      hw/arm/allwinner: Clean up local variable shadowing
      hw/m68k: Clean up local variable shadowing
      hw/microblaze: Clean up local variable shadowing
      hw/nios2: Clean up local variable shadowing
      net/eth: Clean up local variable shadowing
      crypto/cipher-gnutls.c: Clean up local variable shadowing
      util/vhost-user-server: Clean up local variable shadowing
      linux-user/strace: Clean up local variable shadowing
      sysemu/device_tree: Clean up local variable shadowing
      softmmu/memory: Clean up local variable shadowing
      softmmu/physmem: Clean up local variable shadowing
      hw/core/machine: Clean up local variable shadowing
      hw/intc/openpic: Clean up local variable shadowing

 hw/arm/smmuv3-internal.h                 | 41 ++++++++++---------------------
 hw/m68k/bootinfo.h                       | 10 +++-----
 include/hw/ppc/fdt.h                     |  8 +++---
 include/qapi/qmp/qobject.h               | 10 ++++++--
 include/qemu/atomic.h                    | 17 +++++++++----
 include/qemu/compiler.h                  |  3 +++
 include/qemu/osdep.h                     | 27 ++++++++++++++------
 include/sysemu/device_tree.h             |  6 ++---
 accel/tcg/tb-maint.c                     |  3 +--
 block.c                                  |  9 ++++---
 block/monitor/bitmap-qmp-cmds.c          | 19 ++++++++-------
 block/qcow2-bitmap.c                     |  3 +--
 block/rbd.c                              |  2 +-
 block/stream.c                           |  1 -
 block/vdi.c                              |  7 +++---
 block/vvfat.c                            | 35 +++++++++++++-------------
 crypto/tls-cipher-suites.c               |  1 -
 disas/m68k.c                             |  8 +++---
 hw/acpi/cpu_hotplug.c                    | 25 ++++++++++---------
 hw/arm/allwinner-r40.c                   |  7 +++---
 hw/arm/armsse.c                          | 16 +++++-------
 hw/arm/armv7m.c                          |  2 +-
 hw/arm/aspeed_ast2600.c                  | 10 ++++----
 hw/arm/smmuv3.c                          |  4 +--
 hw/arm/virt.c                            |  3 +--
 hw/block/xen-block.c                     |  6 ++---
 hw/core/machine.c                        |  2 --
 hw/i2c/aspeed_i2c.c                      |  1 -
 hw/i386/acpi-build.c                     | 24 +++++++++---------
 hw/i386/intel_iommu.c                    |  8 +++---
 hw/intc/arm_gicv3_its.c                  |  6 ++---
 hw/intc/openpic.c                        |  7 ++----
 hw/microblaze/petalogix_ml605_mmu.c      |  2 +-
 hw/misc/arm_sysctl.c                     |  6 ++---
 hw/misc/aspeed_i3c.c                     |  6 ++---
 hw/nios2/10m50_devboard.c                |  4 +--
 hw/nvme/ns.c                             |  4 +--
 hw/ppc/pnv_psi.c                         |  5 ++--
 hw/ppc/spapr.c                           | 42 +++++++++++++++++---------------
 hw/ppc/spapr_drc.c                       | 12 ++++-----
 hw/ppc/spapr_pci.c                       |  6 ++---
 hw/riscv/opentitan.c                     |  2 +-
 hw/smbios/smbios.c                       | 37 ++++++++++++++--------------
 hw/timer/aspeed_timer.c                  |  2 +-
 linux-user/strace.c                      |  1 -
 migration/block.c                        |  4 +--
 migration/ram.c                          |  8 +++---
 migration/rdma.c                         | 14 +++++++----
 migration/vmstate.c                      |  2 +-
 net/eth.c                                |  2 --
 qemu-nbd.c                               |  9 +++----
 softmmu/device_tree.c                    |  6 ++---
 softmmu/memory.c                         |  1 -
 softmmu/physmem.c                        | 10 ++++----
 softmmu/qemu-seccomp.c                   |  4 +--
 target/arm/hvf/hvf.c                     |  8 +++---
 target/arm/tcg/mve_helper.c              | 16 ++++++------
 target/arm/tcg/translate-m-nocp.c        |  2 +-
 target/m68k/translate.c                  |  2 +-
 target/mips/tcg/msa_helper.c             |  8 +++---
 target/mips/tcg/translate.c              |  8 +++---
 target/riscv/cpu.c                       |  4 +--
 target/riscv/vector_helper.c             |  7 +++---
 target/tricore/translate.c               |  6 ++---
 tcg/tcg.c                                | 16 ++++++------
 tests/unit/test-throttle.c               |  2 +-
 ui/gtk.c                                 | 14 +++++------
 ui/spice-display.c                       |  9 ++++---
 ui/vnc-palette.c                         |  2 --
 ui/vnc.c                                 | 12 ++++-----
 util/vhost-user-server.c                 |  2 +-
 crypto/cipher-gnutls.c.inc               |  4 +--
 target/mips/tcg/nanomips_translate.c.inc |  6 ++---
 ui/vnc-enc-zrle.c.inc                    |  9 +++----
 74 files changed, 326 insertions(+), 331 deletions(-)

-- 
2.41.0



^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PULL 01/56] migration/rdma: Fix save_page method to fail on polling error
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
@ 2023-09-29  8:49 ` Markus Armbruster
  2023-09-29  8:49 ` [PULL 02/56] migration: Clean up local variable shadowing Markus Armbruster
                   ` (55 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Eric Blake, Peter Xu, Li Zhijian

qemu_rdma_save_page() reports polling error with error_report(), then
succeeds anyway.  This is because the variable holding the polling
status *shadows* the variable the function returns.  The latter
remains zero.

Broken since day one, and duplicated more recently.

Fixes: 2da776db4846 (rdma: core logic)
Fixes: b390afd8c50b (migration/rdma: Fix out of order wrid)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
Message-ID: <20230921121312.1301864-2-armbru@redhat.com>
---
 migration/rdma.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index a2a3db35b1..3915d1d7c9 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -3282,7 +3282,8 @@ static size_t qemu_rdma_save_page(QEMUFile *f,
      */
     while (1) {
         uint64_t wr_id, wr_id_in;
-        int ret = qemu_rdma_poll(rdma, rdma->recv_cq, &wr_id_in, NULL);
+        ret = qemu_rdma_poll(rdma, rdma->recv_cq, &wr_id_in, NULL);
+
         if (ret < 0) {
             error_report("rdma migration: polling error! %d", ret);
             goto err;
@@ -3297,7 +3298,8 @@ static size_t qemu_rdma_save_page(QEMUFile *f,
 
     while (1) {
         uint64_t wr_id, wr_id_in;
-        int ret = qemu_rdma_poll(rdma, rdma->send_cq, &wr_id_in, NULL);
+        ret = qemu_rdma_poll(rdma, rdma->send_cq, &wr_id_in, NULL);
+
         if (ret < 0) {
             error_report("rdma migration: polling error! %d", ret);
             goto err;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 02/56] migration: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
  2023-09-29  8:49 ` [PULL 01/56] migration/rdma: Fix save_page method to fail on polling error Markus Armbruster
@ 2023-09-29  8:49 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 03/56] ui: " Markus Armbruster
                   ` (54 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Peter Xu, Li Zhijian

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Tracked down with -Wshadow=local.
Clean up: delete inner declarations when they are actually redundant,
else rename variables.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
Message-ID: <20230921121312.1301864-3-armbru@redhat.com>
---
 migration/block.c   | 4 ++--
 migration/ram.c     | 8 +++-----
 migration/rdma.c    | 8 +++++---
 migration/vmstate.c | 2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/migration/block.c b/migration/block.c
index 86c2256a2b..eb6aafeb9e 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -440,8 +440,8 @@ static int init_blk_migration(QEMUFile *f)
     /* Can only insert new BDSes now because doing so while iterating block
      * devices may end up in a deadlock (iterating the new BDSes, too). */
     for (i = 0; i < num_bs; i++) {
-        BlkMigDevState *bmds = bmds_bs[i].bmds;
-        BlockDriverState *bs = bmds_bs[i].bs;
+        bmds = bmds_bs[i].bmds;
+        bs = bmds_bs[i].bs;
 
         if (bmds) {
             ret = blk_insert_bs(bmds->blk, bs, &local_err);
diff --git a/migration/ram.c b/migration/ram.c
index 9040d66e61..0c202f8109 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -3517,8 +3517,6 @@ int colo_init_ram_cache(void)
     * we use the same name 'ram_bitmap' as for migration.
     */
     if (ram_bytes_total()) {
-        RAMBlock *block;
-
         RAMBLOCK_FOREACH_NOT_IGNORED(block) {
             unsigned long pages = block->max_length >> TARGET_PAGE_BITS;
             block->bmap = bitmap_new(pages);
@@ -3998,12 +3996,12 @@ static int ram_load_precopy(QEMUFile *f)
                         }
                     }
                     if (migrate_ignore_shared()) {
-                        hwaddr addr = qemu_get_be64(f);
+                        hwaddr addr2 = qemu_get_be64(f);
                         if (migrate_ram_is_ignored(block) &&
-                            block->mr->addr != addr) {
+                            block->mr->addr != addr2) {
                             error_report("Mismatched GPAs for block %s "
                                          "%" PRId64 "!= %" PRId64,
-                                         id, (uint64_t)addr,
+                                         id, (uint64_t)addr2,
                                          (uint64_t)block->mr->addr);
                             ret = -EINVAL;
                         }
diff --git a/migration/rdma.c b/migration/rdma.c
index 3915d1d7c9..c78ddfcb74 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -1902,9 +1902,11 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,
      * by waiting for a READY message.
      */
     if (rdma->control_ready_expected) {
-        RDMAControlHeader resp;
-        ret = qemu_rdma_exchange_get_response(rdma,
-                                    &resp, RDMA_CONTROL_READY, RDMA_WRID_READY);
+        RDMAControlHeader resp_ignored;
+
+        ret = qemu_rdma_exchange_get_response(rdma, &resp_ignored,
+                                              RDMA_CONTROL_READY,
+                                              RDMA_WRID_READY);
         if (ret < 0) {
             return ret;
         }
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 31842c3afb..438ea77cfa 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -97,7 +97,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
         return -EINVAL;
     }
     if (vmsd->pre_load) {
-        int ret = vmsd->pre_load(opaque);
+        ret = vmsd->pre_load(opaque);
         if (ret) {
             return ret;
         }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 03/56] ui: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
  2023-09-29  8:49 ` [PULL 01/56] migration/rdma: Fix save_page method to fail on polling error Markus Armbruster
  2023-09-29  8:49 ` [PULL 02/56] migration: Clean up local variable shadowing Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 04/56] block/dirty-bitmap: " Markus Armbruster
                   ` (53 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Peter Maydell

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Tracked down with -Wshadow=local.
Clean up: delete inner declarations when they are actually redundant,
else rename variables.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230921121312.1301864-4-armbru@redhat.com>
---
 ui/gtk.c              | 14 +++++++-------
 ui/spice-display.c    |  9 +++++----
 ui/vnc-palette.c      |  2 --
 ui/vnc.c              | 12 ++++++------
 ui/vnc-enc-zrle.c.inc |  9 ++++-----
 5 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index e09f97a86b..3373427c9b 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -930,8 +930,8 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
         GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
         GdkRectangle geometry;
 
-        int x = (int)motion->x_root;
-        int y = (int)motion->y_root;
+        int xr = (int)motion->x_root;
+        int yr = (int)motion->y_root;
 
         gdk_monitor_get_geometry(monitor, &geometry);
 
@@ -942,13 +942,13 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
          * may still be only half way across the screen. Without
          * this warp, the server pointer would thus appear to hit
          * an invisible wall */
-        if (x <= geometry.x || x - geometry.x >= geometry.width - 1 ||
-            y <= geometry.y || y - geometry.y >= geometry.height - 1) {
+        if (xr <= geometry.x || xr - geometry.x >= geometry.width - 1 ||
+            yr <= geometry.y || yr - geometry.y >= geometry.height - 1) {
             GdkDevice *dev = gdk_event_get_device((GdkEvent *)motion);
-            x = geometry.x + geometry.width / 2;
-            y = geometry.y + geometry.height / 2;
+            xr = geometry.x + geometry.width / 2;
+            yr = geometry.y + geometry.height / 2;
 
-            gdk_device_warp(dev, screen, x, y);
+            gdk_device_warp(dev, screen, xr, yr);
             s->last_set = FALSE;
             return FALSE;
         }
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 5cc47bd668..6eb98a5a5c 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -1081,15 +1081,16 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl,
     }
 
     if (render_cursor) {
-        int x, y;
+        int ptr_x, ptr_y;
+
         qemu_mutex_lock(&ssd->lock);
-        x = ssd->ptr_x;
-        y = ssd->ptr_y;
+        ptr_x = ssd->ptr_x;
+        ptr_y = ssd->ptr_y;
         qemu_mutex_unlock(&ssd->lock);
         egl_texture_blit(ssd->gls, &ssd->blit_fb, &ssd->guest_fb,
                          !y_0_top);
         egl_texture_blend(ssd->gls, &ssd->blit_fb, &ssd->cursor_fb,
-                          !y_0_top, x, y, 1.0, 1.0);
+                          !y_0_top, ptr_x, ptr_y, 1.0, 1.0);
         glFlush();
     }
 
diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c
index dc7c0ba997..4e88c412f0 100644
--- a/ui/vnc-palette.c
+++ b/ui/vnc-palette.c
@@ -86,8 +86,6 @@ int palette_put(VncPalette *palette, uint32_t color)
         return 0;
     }
     if (!entry) {
-        VncPaletteEntry *entry;
-
         entry = &palette->pool[palette->size];
         entry->color = color;
         entry->idx = idx;
diff --git a/ui/vnc.c b/ui/vnc.c
index c302bb07a5..523eb1f5b0 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1584,15 +1584,15 @@ static void vnc_jobs_bh(void *opaque)
  */
 static int vnc_client_read(VncState *vs)
 {
-    size_t ret;
+    size_t sz;
 
 #ifdef CONFIG_VNC_SASL
     if (vs->sasl.conn && vs->sasl.runSSF)
-        ret = vnc_client_read_sasl(vs);
+        sz = vnc_client_read_sasl(vs);
     else
 #endif /* CONFIG_VNC_SASL */
-        ret = vnc_client_read_plain(vs);
-    if (!ret) {
+        sz = vnc_client_read_plain(vs);
+    if (!sz) {
         if (vs->disconnecting) {
             vnc_disconnect_finish(vs);
             return -1;
@@ -3118,8 +3118,8 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
     cmp_bytes = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES,
                     server_stride);
     if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
-        int width = pixman_image_get_width(vd->server);
-        tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width);
+        int w = pixman_image_get_width(vd->server);
+        tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, w);
     } else {
         int guest_bpp =
             PIXMAN_FORMAT_BPP(pixman_image_get_format(vd->guest.fb));
diff --git a/ui/vnc-enc-zrle.c.inc b/ui/vnc-enc-zrle.c.inc
index a8ca37d05e..2ef7501d52 100644
--- a/ui/vnc-enc-zrle.c.inc
+++ b/ui/vnc-enc-zrle.c.inc
@@ -153,11 +153,12 @@ static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h,
     }
 
     if (use_rle) {
-        ZRLE_PIXEL *ptr = data;
-        ZRLE_PIXEL *end = ptr + w * h;
         ZRLE_PIXEL *run_start;
         ZRLE_PIXEL pix;
 
+        ptr = data;
+        end = ptr + w * h;
+
         while (ptr < end) {
             int len;
             int index = 0;
@@ -198,7 +199,7 @@ static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h,
         }
     } else if (use_palette) { /* no RLE */
         int bppp;
-        ZRLE_PIXEL *ptr = data;
+        ptr = data;
 
         /* packed pixels */
 
@@ -241,8 +242,6 @@ static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h,
 #endif
         {
 #ifdef ZRLE_COMPACT_PIXEL
-            ZRLE_PIXEL *ptr;
-
             for (ptr = data; ptr < data + w * h; ptr++) {
                 ZRLE_WRITE_PIXEL(vs, *ptr);
             }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 04/56] block/dirty-bitmap: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (2 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 03/56] ui: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 05/56] block/vdi: " Markus Armbruster
                   ` (52 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Kevin Wolf

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Tracked down with -Wshadow=local.
Clean up: rename both the pair of parameters and the pair of local
variables.  While there, move the local variables to function scope.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230921121312.1301864-5-armbru@redhat.com>
---
 block/monitor/bitmap-qmp-cmds.c | 19 ++++++++++---------
 block/qcow2-bitmap.c            |  3 +--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/block/monitor/bitmap-qmp-cmds.c b/block/monitor/bitmap-qmp-cmds.c
index 55f778f5af..70d01a3776 100644
--- a/block/monitor/bitmap-qmp-cmds.c
+++ b/block/monitor/bitmap-qmp-cmds.c
@@ -258,37 +258,38 @@ void qmp_block_dirty_bitmap_disable(const char *node, const char *name,
     bdrv_disable_dirty_bitmap(bitmap);
 }
 
-BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target,
+BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *dst_node,
+                                          const char *dst_bitmap,
                                           BlockDirtyBitmapOrStrList *bms,
                                           HBitmap **backup, Error **errp)
 {
     BlockDriverState *bs;
     BdrvDirtyBitmap *dst, *src;
     BlockDirtyBitmapOrStrList *lst;
+    const char *src_node, *src_bitmap;
     HBitmap *local_backup = NULL;
 
     GLOBAL_STATE_CODE();
 
-    dst = block_dirty_bitmap_lookup(node, target, &bs, errp);
+    dst = block_dirty_bitmap_lookup(dst_node, dst_bitmap, &bs, errp);
     if (!dst) {
         return NULL;
     }
 
     for (lst = bms; lst; lst = lst->next) {
         switch (lst->value->type) {
-            const char *name, *node;
         case QTYPE_QSTRING:
-            name = lst->value->u.local;
-            src = bdrv_find_dirty_bitmap(bs, name);
+            src_bitmap = lst->value->u.local;
+            src = bdrv_find_dirty_bitmap(bs, src_bitmap);
             if (!src) {
-                error_setg(errp, "Dirty bitmap '%s' not found", name);
+                error_setg(errp, "Dirty bitmap '%s' not found", src_bitmap);
                 goto fail;
             }
             break;
         case QTYPE_QDICT:
-            node = lst->value->u.external.node;
-            name = lst->value->u.external.name;
-            src = block_dirty_bitmap_lookup(node, name, NULL, errp);
+            src_node = lst->value->u.external.node;
+            src_bitmap = lst->value->u.external.name;
+            src = block_dirty_bitmap_lookup(src_node, src_bitmap, NULL, errp);
             if (!src) {
                 goto fail;
             }
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 037fa2d435..ffd5cd3b23 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1555,7 +1555,6 @@ bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
     FOR_EACH_DIRTY_BITMAP(bs, bitmap) {
         const char *name = bdrv_dirty_bitmap_name(bitmap);
         uint32_t granularity = bdrv_dirty_bitmap_granularity(bitmap);
-        Qcow2Bitmap *bm;
 
         if (!bdrv_dirty_bitmap_get_persistence(bitmap) ||
             bdrv_dirty_bitmap_inconsistent(bitmap)) {
@@ -1625,7 +1624,7 @@ bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
 
     /* allocate clusters and store bitmaps */
     QSIMPLEQ_FOREACH(bm, bm_list, entry) {
-        BdrvDirtyBitmap *bitmap = bm->dirty_bitmap;
+        bitmap = bm->dirty_bitmap;
 
         if (bitmap == NULL || bdrv_dirty_bitmap_readonly(bitmap)) {
             continue;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 05/56] block/vdi: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (3 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 04/56] block/dirty-bitmap: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 06/56] block: " Markus Armbruster
                   ` (51 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Kevin Wolf

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Tracked down with -Wshadow=local.
Clean up: delete inner declarations when they are actually redundant,
else rename variables.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230921121312.1301864-6-armbru@redhat.com>
---
 block/vdi.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 6c35309e04..934e1b849b 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -634,7 +634,6 @@ vdi_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
         bmap_entry = le32_to_cpu(s->bmap[block_index]);
         if (!VDI_IS_ALLOCATED(bmap_entry)) {
             /* Allocate new block and write to it. */
-            uint64_t data_offset;
             qemu_co_rwlock_upgrade(&s->bmap_lock);
             bmap_entry = le32_to_cpu(s->bmap[block_index]);
             if (VDI_IS_ALLOCATED(bmap_entry)) {
@@ -700,7 +699,7 @@ nonallocating_write:
         /* One or more new blocks were allocated. */
         VdiHeader *header;
         uint8_t *base;
-        uint64_t offset;
+        uint64_t bmap_offset;
         uint32_t n_sectors;
 
         g_free(block);
@@ -723,11 +722,11 @@ nonallocating_write:
         bmap_first /= (SECTOR_SIZE / sizeof(uint32_t));
         bmap_last /= (SECTOR_SIZE / sizeof(uint32_t));
         n_sectors = bmap_last - bmap_first + 1;
-        offset = s->bmap_sector + bmap_first;
+        bmap_offset = s->bmap_sector + bmap_first;
         base = ((uint8_t *)&s->bmap[0]) + bmap_first * SECTOR_SIZE;
         logout("will write %u block map sectors starting from entry %u\n",
                n_sectors, bmap_first);
-        ret = bdrv_co_pwrite(bs->file, offset * SECTOR_SIZE,
+        ret = bdrv_co_pwrite(bs->file, bmap_offset * SECTOR_SIZE,
                              n_sectors * SECTOR_SIZE, base, 0);
     }
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 06/56] block: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (4 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 05/56] block/vdi: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 07/56] qobject atomics osdep: Make a few macros more hygienic Markus Armbruster
                   ` (50 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Anthony PERARD, Ilya Dryomov, Kevin Wolf

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Tracked down with -Wshadow=local.
Clean up: delete inner declarations when they are actually redundant,
else rename variables.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230921121312.1301864-7-armbru@redhat.com>
---
 block.c              |  9 +++++----
 block/rbd.c          |  2 +-
 block/stream.c       |  1 -
 block/vvfat.c        | 35 ++++++++++++++++++-----------------
 hw/block/xen-block.c |  6 +++---
 5 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/block.c b/block.c
index e7f349b25c..af04c8ac6f 100644
--- a/block.c
+++ b/block.c
@@ -3072,18 +3072,19 @@ bdrv_attach_child_common(BlockDriverState *child_bs,
                                               &local_err);
 
         if (ret < 0 && child_class->change_aio_ctx) {
-            Transaction *tran = tran_new();
+            Transaction *aio_ctx_tran = tran_new();
             GHashTable *visited = g_hash_table_new(NULL, NULL);
             bool ret_child;
 
             g_hash_table_add(visited, new_child);
             ret_child = child_class->change_aio_ctx(new_child, child_ctx,
-                                                    visited, tran, NULL);
+                                                    visited, aio_ctx_tran,
+                                                    NULL);
             if (ret_child == true) {
                 error_free(local_err);
                 ret = 0;
             }
-            tran_finalize(tran, ret_child == true ? 0 : -1);
+            tran_finalize(aio_ctx_tran, ret_child == true ? 0 : -1);
             g_hash_table_destroy(visited);
         }
 
@@ -6208,12 +6209,12 @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
     QLIST_FOREACH(drv, &bdrv_drivers, list) {
         if (drv->format_name) {
             bool found = false;
-            int i = count;
 
             if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, read_only)) {
                 continue;
             }
 
+            i = count;
             while (formats && i && !found) {
                 found = !strcmp(formats[--i], drv->format_name);
             }
diff --git a/block/rbd.c b/block/rbd.c
index 978671411e..472ca05cba 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -1290,7 +1290,7 @@ static int coroutine_fn qemu_rbd_start_co(BlockDriverState *bs,
          * operations that exceed the current size.
          */
         if (offset + bytes > s->image_size) {
-            int r = qemu_rbd_resize(bs, offset + bytes);
+            r = qemu_rbd_resize(bs, offset + bytes);
             if (r < 0) {
                 return r;
             }
diff --git a/block/stream.c b/block/stream.c
index e4da214f1f..133cb72fb4 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -292,7 +292,6 @@ void stream_start(const char *job_id, BlockDriverState *bs,
     /* Make sure that the image is opened in read-write mode */
     bs_read_only = bdrv_is_read_only(bs);
     if (bs_read_only) {
-        int ret;
         /* Hold the chain during reopen */
         if (bdrv_freeze_backing_chain(bs, above_base, errp) < 0) {
             return;
diff --git a/block/vvfat.c b/block/vvfat.c
index 0ddc91fc09..856b479c91 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -777,7 +777,6 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
     while((entry=readdir(dir))) {
         unsigned int length=strlen(dirname)+2+strlen(entry->d_name);
         char* buffer;
-        direntry_t* direntry;
         struct stat st;
         int is_dot=!strcmp(entry->d_name,".");
         int is_dotdot=!strcmp(entry->d_name,"..");
@@ -857,7 +856,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
 
     /* fill with zeroes up to the end of the cluster */
     while(s->directory.next%(0x10*s->sectors_per_cluster)) {
-        direntry_t* direntry=array_get_next(&(s->directory));
+        direntry = array_get_next(&(s->directory));
         memset(direntry,0,sizeof(direntry_t));
     }
 
@@ -1962,24 +1961,24 @@ get_cluster_count_for_direntry(BDRVVVFATState* s, direntry_t* direntry, const ch
                  * This is horribly inefficient, but that is okay, since
                  * it is rarely executed, if at all.
                  */
-                int64_t offset = cluster2sector(s, cluster_num);
+                int64_t offs = cluster2sector(s, cluster_num);
 
                 vvfat_close_current_file(s);
                 for (i = 0; i < s->sectors_per_cluster; i++) {
                     int res;
 
                     res = bdrv_is_allocated(s->qcow->bs,
-                                            (offset + i) * BDRV_SECTOR_SIZE,
+                                            (offs + i) * BDRV_SECTOR_SIZE,
                                             BDRV_SECTOR_SIZE, NULL);
                     if (res < 0) {
                         return -1;
                     }
                     if (!res) {
-                        res = vvfat_read(s->bs, offset, s->cluster_buffer, 1);
+                        res = vvfat_read(s->bs, offs, s->cluster_buffer, 1);
                         if (res) {
                             return -1;
                         }
-                        res = bdrv_co_pwrite(s->qcow, offset * BDRV_SECTOR_SIZE,
+                        res = bdrv_co_pwrite(s->qcow, offs * BDRV_SECTOR_SIZE,
                                              BDRV_SECTOR_SIZE, s->cluster_buffer,
                                              0);
                         if (res < 0) {
@@ -2467,8 +2466,9 @@ commit_direntries(BDRVVVFATState* s, int dir_index, int parent_mapping_index)
 
     for (c = first_cluster; !fat_eof(s, c); c = modified_fat_get(s, c)) {
         direntry_t *first_direntry;
-        void* direntry = array_get(&(s->directory), current_dir_index);
-        int ret = vvfat_read(s->bs, cluster2sector(s, c), direntry,
+
+        direntry = array_get(&(s->directory), current_dir_index);
+        ret = vvfat_read(s->bs, cluster2sector(s, c), (uint8_t *)direntry,
                 s->sectors_per_cluster);
         if (ret)
             return ret;
@@ -2690,12 +2690,12 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s)
                 direntry_t* direntry = array_get(&(s->directory),
                         mapping->info.dir.first_dir_index);
                 uint32_t c = mapping->begin;
-                int i = 0;
+                int j = 0;
 
                 /* recurse */
                 while (!fat_eof(s, c)) {
                     do {
-                        direntry_t* d = direntry + i;
+                        direntry_t *d = direntry + j;
 
                         if (is_file(d) || (is_directory(d) && !is_dot(d))) {
                             int l;
@@ -2716,8 +2716,8 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s)
 
                             schedule_rename(s, m->begin, new_path);
                         }
-                        i++;
-                    } while((i % (0x10 * s->sectors_per_cluster)) != 0);
+                        j++;
+                    } while (j % (0x10 * s->sectors_per_cluster) != 0);
                     c = fat_get(s, c);
                 }
             }
@@ -2804,16 +2804,16 @@ static int coroutine_fn GRAPH_RDLOCK handle_commits(BDRVVVFATState* s)
             int begin = commit->param.new_file.first_cluster;
             mapping_t* mapping = find_mapping_for_cluster(s, begin);
             direntry_t* entry;
-            int i;
+            int j;
 
             /* find direntry */
-            for (i = 0; i < s->directory.next; i++) {
-                entry = array_get(&(s->directory), i);
+            for (j = 0; j < s->directory.next; j++) {
+                entry = array_get(&(s->directory), j);
                 if (is_file(entry) && begin_of_direntry(entry) == begin)
                     break;
             }
 
-            if (i >= s->directory.next) {
+            if (j >= s->directory.next) {
                 fail = -6;
                 continue;
             }
@@ -2833,8 +2833,9 @@ static int coroutine_fn GRAPH_RDLOCK handle_commits(BDRVVVFATState* s)
             mapping->mode = MODE_NORMAL;
             mapping->info.file.offset = 0;
 
-            if (commit_one_file(s, i, 0))
+            if (commit_one_file(s, j, 0)) {
                 fail = -7;
+            }
 
             break;
         }
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 3906b9058b..a07cd7eb5d 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -369,7 +369,7 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
     case XEN_BLOCK_VDEV_TYPE_XVD:
     case XEN_BLOCK_VDEV_TYPE_HD:
     case XEN_BLOCK_VDEV_TYPE_SD: {
-        char *name = disk_to_vbd_name(vdev->disk);
+        char *vbd_name = disk_to_vbd_name(vdev->disk);
 
         str = g_strdup_printf("%s%s%lu",
                               (vdev->type == XEN_BLOCK_VDEV_TYPE_XVD) ?
@@ -377,8 +377,8 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,
                               (vdev->type == XEN_BLOCK_VDEV_TYPE_HD) ?
                               "hd" :
                               "sd",
-                              name, vdev->partition);
-        g_free(name);
+                              vbd_name, vdev->partition);
+        g_free(vbd_name);
         break;
     }
     default:
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 07/56] qobject atomics osdep: Make a few macros more hygienic
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (5 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 06/56] block: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 08/56] tcg: Clean up local variable shadowing Markus Armbruster
                   ` (49 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Eric Blake, Philippe Mathieu-Daudé

Variables declared in macros can shadow other variables.  Much of the
time, this is harmless, e.g.:

    #define _FDT(exp)                                                  \
        do {                                                           \
            int ret = (exp);                                           \
            if (ret < 0) {                                             \
                error_report("error creating device tree: %s: %s",   \
                        #exp, fdt_strerror(ret));                      \
                exit(1);                                               \
            }                                                          \
        } while (0)

Harmless shadowing in h_client_architecture_support():

        target_ulong ret;

        [...]

        ret = do_client_architecture_support(cpu, spapr, vec, fdt_bufsize);
        if (ret == H_SUCCESS) {
            _FDT((fdt_pack(spapr->fdt_blob)));
            [...]
        }

        return ret;

However, we can get in trouble when the shadowed variable is used in a
macro argument:

    #define QOBJECT(obj) ({                                 \
        typeof(obj) o = (obj);                              \
        o ? container_of(&(o)->base, QObject, base) : NULL; \
     })

QOBJECT(o) expands into

    ({
--->    typeof(o) o = (o);
        o ? container_of(&(o)->base, QObject, base) : NULL;
    })

Unintended variable name capture at --->.  We'd be saved by
-Winit-self.  But I could certainly construct more elaborate death
traps that don't trigger it.

To reduce the risk of trapping ourselves, we use variable names in
macros that no sane person would use elsewhere.  Here's our actual
definition of QOBJECT():

    #define QOBJECT(obj) ({                                         \
        typeof(obj) _obj = (obj);                                   \
        _obj ? container_of(&(_obj)->base, QObject, base) : NULL;   \
    })

Works well enough until we nest macro calls.  For instance, with

    #define qobject_ref(obj) ({                     \
        typeof(obj) _obj = (obj);                   \
        qobject_ref_impl(QOBJECT(_obj));            \
        _obj;                                       \
    })

the expression qobject_ref(obj) expands into

    ({
        typeof(obj) _obj = (obj);
        qobject_ref_impl(
            ({
--->            typeof(_obj) _obj = (_obj);
                _obj ? container_of(&(_obj)->base, QObject, base) : NULL;
            }));
        _obj;
    })

Unintended variable name capture at --->.

The only reliable way to prevent unintended variable name capture is
-Wshadow.

One blocker for enabling it is shadowing hiding in function-like
macros like

     qdict_put(dict, "name", qobject_ref(...))

qdict_put() wraps its last argument in QOBJECT(), and the last
argument here contains another QOBJECT().

Use dark preprocessor sorcery to make the macros that give us this
problem use different variable names on every call.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20230921121312.1301864-8-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/qapi/qmp/qobject.h | 10 ++++++++--
 include/qemu/atomic.h      | 17 ++++++++++++-----
 include/qemu/compiler.h    |  3 +++
 include/qemu/osdep.h       | 27 ++++++++++++++++++++-------
 4 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index 9003b71fd3..89b97d88bc 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -45,10 +45,16 @@ struct QObject {
     struct QObjectBase_ base;
 };
 
-#define QOBJECT(obj) ({                                         \
+/*
+ * Preprocessor sorcery ahead: use a different identifier for the
+ * local variable in each expansion, so we can nest macro calls
+ * without shadowing variables.
+ */
+#define QOBJECT_INTERNAL(obj, _obj) ({                          \
     typeof(obj) _obj = (obj);                                   \
-    _obj ? container_of(&(_obj)->base, QObject, base) : NULL;   \
+    _obj ? container_of(&_obj->base, QObject, base) : NULL;     \
 })
+#define QOBJECT(obj) QOBJECT_INTERNAL((obj), MAKE_IDENTFIER(_obj))
 
 /* Required for qobject_to() */
 #define QTYPE_CAST_TO_QNull     QTYPE_QNULL
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index d95612f7a0..f1d3d1702a 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -157,13 +157,20 @@
     smp_read_barrier_depends();
 #endif
 
-#define qatomic_rcu_read(ptr)                          \
-    ({                                                 \
+/*
+ * Preprocessor sorcery ahead: use a different identifier for the
+ * local variable in each expansion, so we can nest macro calls
+ * without shadowing variables.
+ */
+#define qatomic_rcu_read_internal(ptr, _val)            \
+    ({                                                  \
     qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \
-    typeof_strip_qual(*ptr) _val;                      \
-    qatomic_rcu_read__nocheck(ptr, &_val);             \
-    _val;                                              \
+    typeof_strip_qual(*ptr) _val;                       \
+    qatomic_rcu_read__nocheck(ptr, &_val);              \
+    _val;                                               \
     })
+#define qatomic_rcu_read(ptr) \
+    qatomic_rcu_read_internal((ptr), MAKE_IDENTFIER(_val))
 
 #define qatomic_rcu_set(ptr, i) do {                   \
     qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 7fda29b445..7f1bbbf05f 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -37,6 +37,9 @@
 #define tostring(s) #s
 #endif
 
+/* Expands into an identifier stemN, where N is another number each time */
+#define MAKE_IDENTFIER(stem) glue(stem, __COUNTER__)
+
 #ifndef likely
 #define likely(x)   __builtin_expect(!!(x), 1)
 #define unlikely(x)   __builtin_expect(!!(x), 0)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index e4a4eb2d61..18b940db75 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -383,19 +383,28 @@ void QEMU_ERROR("code path is reachable")
  * determined by the pre-processor instead of the compiler, you'll
  * have to open-code it.  Sadly, Coverity is severely confused by the
  * constant variants, so we have to dumb things down there.
+ *
+ * Preprocessor sorcery ahead: use different identifiers for the local
+ * variables in each expansion, so we can nest macro calls without
+ * shadowing variables.
  */
-#undef MIN
-#define MIN(a, b)                                       \
+#define MIN_INTERNAL(a, b, _a, _b)                      \
     ({                                                  \
         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
         _a < _b ? _a : _b;                              \
     })
-#undef MAX
-#define MAX(a, b)                                       \
+#undef MIN
+#define MIN(a, b) \
+    MIN_INTERNAL((a), (b), MAKE_IDENTFIER(_a), MAKE_IDENTFIER(_b))
+
+#define MAX_INTERNAL(a, b, _a, _b)                      \
     ({                                                  \
         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
         _a > _b ? _a : _b;                              \
     })
+#undef MAX
+#define MAX(a, b) \
+    MAX_INTERNAL((a), (b), MAKE_IDENTFIER(_a), MAKE_IDENTFIER(_b))
 
 #ifdef __COVERITY__
 # define MIN_CONST(a, b) ((a) < (b) ? (a) : (b))
@@ -416,14 +425,18 @@ void QEMU_ERROR("code path is reachable")
 /*
  * Minimum function that returns zero only if both values are zero.
  * Intended for use with unsigned values only.
+ *
+ * Preprocessor sorcery ahead: use different identifiers for the local
+ * variables in each expansion, so we can nest macro calls without
+ * shadowing variables.
  */
-#ifndef MIN_NON_ZERO
-#define MIN_NON_ZERO(a, b)                              \
+#define MIN_NON_ZERO_INTERNAL(a, b, _a, _b)             \
     ({                                                  \
         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
         _a == 0 ? _b : (_b == 0 || _b > _a) ? _a : _b;  \
     })
-#endif
+#define MIN_NON_ZERO(a, b) \
+    MIN_NON_ZERO_INTERNAL((a), (b), MAKE_IDENTFIER(_a), MAKE_IDENTFIER(_b))
 
 /*
  * Round number down to multiple. Safe when m is not a power of 2 (see
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 08/56] tcg: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (6 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 07/56] qobject atomics osdep: Make a few macros more hygienic Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 09/56] target/arm/tcg: " Markus Armbruster
                   ` (48 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  tcg/tcg.c:2551:27: error: declaration shadows a local variable [-Werror,-Wshadow]
                    MemOp op = get_memop(oi);
                          ^
  tcg/tcg.c:2437:12: note: previous declaration is here
    TCGOp *op;
           ^
  accel/tcg/tb-maint.c:245:18: error: declaration shadows a local variable [-Werror,-Wshadow]
        for (int i = 0; i < V_L2_SIZE; i++) {
                 ^
  accel/tcg/tb-maint.c:210:9: note: previous declaration is here
    int i;
        ^

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-2-philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 accel/tcg/tb-maint.c |  3 +--
 tcg/tcg.c            | 16 ++++++++--------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c
index 32ae8af61c..8c71cebabd 100644
--- a/accel/tcg/tb-maint.c
+++ b/accel/tcg/tb-maint.c
@@ -207,13 +207,12 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, bool alloc)
 {
     PageDesc *pd;
     void **lp;
-    int i;
 
     /* Level 1.  Always allocated.  */
     lp = l1_map + ((index >> v_l1_shift) & (v_l1_size - 1));
 
     /* Level 2..N-1.  */
-    for (i = v_l2_levels; i > 0; i--) {
+    for (int i = v_l2_levels; i > 0; i--) {
         void **p = qatomic_rcu_read(lp);
 
         if (p == NULL) {
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 604fa9bf3e..ea94d0fbff 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2549,21 +2549,21 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs)
                 {
                     const char *s_al, *s_op, *s_at;
                     MemOpIdx oi = op->args[k++];
-                    MemOp op = get_memop(oi);
+                    MemOp mop = get_memop(oi);
                     unsigned ix = get_mmuidx(oi);
 
-                    s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT];
-                    s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)];
-                    s_at = atom_name[(op & MO_ATOM_MASK) >> MO_ATOM_SHIFT];
-                    op &= ~(MO_AMASK | MO_BSWAP | MO_SSIZE | MO_ATOM_MASK);
+                    s_al = alignment_name[(mop & MO_AMASK) >> MO_ASHIFT];
+                    s_op = ldst_name[mop & (MO_BSWAP | MO_SSIZE)];
+                    s_at = atom_name[(mop & MO_ATOM_MASK) >> MO_ATOM_SHIFT];
+                    mop &= ~(MO_AMASK | MO_BSWAP | MO_SSIZE | MO_ATOM_MASK);
 
                     /* If all fields are accounted for, print symbolically. */
-                    if (!op && s_al && s_op && s_at) {
+                    if (!mop && s_al && s_op && s_at) {
                         col += ne_fprintf(f, ",%s%s%s,%u",
                                           s_at, s_al, s_op, ix);
                     } else {
-                        op = get_memop(oi);
-                        col += ne_fprintf(f, ",$0x%x,%u", op, ix);
+                        mop = get_memop(oi);
+                        col += ne_fprintf(f, ",$0x%x,%u", mop, ix);
                     }
                     i = 1;
                 }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 09/56] target/arm/tcg: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (7 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 08/56] tcg: Clean up local variable shadowing Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 10/56] target/arm/hvf: " Markus Armbruster
                   ` (47 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Maydell

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  target/arm/tcg/translate-m-nocp.c: In function ‘gen_M_fp_sysreg_read’:
  target/arm/tcg/translate-m-nocp.c:509:18: warning: declaration of ‘tmp’ shadows a previous local [-Wshadow=compatible-local]
    509 |         TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]);
        |                  ^~~
  target/arm/tcg/translate-m-nocp.c:433:14: note: shadowed declaration is here
    433 |     TCGv_i32 tmp;
        |              ^~~
       ---

  target/arm/tcg/mve_helper.c: In function ‘helper_mve_vqshlsb’:
  target/arm/tcg/mve_helper.c:1259:19: warning: declaration of ‘r’ shadows a previous local [-Wshadow=compatible-local]
   1259 |         typeof(N) r = FN(N, (int8_t)(M), sizeof(N) * 8, ROUND, &su32);  \
        |                   ^
  target/arm/tcg/mve_helper.c:1267:5: note: in expansion of macro ‘WRAP_QRSHL_HELPER’
   1267 |     WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, false, satp)
        |     ^~~~~~~~~~~~~~~~~
  target/arm/tcg/mve_helper.c:927:22: note: in expansion of macro ‘DO_SQSHL_OP’
    927 |             TYPE r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)], &sat);          \
        |                      ^~
  target/arm/tcg/mve_helper.c:945:5: note: in expansion of macro ‘DO_2OP_SAT’
    945 |     DO_2OP_SAT(OP##b, 1, int8_t, FN)            \
        |     ^~~~~~~~~~
  target/arm/tcg/mve_helper.c:1277:1: note: in expansion of macro ‘DO_2OP_SAT_S’
   1277 | DO_2OP_SAT_S(vqshls, DO_SQSHL_OP)
        | ^~~~~~~~~~~~
       ---

  target/arm/tcg/mve_helper.c: In function ‘do_sqrshl48_d’:
  target/arm/tcg/mve_helper.c:2463:17: warning: declaration of ‘extval’ shadows a previous local [-Wshadow=compatible-local]
   2463 |         int64_t extval = sextract64(src << shift, 0, 48);
        |                 ^~~~~~
  target/arm/tcg/mve_helper.c:2443:18: note: shadowed declaration is here
   2443 |     int64_t val, extval;
        |                  ^~~~~~
       ---

  target/arm/tcg/mve_helper.c: In function ‘do_uqrshl48_d’:
  target/arm/tcg/mve_helper.c:2495:18: warning: declaration of ‘extval’ shadows a previous local [-Wshadow=compatible-local]
   2495 |         uint64_t extval = extract64(src << shift, 0, 48);
        |                  ^~~~~~
  target/arm/tcg/mve_helper.c:2479:19: note: shadowed declaration is here
   2479 |     uint64_t val, extval;
        |                   ^~~~~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-3-philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/arm/tcg/mve_helper.c       | 16 ++++++++--------
 target/arm/tcg/translate-m-nocp.c |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/target/arm/tcg/mve_helper.c b/target/arm/tcg/mve_helper.c
index c666a96ba1..8b99736aad 100644
--- a/target/arm/tcg/mve_helper.c
+++ b/target/arm/tcg/mve_helper.c
@@ -925,8 +925,8 @@ DO_1OP_IMM(vorri, DO_ORRI)
         bool qc = false;                                                \
         for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) {              \
             bool sat = false;                                           \
-            TYPE r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)], &sat);          \
-            mergemask(&d[H##ESIZE(e)], r, mask);                        \
+            TYPE r_ = FN(n[H##ESIZE(e)], m[H##ESIZE(e)], &sat);         \
+            mergemask(&d[H##ESIZE(e)], r_, mask);                       \
             qc |= sat & mask & 1;                                       \
         }                                                               \
         if (qc) {                                                       \
@@ -1250,11 +1250,11 @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W)
 #define WRAP_QRSHL_HELPER(FN, N, M, ROUND, satp)                        \
     ({                                                                  \
         uint32_t su32 = 0;                                              \
-        typeof(N) r = FN(N, (int8_t)(M), sizeof(N) * 8, ROUND, &su32);  \
+        typeof(N) qrshl_ret = FN(N, (int8_t)(M), sizeof(N) * 8, ROUND, &su32); \
         if (su32) {                                                     \
             *satp = true;                                               \
         }                                                               \
-        r;                                                              \
+        qrshl_ret;                                                      \
     })
 
 #define DO_SQSHL_OP(N, M, satp) \
@@ -1292,12 +1292,12 @@ DO_2OP_SAT_U(vqrshlu, DO_UQRSHL_OP)
         for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) {              \
             bool sat = false;                                           \
             if ((e & 1) == XCHG) {                                      \
-                TYPE r = FN(n[H##ESIZE(e)],                             \
+                TYPE vqdmladh_ret = FN(n[H##ESIZE(e)],                  \
                             m[H##ESIZE(e - XCHG)],                      \
                             n[H##ESIZE(e + (1 - 2 * XCHG))],            \
                             m[H##ESIZE(e + (1 - XCHG))],                \
                             ROUND, &sat);                               \
-                mergemask(&d[H##ESIZE(e)], r, mask);                    \
+                mergemask(&d[H##ESIZE(e)], vqdmladh_ret, mask);         \
                 qc |= sat & mask & 1;                                   \
             }                                                           \
         }                                                               \
@@ -2454,7 +2454,7 @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift,
             return extval;
         }
     } else if (shift < 48) {
-        int64_t extval = sextract64(src << shift, 0, 48);
+        extval = sextract64(src << shift, 0, 48);
         if (!sat || src == (extval >> shift)) {
             return extval;
         }
@@ -2486,7 +2486,7 @@ static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift,
             return extval;
         }
     } else if (shift < 48) {
-        uint64_t extval = extract64(src << shift, 0, 48);
+        extval = extract64(src << shift, 0, 48);
         if (!sat || src == (extval >> shift)) {
             return extval;
         }
diff --git a/target/arm/tcg/translate-m-nocp.c b/target/arm/tcg/translate-m-nocp.c
index 33f6478bb9..42308c4db5 100644
--- a/target/arm/tcg/translate-m-nocp.c
+++ b/target/arm/tcg/translate-m-nocp.c
@@ -506,7 +506,7 @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,
 
         gen_branch_fpInactive(s, TCG_COND_EQ, lab_active);
         /* fpInactive case: reads as FPDSCR_NS */
-        TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]);
+        tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]);
         storefn(s, opaque, tmp, true);
         lab_end = gen_new_label();
         tcg_gen_br(lab_end);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 10/56] target/arm/hvf: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (8 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 09/56] target/arm/tcg: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 11/56] target/mips: " Markus Armbruster
                   ` (46 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Maydell

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Per Peter Maydell analysis [*]:

  The hvf_vcpu_exec() function is not documented, but in practice
  its caller expects it to return either EXCP_DEBUG (for "this was
  a guest debug exception you need to deal with") or something else
  (presumably the intention being 0 for OK).

  The hvf_sysreg_read() and hvf_sysreg_write() functions are also not
  documented, but they return 0 on success, or 1 for a completely
  unrecognized sysreg where we've raised the UNDEF exception (but
  not if we raised an UNDEF exception for an unrecognized GIC sysreg --
  I think this is a bug). We use this return value to decide whether
  we need to advance the PC past the insn or not. It's not the same
  as the return value we want to return from hvf_vcpu_exec().

  Retain the variable as locally scoped but give it a name that
  doesn't clash with the other function-scoped variable.

This fixes:

  target/arm/hvf/hvf.c:1936:13: error: declaration shadows a local variable [-Werror,-Wshadow]
        int ret = 0;
            ^
  target/arm/hvf/hvf.c:1807:9: note: previous declaration is here
    int ret;
        ^
[*] https://lore.kernel.org/qemu-devel/CAFEAcA_e+fU6JKtS+W63wr9cCJ6btu_hT_ydZWOwC0kBkDYYYQ@mail.gmail.com/

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-4-philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/arm/hvf/hvf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 546c0e817f..757e13b0f9 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1934,16 +1934,16 @@ int hvf_vcpu_exec(CPUState *cpu)
         uint32_t rt = (syndrome >> 5) & 0x1f;
         uint32_t reg = syndrome & SYSREG_MASK;
         uint64_t val;
-        int ret = 0;
+        int sysreg_ret = 0;
 
         if (isread) {
-            ret = hvf_sysreg_read(cpu, reg, rt);
+            sysreg_ret = hvf_sysreg_read(cpu, reg, rt);
         } else {
             val = hvf_get_reg(cpu, rt);
-            ret = hvf_sysreg_write(cpu, reg, val);
+            sysreg_ret = hvf_sysreg_write(cpu, reg, val);
         }
 
-        advance_pc = !ret;
+        advance_pc = !sysreg_ret;
         break;
     }
     case EC_WFX_TRAP:
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 11/56] target/mips: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (9 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 10/56] target/arm/hvf: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 12/56] target/m68k: " Markus Armbruster
                   ` (45 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  target/mips/tcg/nanomips_translate.c.inc:4410:33: error: declaration shadows a local variable [-Werror,-Wshadow]
                        int32_t imm = extract32(ctx->opcode, 1, 13) |
                                ^
  target/mips/tcg/nanomips_translate.c.inc:3577:9: note: previous declaration is here
    int imm;
        ^
  target/mips/tcg/translate.c:15578:19: error: declaration shadows a local variable [-Werror,-Wshadow]
    for (unsigned i = 1; i < 32; i++) {
                  ^
  target/mips/tcg/translate.c:15567:9: note: previous declaration is here
    int i;
        ^
  target/mips/tcg/msa_helper.c:7478:13: error: declaration shadows a local variable [-Werror,-Wshadow]
            MSA_FLOAT_MAXOP(pwx->w[0], min, pws->w[0], pws->w[0], 32);
            ^
  target/mips/tcg/msa_helper.c:7434:23: note: expanded from macro 'MSA_FLOAT_MAXOP'
        float_status *status = &env->active_tc.msa_fp_status;
                      ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-5-philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/mips/tcg/msa_helper.c             | 8 ++++----
 target/mips/tcg/translate.c              | 8 +++-----
 target/mips/tcg/nanomips_translate.c.inc | 6 +++---
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/target/mips/tcg/msa_helper.c b/target/mips/tcg/msa_helper.c
index c314a74397..7a8dbada5d 100644
--- a/target/mips/tcg/msa_helper.c
+++ b/target/mips/tcg/msa_helper.c
@@ -7432,15 +7432,15 @@ void helper_msa_ftq_df(CPUMIPSState *env, uint32_t df, uint32_t wd,
 
 #define MSA_FLOAT_MAXOP(DEST, OP, ARG1, ARG2, BITS)                         \
     do {                                                                    \
-        float_status *status = &env->active_tc.msa_fp_status;               \
+        float_status *status_ = &env->active_tc.msa_fp_status;              \
         int c;                                                              \
                                                                             \
-        set_float_exception_flags(0, status);                               \
-        DEST = float ## BITS ## _ ## OP(ARG1, ARG2, status);                \
+        set_float_exception_flags(0, status_);                              \
+        DEST = float ## BITS ## _ ## OP(ARG1, ARG2, status_);               \
         c = update_msacsr(env, 0, 0);                                       \
                                                                             \
         if (get_enabled_exceptions(env, c)) {                               \
-            DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c;            \
+            DEST = ((FLOAT_SNAN ## BITS(status_) >> 6) << 6) | c;           \
         }                                                                   \
     } while (0)
 
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index 9bb40f1849..26d741d960 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -15564,10 +15564,8 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
 
 void mips_tcg_init(void)
 {
-    int i;
-
     cpu_gpr[0] = NULL;
-    for (i = 1; i < 32; i++)
+    for (unsigned i = 1; i < 32; i++)
         cpu_gpr[i] = tcg_global_mem_new(cpu_env,
                                         offsetof(CPUMIPSState,
                                                  active_tc.gpr[i]),
@@ -15584,7 +15582,7 @@ void mips_tcg_init(void)
                                                rname);
     }
 #endif /* !TARGET_MIPS64 */
-    for (i = 0; i < 32; i++) {
+    for (unsigned i = 0; i < 32; i++) {
         int off = offsetof(CPUMIPSState, active_fpu.fpr[i].wr.d[0]);
 
         fpu_f64[i] = tcg_global_mem_new_i64(cpu_env, off, fregnames[i]);
@@ -15592,7 +15590,7 @@ void mips_tcg_init(void)
     msa_translate_init();
     cpu_PC = tcg_global_mem_new(cpu_env,
                                 offsetof(CPUMIPSState, active_tc.PC), "PC");
-    for (i = 0; i < MIPS_DSP_ACC; i++) {
+    for (unsigned i = 0; i < MIPS_DSP_ACC; i++) {
         cpu_HI[i] = tcg_global_mem_new(cpu_env,
                                        offsetof(CPUMIPSState, active_tc.HI[i]),
                                        regnames_HI[i]);
diff --git a/target/mips/tcg/nanomips_translate.c.inc b/target/mips/tcg/nanomips_translate.c.inc
index a98dde0d2e..d81a7c2d11 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -4407,8 +4407,8 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                 case NM_BPOSGE32C:
                     check_dsp_r3(ctx);
                     {
-                        int32_t imm = extract32(ctx->opcode, 1, 13) |
-                                      extract32(ctx->opcode, 0, 1) << 13;
+                        imm = extract32(ctx->opcode, 1, 13)
+                            | extract32(ctx->opcode, 0, 1) << 13;
 
                         gen_compute_branch_nm(ctx, OPC_BPOSGE32, 4, -1, -2,
                                               imm << 1);
@@ -4635,7 +4635,7 @@ static int decode_isa_nanomips(CPUMIPSState *env, DisasContext *ctx)
         break;
     case NM_LI16:
         {
-            int imm = extract32(ctx->opcode, 0, 7);
+            imm = extract32(ctx->opcode, 0, 7);
             imm = (imm == 0x7f ? -1 : imm);
             if (rt != 0) {
                 tcg_gen_movi_tl(cpu_gpr[rt], imm);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 12/56] target/m68k: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (10 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 11/56] target/mips: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 13/56] target/tricore: " Markus Armbruster
                   ` (44 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Maydell

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  target/m68k/translate.c:828:18: error: declaration shadows a local variable [-Werror,-Wshadow]
            TCGv tmp = tcg_temp_new();
                 ^
  target/m68k/translate.c:801:15: note: previous declaration is here
    TCGv reg, tmp, result;
              ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230904161235.84651-6-philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/m68k/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 9e224fe796..15c9ddf427 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -824,7 +824,7 @@ static TCGv gen_ea_mode(CPUM68KState *env, DisasContext *s, int mode, int reg0,
         reg = get_areg(s, reg0);
         result = gen_ldst(s, opsize, reg, val, what, index);
         if (what == EA_STORE || !addrp) {
-            TCGv tmp = tcg_temp_new();
+            tmp = tcg_temp_new();
             if (reg0 == 7 && opsize == OS_BYTE &&
                 m68k_feature(s->env, M68K_FEATURE_M68K)) {
                 tcg_gen_addi_i32(tmp, reg, 2);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 13/56] target/tricore: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (11 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 12/56] target/m68k: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 14/56] hw/arm/armv7m: " Markus Armbruster
                   ` (43 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Bastian Koppelmann

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  target/tricore/translate.c:5016:18: warning: declaration of ‘temp’ shadows a previous local [-Wshadow=compatible-local]
   5016 |             TCGv temp = tcg_constant_i32(const9);
        |                  ^~~~
  target/tricore/translate.c:4958:10: note: shadowed declaration is here
   4958 |     TCGv temp;
        |          ^~~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-7-philmd@linaro.org>
Reviewed-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/tricore/translate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/tricore/translate.c b/target/tricore/translate.c
index 6ae5ccbf72..9ca211b2a8 100644
--- a/target/tricore/translate.c
+++ b/target/tricore/translate.c
@@ -4962,8 +4962,6 @@ static void decode_rc_logical_shift(DisasContext *ctx)
     const9 = MASK_OP_RC_CONST9(ctx->opcode);
     op2 = MASK_OP_RC_OP2(ctx->opcode);
 
-    temp = tcg_temp_new();
-
     switch (op2) {
     case OPC2_32_RC_AND:
         tcg_gen_andi_tl(cpu_gpr_d[r2], cpu_gpr_d[r1], const9);
@@ -4972,10 +4970,12 @@ static void decode_rc_logical_shift(DisasContext *ctx)
         tcg_gen_andi_tl(cpu_gpr_d[r2], cpu_gpr_d[r1], ~const9);
         break;
     case OPC2_32_RC_NAND:
+        temp = tcg_temp_new();
         tcg_gen_movi_tl(temp, const9);
         tcg_gen_nand_tl(cpu_gpr_d[r2], cpu_gpr_d[r1], temp);
         break;
     case OPC2_32_RC_NOR:
+        temp = tcg_temp_new();
         tcg_gen_movi_tl(temp, const9);
         tcg_gen_nor_tl(cpu_gpr_d[r2], cpu_gpr_d[r1], temp);
         break;
@@ -5013,7 +5013,7 @@ static void decode_rc_logical_shift(DisasContext *ctx)
         break;
     case OPC2_32_RC_SHUFFLE:
         if (has_feature(ctx, TRICORE_FEATURE_162)) {
-            TCGv temp = tcg_constant_i32(const9);
+            temp = tcg_constant_i32(const9);
             gen_helper_shuffle(cpu_gpr_d[r2], cpu_gpr_d[r1], temp);
         } else {
             generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 14/56] hw/arm/armv7m: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (12 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 13/56] target/tricore: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 15/56] hw/arm/virt: " Markus Armbruster
                   ` (42 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Maydell

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  hw/arm/armv7m.c: In function ‘armv7m_realize’:
  hw/arm/armv7m.c:520:27: warning: declaration of ‘sbd’ shadows a previous local [-Wshadow=compatible-local]
    520 |             SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]);
        |                           ^~~
  hw/arm/armv7m.c:278:19: note: shadowed declaration is here
    278 |     SysBusDevice *sbd;
        |                   ^~~
       ---

  hw/arm/armsse.c: In function ‘armsse_realize’:
  hw/arm/armsse.c:1471:27: warning: declaration of ‘mr’ shadows a previous local [-Wshadow=compatible-local]
   1471 |             MemoryRegion *mr;
        |                           ^~
  hw/arm/armsse.c:917:19: note: shadowed declaration is here
    917 |     MemoryRegion *mr;
        |                   ^~
       ---

  hw/arm/armsse.c:1608:22: warning: declaration of ‘dev_splitter’ shadows a previous local [-Wshadow=compatible-local]
   1608 |         DeviceState *dev_splitter = DEVICE(splitter);
        |                      ^~~~~~~~~~~~
  hw/arm/armsse.c:923:18: note: shadowed declaration is here
    923 |     DeviceState *dev_splitter;
        |                  ^~~~~~~~~~~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-8-philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/arm/armsse.c | 16 ++++++----------
 hw/arm/armv7m.c |  2 +-
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
index 11cd08b6c1..31acbf7347 100644
--- a/hw/arm/armsse.c
+++ b/hw/arm/armsse.c
@@ -1468,7 +1468,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)
     if (info->has_cachectrl) {
         for (i = 0; i < info->num_cpus; i++) {
             char *name = g_strdup_printf("cachectrl%d", i);
-            MemoryRegion *mr;
 
             qdev_prop_set_string(DEVICE(&s->cachectrl[i]), "name", name);
             g_free(name);
@@ -1484,7 +1483,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)
     if (info->has_cpusecctrl) {
         for (i = 0; i < info->num_cpus; i++) {
             char *name = g_strdup_printf("CPUSECCTRL%d", i);
-            MemoryRegion *mr;
 
             qdev_prop_set_string(DEVICE(&s->cpusecctrl[i]), "name", name);
             g_free(name);
@@ -1499,7 +1497,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)
     }
     if (info->has_cpuid) {
         for (i = 0; i < info->num_cpus; i++) {
-            MemoryRegion *mr;
 
             qdev_prop_set_uint32(DEVICE(&s->cpuid[i]), "CPUID", i);
             if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpuid[i]), errp)) {
@@ -1512,7 +1509,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)
     }
     if (info->has_cpu_pwrctrl) {
         for (i = 0; i < info->num_cpus; i++) {
-            MemoryRegion *mr;
 
             if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu_pwrctrl[i]), errp)) {
                 return;
@@ -1605,7 +1601,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
     /* Wire up the splitters for the MPC IRQs */
     for (i = 0; i < IOTS_NUM_EXP_MPC + info->sram_banks; i++) {
         SplitIRQ *splitter = &s->mpc_irq_splitter[i];
-        DeviceState *dev_splitter = DEVICE(splitter);
+        DeviceState *devs = DEVICE(splitter);
 
         if (!object_property_set_int(OBJECT(splitter), "num-lines", 2,
                                      errp)) {
@@ -1617,22 +1613,22 @@ static void armsse_realize(DeviceState *dev, Error **errp)
 
         if (i < IOTS_NUM_EXP_MPC) {
             /* Splitter input is from GPIO input line */
-            s->mpcexp_status_in[i] = qdev_get_gpio_in(dev_splitter, 0);
-            qdev_connect_gpio_out(dev_splitter, 0,
+            s->mpcexp_status_in[i] = qdev_get_gpio_in(devs, 0);
+            qdev_connect_gpio_out(devs, 0,
                                   qdev_get_gpio_in_named(dev_secctl,
                                                          "mpcexp_status", i));
         } else {
             /* Splitter input is from our own MPC */
             qdev_connect_gpio_out_named(DEVICE(&s->mpc[i - IOTS_NUM_EXP_MPC]),
                                         "irq", 0,
-                                        qdev_get_gpio_in(dev_splitter, 0));
-            qdev_connect_gpio_out(dev_splitter, 0,
+                                        qdev_get_gpio_in(devs, 0));
+            qdev_connect_gpio_out(devs, 0,
                                   qdev_get_gpio_in_named(dev_secctl,
                                                          "mpc_status",
                                                          i - IOTS_NUM_EXP_MPC));
         }
 
-        qdev_connect_gpio_out(dev_splitter, 1,
+        qdev_connect_gpio_out(devs, 1,
                               qdev_get_gpio_in(DEVICE(&s->mpc_irq_orgate), i));
     }
     /* Create GPIO inputs which will pass the line state for our
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index bf173b10b8..1f78e18872 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -517,7 +517,7 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
     for (i = 0; i < ARRAY_SIZE(s->bitband); i++) {
         if (s->enable_bitband) {
             Object *obj = OBJECT(&s->bitband[i]);
-            SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]);
+            sbd = SYS_BUS_DEVICE(&s->bitband[i]);
 
             if (!object_property_set_int(obj, "base",
                                          bitband_input_addr[i], errp)) {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 15/56] hw/arm/virt: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (13 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 14/56] hw/arm/armv7m: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 16/56] hw/arm/allwinner: " Markus Armbruster
                   ` (41 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Maydell

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  hw/arm/virt.c:821:22: error: declaration shadows a local variable [-Werror,-Wshadow]
            qemu_irq irq = qdev_get_gpio_in(vms->gic,
                     ^
  hw/arm/virt.c:803:13: note: previous declaration is here
        int irq;
            ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230904161235.84651-9-philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/arm/virt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 8ad78b23c2..15e74249f9 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -801,7 +801,6 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
     for (i = 0; i < smp_cpus; i++) {
         DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
         int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
-        int irq;
         /* Mapping from the output timer irq lines from the CPU to the
          * GIC PPI inputs we use for the virt board.
          */
@@ -812,7 +811,7 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
             [GTIMER_SEC]  = ARCH_TIMER_S_EL1_IRQ,
         };
 
-        for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
+        for (unsigned irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
             qdev_connect_gpio_out(cpudev, irq,
                                   qdev_get_gpio_in(vms->gic,
                                                    ppibase + timer_irq[irq]));
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 16/56] hw/arm/allwinner: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (14 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 15/56] hw/arm/virt: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 17/56] hw/m68k: " Markus Armbruster
                   ` (40 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Maydell

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  hw/arm/allwinner-r40.c:412:14: error: declaration shadows a local variable [-Werror,-Wshadow]
    for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
             ^
  hw/arm/allwinner-r40.c:299:14: note: previous declaration is here
    unsigned i;
             ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230904161235.84651-10-philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/arm/allwinner-r40.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
index 7d29eb224f..a0d367c60d 100644
--- a/hw/arm/allwinner-r40.c
+++ b/hw/arm/allwinner-r40.c
@@ -296,10 +296,9 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp)
 {
     const char *r40_nic_models[] = { "gmac", "emac", NULL };
     AwR40State *s = AW_R40(dev);
-    unsigned i;
 
     /* CPUs */
-    for (i = 0; i < AW_R40_NUM_CPUS; i++) {
+    for (unsigned i = 0; i < AW_R40_NUM_CPUS; i++) {
 
         /*
          * Disable secondary CPUs. Guest EL3 firmware will start
@@ -335,7 +334,7 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp)
      * maintenance interrupt signal to the appropriate GIC PPI inputs,
      * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs.
      */
-    for (i = 0; i < AW_R40_NUM_CPUS; i++) {
+    for (unsigned i = 0; i < AW_R40_NUM_CPUS; i++) {
         DeviceState *cpudev = DEVICE(&s->cpus[i]);
         int ppibase = AW_R40_GIC_NUM_SPI + i * GIC_INTERNAL + GIC_NR_SGIS;
         int irq;
@@ -494,7 +493,7 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp)
                        qdev_get_gpio_in(DEVICE(&s->gic), AW_R40_GIC_SPI_EMAC));
 
     /* Unimplemented devices */
-    for (i = 0; i < ARRAY_SIZE(r40_unimplemented); i++) {
+    for (unsigned i = 0; i < ARRAY_SIZE(r40_unimplemented); i++) {
         create_unimplemented_device(r40_unimplemented[i].device_name,
                                     r40_unimplemented[i].base,
                                     r40_unimplemented[i].size);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 17/56] hw/m68k: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (15 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 16/56] hw/arm/allwinner: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 18/56] hw/microblaze: " Markus Armbruster
                   ` (39 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Thomas Huth

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  hw/m68k/virt.c:263:13: error: declaration shadows a local variable [-Werror,-Wshadow]
            BOOTINFOSTR(param_ptr, BI_COMMAND_LINE,
            ^
  hw/m68k/bootinfo.h:47:13: note: expanded from macro 'BOOTINFOSTR'
        int i; \
            ^
  hw/m68k/virt.c:130:9: note: previous declaration is here
    int i;
        ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-13-philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/m68k/bootinfo.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/hw/m68k/bootinfo.h b/hw/m68k/bootinfo.h
index a3d37e3c80..0e6e3eea87 100644
--- a/hw/m68k/bootinfo.h
+++ b/hw/m68k/bootinfo.h
@@ -44,15 +44,14 @@
 
 #define BOOTINFOSTR(base, id, string) \
     do { \
-        int i; \
         stw_p(base, id); \
         base += 2; \
         stw_p(base, \
                  (sizeof(struct bi_record) + strlen(string) + \
                   1 /* null termination */ + 3 /* padding */) & ~3); \
         base += 2; \
-        for (i = 0; string[i]; i++) { \
-            stb_p(base++, string[i]); \
+        for (unsigned i_ = 0; string[i_]; i_++) { \
+            stb_p(base++, string[i_]); \
         } \
         stb_p(base++, 0); \
         base = QEMU_ALIGN_PTR_UP(base, 4); \
@@ -60,7 +59,6 @@
 
 #define BOOTINFODATA(base, id, data, len) \
     do { \
-        int i; \
         stw_p(base, id); \
         base += 2; \
         stw_p(base, \
@@ -69,8 +67,8 @@
         base += 2; \
         stw_p(base, len); \
         base += 2; \
-        for (i = 0; i < len; ++i) { \
-            stb_p(base++, data[i]); \
+        for (unsigned i_ = 0; i_ < len; ++i_) { \
+            stb_p(base++, data[i_]); \
         } \
         base = QEMU_ALIGN_PTR_UP(base, 4); \
     } while (0)
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 18/56] hw/microblaze: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (16 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 17/56] hw/m68k: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 19/56] hw/nios2: " Markus Armbruster
                   ` (38 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  hw/microblaze/petalogix_ml605_mmu.c: In function ‘petalogix_ml605_init’:
  hw/microblaze/petalogix_ml605_mmu.c:186:24: warning: declaration of ‘dinfo’ shadows a previous local [-Wshadow=compatible-local]
    186 |             DriveInfo *dinfo = drive_get(IF_MTD, 0, i);
        |                        ^~~~~
  hw/microblaze/petalogix_ml605_mmu.c:78:16: note: shadowed declaration is here
     78 |     DriveInfo *dinfo;
        |                ^~~~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-14-philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/microblaze/petalogix_ml605_mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index ea0fb68cf0..fb7889cf67 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -183,7 +183,7 @@ petalogix_ml605_init(MachineState *machine)
         spi = (SSIBus *)qdev_get_child_bus(dev, "spi");
 
         for (i = 0; i < NUM_SPI_FLASHES; i++) {
-            DriveInfo *dinfo = drive_get(IF_MTD, 0, i);
+            dinfo = drive_get(IF_MTD, 0, i);
             qemu_irq cs_line;
 
             dev = qdev_new("n25q128");
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 19/56] hw/nios2: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (17 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 18/56] hw/microblaze: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 20/56] net/eth: " Markus Armbruster
                   ` (37 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  hw/nios2/10m50_devboard.c: In function ‘nios2_10m50_ghrd_init’:
  hw/nios2/10m50_devboard.c:101:22: warning: declaration of ‘dev’ shadows a previous local [-Wshadow=compatible-local]
    101 |         DeviceState *dev = qdev_new(TYPE_NIOS2_VIC);
        |                      ^~~
  hw/nios2/10m50_devboard.c:60:18: note: shadowed declaration is here
     60 |     DeviceState *dev;
        |                  ^~~

  hw/nios2/10m50_devboard.c:110:18: warning: declaration of ‘i’ shadows a previous local [-Wshadow=compatible-local]
    110 |         for (int i = 0; i < 32; i++) {
        |                  ^
  hw/nios2/10m50_devboard.c:67:9: note: shadowed declaration is here
     67 |     int i;
        |         ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-15-philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/nios2/10m50_devboard.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c
index 91383fb097..952a0dc33e 100644
--- a/hw/nios2/10m50_devboard.c
+++ b/hw/nios2/10m50_devboard.c
@@ -98,7 +98,7 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
     qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal);
 
     if (nms->vic) {
-        DeviceState *dev = qdev_new(TYPE_NIOS2_VIC);
+        dev = qdev_new(TYPE_NIOS2_VIC);
         MemoryRegion *dev_mr;
         qemu_irq cpu_irq;
 
@@ -107,7 +107,7 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
 
         cpu_irq = qdev_get_gpio_in_named(DEVICE(cpu), "EIC", 0);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq);
-        for (int i = 0; i < 32; i++) {
+        for (i = 0; i < 32; i++) {
             irq[i] = qdev_get_gpio_in(dev, i);
         }
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 20/56] net/eth: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (18 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 19/56] hw/nios2: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 21/56] crypto/cipher-gnutls.c: " Markus Armbruster
                   ` (36 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Akihiko Odaki, Eric Blake

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  net/eth.c:435:20: error: declaration shadows a local variable [-Werror,-Wshadow]
            size_t input_size = iov_size(pkt, pkt_frags);
                   ^
  net/eth.c:413:16: note: previous declaration is here
        size_t input_size = iov_size(pkt, pkt_frags);
               ^

Suggested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-16-philmd@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 net/eth.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 649e66bb1f..3f680cc033 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -432,8 +432,6 @@ _eth_get_rss_ex_src_addr(const struct iovec *pkt, int pkt_frags,
         }
 
         if (opthdr.type == IP6_OPT_HOME) {
-            size_t input_size = iov_size(pkt, pkt_frags);
-
             if (input_size < opt_offset + sizeof(opthdr)) {
                 return false;
             }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 21/56] crypto/cipher-gnutls.c: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (19 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 20/56] net/eth: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 22/56] util/vhost-user-server: " Markus Armbruster
                   ` (35 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Daniel P . Berrangé

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  In file included from crypto/cipher.c:140:
  crypto/cipher-gnutls.c.inc: In function ‘qcrypto_gnutls_cipher_encrypt’:
  crypto/cipher-gnutls.c.inc:116:17: warning: declaration of ‘err’ shadows a previous local [-Wshadow=compatible-local]
    116 |             int err = gnutls_cipher_init(&handle, ctx->galg, &gkey, NULL);
        |                 ^~~
  crypto/cipher-gnutls.c.inc:94:9: note: shadowed declaration is here
     94 |     int err;
        |         ^~~
       ---

  crypto/cipher-gnutls.c.inc: In function ‘qcrypto_gnutls_cipher_decrypt’:
  crypto/cipher-gnutls.c.inc:177:17: warning: declaration of ‘err’ shadows a previous local [-Wshadow=compatible-local]
    177 |             int err = gnutls_cipher_init(&handle, ctx->galg, &gkey, NULL);
        |                 ^~~
  crypto/cipher-gnutls.c.inc:154:9: note: shadowed declaration is here
    154 |     int err;
        |         ^~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-17-philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 crypto/cipher-gnutls.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/cipher-gnutls.c.inc b/crypto/cipher-gnutls.c.inc
index 501e4e07a5..d3e231c13c 100644
--- a/crypto/cipher-gnutls.c.inc
+++ b/crypto/cipher-gnutls.c.inc
@@ -113,7 +113,7 @@ qcrypto_gnutls_cipher_encrypt(QCryptoCipher *cipher,
         while (len) {
             gnutls_cipher_hd_t handle;
             gnutls_datum_t gkey = { (unsigned char *)ctx->key, ctx->nkey };
-            int err = gnutls_cipher_init(&handle, ctx->galg, &gkey, NULL);
+            err = gnutls_cipher_init(&handle, ctx->galg, &gkey, NULL);
             if (err != 0) {
                 error_setg(errp, "Cannot initialize cipher: %s",
                            gnutls_strerror(err));
@@ -174,7 +174,7 @@ qcrypto_gnutls_cipher_decrypt(QCryptoCipher *cipher,
         while (len) {
             gnutls_cipher_hd_t handle;
             gnutls_datum_t gkey = { (unsigned char *)ctx->key, ctx->nkey };
-            int err = gnutls_cipher_init(&handle, ctx->galg, &gkey, NULL);
+            err = gnutls_cipher_init(&handle, ctx->galg, &gkey, NULL);
             if (err != 0) {
                 error_setg(errp, "Cannot initialize cipher: %s",
                            gnutls_strerror(err));
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 22/56] util/vhost-user-server: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (20 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 21/56] crypto/cipher-gnutls.c: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 23/56] linux-user/strace: " Markus Armbruster
                   ` (34 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Michael S . Tsirkin

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  util/vhost-user-server.c: In function ‘set_watch’:
  util/vhost-user-server.c:274:20: warning: declaration of ‘vu_fd_watch’ shadows a previous local [-Wshadow=compatible-local]
    274 |         VuFdWatch *vu_fd_watch = g_new0(VuFdWatch, 1);
        |                    ^~~~~~~~~~~
  util/vhost-user-server.c:271:16: note: shadowed declaration is here
    271 |     VuFdWatch *vu_fd_watch = find_vu_fd_watch(server, fd);
        |                ^~~~~~~~~~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-18-philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 util/vhost-user-server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/vhost-user-server.c b/util/vhost-user-server.c
index b4b6bf30a2..5ccc6d24a0 100644
--- a/util/vhost-user-server.c
+++ b/util/vhost-user-server.c
@@ -278,7 +278,7 @@ set_watch(VuDev *vu_dev, int fd, int vu_evt,
     VuFdWatch *vu_fd_watch = find_vu_fd_watch(server, fd);
 
     if (!vu_fd_watch) {
-        VuFdWatch *vu_fd_watch = g_new0(VuFdWatch, 1);
+        vu_fd_watch = g_new0(VuFdWatch, 1);
 
         QTAILQ_INSERT_TAIL(&server->vu_fd_watches, vu_fd_watch, next);
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 23/56] linux-user/strace: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (21 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 22/56] util/vhost-user-server: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 24/56] sysemu/device_tree: " Markus Armbruster
                   ` (33 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  linux-user/strace.c: In function ‘print_sockaddr’:
  linux-user/strace.c:370:17: warning: declaration of ‘i’ shadows a previous local [-Wshadow=compatible-local]
    370 |             int i;
        |                 ^
  linux-user/strace.c:361:9: note: shadowed declaration is here
    361 |     int i;
        |         ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-20-philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 linux-user/strace.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index e0ab8046ec..cf26e55264 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -367,7 +367,6 @@ print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
         switch (sa_family) {
         case AF_UNIX: {
             struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
-            int i;
             qemu_log("{sun_family=AF_UNIX,sun_path=\"");
             for (i = 0; i < addrlen -
                             offsetof(struct target_sockaddr_un, sun_path) &&
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 24/56] sysemu/device_tree: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (22 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 23/56] linux-user/strace: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 25/56] softmmu/memory: " Markus Armbruster
                   ` (32 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  hw/mips/boston.c:472:5: error: declaration shadows a local variable [-Werror,-Wshadow]
    qemu_fdt_setprop_cells(fdt, name, "reg", reg_base, reg_size);
    ^
  include/sysemu/device_tree.h:129:13: note: expanded from macro 'qemu_fdt_setprop_cells'
        int i;
            ^
  hw/mips/boston.c:461:9: note: previous declaration is here
    int i;
        ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-21-philmd@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/sysemu/device_tree.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h
index ca5339beae..8eab395934 100644
--- a/include/sysemu/device_tree.h
+++ b/include/sysemu/device_tree.h
@@ -126,10 +126,8 @@ int qemu_fdt_add_path(void *fdt, const char *path);
 #define qemu_fdt_setprop_cells(fdt, node_path, property, ...)                 \
     do {                                                                      \
         uint32_t qdt_tmp[] = { __VA_ARGS__ };                                 \
-        int i;                                                                \
-                                                                              \
-        for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) {                           \
-            qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]);                             \
+        for (unsigned i_ = 0; i_ < ARRAY_SIZE(qdt_tmp); i_++) {               \
+            qdt_tmp[i_] = cpu_to_be32(qdt_tmp[i_]);                           \
         }                                                                     \
         qemu_fdt_setprop(fdt, node_path, property, qdt_tmp,                   \
                          sizeof(qdt_tmp));                                    \
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 25/56] softmmu/memory: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (23 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 24/56] sysemu/device_tree: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 26/56] softmmu/physmem: " Markus Armbruster
                   ` (31 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Xu

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  softmmu/memory.c: In function ‘mtree_print_mr’:
  softmmu/memory.c:3236:27: warning: declaration of ‘ml’ shadows a previous local [-Wshadow=compatible-local]
   3236 |         MemoryRegionList *ml;
        |                           ^~
  softmmu/memory.c:3213:32: note: shadowed declaration is here
   3213 |     MemoryRegionList *new_ml, *ml, *next_ml;
        |                                ^~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-22-philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 softmmu/memory.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/softmmu/memory.c b/softmmu/memory.c
index c0383a163d..234bd7b116 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -3245,7 +3245,6 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
     }
 
     if (mr->alias) {
-        MemoryRegionList *ml;
         bool found = false;
 
         /* check if the alias is already in the queue */
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 26/56] softmmu/physmem: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (24 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 25/56] softmmu/memory: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 27/56] hw/core/machine: " Markus Armbruster
                   ` (30 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Daniel P . Berrangé,
	Peter Xu

From: Philippe Mathieu-Daudé <philmd@linaro.org>

Fix:

  softmmu/physmem.c: In function ‘cpu_physical_memory_snapshot_and_clear_dirty’:
  softmmu/physmem.c:916:27: warning: declaration of ‘offset’ shadows a parameter [-Wshadow=compatible-local]
    916 |             unsigned long offset = page % DIRTY_MEMORY_BLOCK_SIZE;
        |                           ^~~~~~
  softmmu/physmem.c:892:31: note: shadowed declaration is here
    892 |     (MemoryRegion *mr, hwaddr offset, hwaddr length, unsigned client)
        |                        ~~~~~~~^~~~~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904161235.84651-23-philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 softmmu/physmem.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 4f6ca653b3..309653c722 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -913,16 +913,16 @@ DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty
 
         while (page < end) {
             unsigned long idx = page / DIRTY_MEMORY_BLOCK_SIZE;
-            unsigned long offset = page % DIRTY_MEMORY_BLOCK_SIZE;
+            unsigned long ofs = page % DIRTY_MEMORY_BLOCK_SIZE;
             unsigned long num = MIN(end - page,
-                                    DIRTY_MEMORY_BLOCK_SIZE - offset);
+                                    DIRTY_MEMORY_BLOCK_SIZE - ofs);
 
-            assert(QEMU_IS_ALIGNED(offset, (1 << BITS_PER_LEVEL)));
+            assert(QEMU_IS_ALIGNED(ofs, (1 << BITS_PER_LEVEL)));
             assert(QEMU_IS_ALIGNED(num,    (1 << BITS_PER_LEVEL)));
-            offset >>= BITS_PER_LEVEL;
+            ofs >>= BITS_PER_LEVEL;
 
             bitmap_copy_and_clear_atomic(snap->dirty + dest,
-                                         blocks->blocks[idx] + offset,
+                                         blocks->blocks[idx] + ofs,
                                          num);
             page += num;
             dest += num >> BITS_PER_LEVEL;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 27/56] hw/core/machine: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (25 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 26/56] softmmu/physmem: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 28/56] hw/intc/openpic: " Markus Armbruster
                   ` (29 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Maydell

From: Philippe Mathieu-Daudé <philmd@linaro.org>

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)
        |                            ~~~~~~~~^~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904162824.85385-2-philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/core/machine.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index cb38b8cf4c..a232ae0bcd 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1082,8 +1082,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);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 28/56] hw/intc/openpic: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (26 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 27/56] hw/core/machine: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 29/56] hw/ppc: Clean up local variable shadowing in _FDT helper routine Markus Armbruster
                   ` (28 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Peter Maydell

From: Philippe Mathieu-Daudé <philmd@linaro.org>

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;
        |         ^~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230904162824.85385-3-philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/intc/openpic.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
index c757adbe53..a6f91d4bcd 100644
--- a/hw/intc/openpic.c
+++ b/hw/intc/openpic.c
@@ -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;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 29/56] hw/ppc: Clean up local variable shadowing in _FDT helper routine
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (27 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 28/56] hw/intc/openpic: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 30/56] pnv/psi: Clean up local variable shadowing Markus Armbruster
                   ` (27 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Harsh Prateek Bora

From: Cédric Le Goater <clg@kaod.org>

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>
Message-ID: <20230918145850.241074-2-clg@kaod.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.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 a8cd85069f..b56ac2a8cb 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



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 30/56] pnv/psi: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (28 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 29/56] hw/ppc: Clean up local variable shadowing in _FDT helper routine Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 31/56] spapr: Clean up local variable shadowing in spapr_dt_cpus() Markus Armbruster
                   ` (26 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Harsh Prateek Bora

From: Cédric Le Goater <clg@kaod.org>

to fix :

  ../hw/ppc/pnv_psi.c: In function ‘pnv_psi_p9_mmio_write’:
  ../hw/ppc/pnv_psi.c:741:24: warning: declaration of ‘addr’ shadows a parameter [-Wshadow=compatible-local]
    741 |                 hwaddr addr = val & ~(PSIHB9_ESB_CI_VALID | PSIHB10_ESB_CI_64K);
        |                        ^~~~
  ../hw/ppc/pnv_psi.c:702:56: note: shadowed declaration is here
    702 | static void pnv_psi_p9_mmio_write(void *opaque, hwaddr addr,
        |                                                 ~~~~~~~^~~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230918145850.241074-3-clg@kaod.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ppc/pnv_psi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
index daaa2f0575..26460d210d 100644
--- a/hw/ppc/pnv_psi.c
+++ b/hw/ppc/pnv_psi.c
@@ -738,8 +738,9 @@ static void pnv_psi_p9_mmio_write(void *opaque, hwaddr addr,
             }
         } else {
             if (!(psi->regs[reg] & PSIHB9_ESB_CI_VALID)) {
-                hwaddr addr = val & ~(PSIHB9_ESB_CI_VALID | PSIHB10_ESB_CI_64K);
-                memory_region_add_subregion(sysmem, addr,
+                hwaddr esb_addr =
+                    val & ~(PSIHB9_ESB_CI_VALID | PSIHB10_ESB_CI_64K);
+                memory_region_add_subregion(sysmem, esb_addr,
                                             &psi9->source.esb_mmio);
             }
         }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 31/56] spapr: Clean up local variable shadowing in spapr_dt_cpus()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (29 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 30/56] pnv/psi: Clean up local variable shadowing Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 32/56] spapr: Clean up local variable shadowing in spapr_init_cpus() Markus Armbruster
                   ` (25 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Harsh Prateek Bora

From: Cédric Le Goater <clg@kaod.org>

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>
Message-ID: <20230918145850.241074-4-clg@kaod.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 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 1f1aa2a6d4..612dbdf356 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);
     }
 
     g_free(rev);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 32/56] spapr: Clean up local variable shadowing in spapr_init_cpus()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (30 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 31/56] spapr: Clean up local variable shadowing in spapr_dt_cpus() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 33/56] spapr: Clean up local variable shadowing in spapr_get_fw_dev_path() Markus Armbruster
                   ` (24 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Harsh Prateek Bora

From: Cédric Le Goater <clg@kaod.org>

Remove extra 'i' variable to fix this warning :

  ../hw/ppc/spapr.c: In function ‘spapr_init_cpus’:
  ../hw/ppc/spapr.c:2668:13: warning: declaration of ‘i’ shadows a previous local [-Wshadow=compatible-local]
   2668 |         int i;
        |             ^
  ../hw/ppc/spapr.c:2645:9: note: shadowed declaration is here
   2645 |     int i;
        |         ^

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230918145850.241074-5-clg@kaod.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ppc/spapr.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 612dbdf356..4fe82e490a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2665,8 +2665,6 @@ static void spapr_init_cpus(SpaprMachineState *spapr)
     }
 
     if (smc->pre_2_10_has_unused_icps) {
-        int i;
-
         for (i = 0; i < spapr_max_server_number(spapr); i++) {
             /* Dummy entries get deregistered when real ICPState objects
              * are registered during CPU core hotplug.
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 33/56] spapr: Clean up local variable shadowing in spapr_get_fw_dev_path()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (31 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 32/56] spapr: Clean up local variable shadowing in spapr_init_cpus() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 34/56] spapr/drc: Clean up local variable shadowing in rtas_ibm_configure_connector() Markus Armbruster
                   ` (23 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Philippe Mathieu-Daudé

From: Cédric Le Goater <clg@kaod.org>

Rename PCIDevice variable to avoid this warning :

  ../hw/ppc/spapr.c: In function ‘spapr_get_fw_dev_path’:
  ../hw/ppc/spapr.c:3217:20: warning: declaration of ‘pcidev’ shadows a previous local [-Wshadow=compatible-local]
   3217 |         PCIDevice *pcidev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE);
        |                    ^~~~~~
  ../hw/ppc/spapr.c:3147:16: note: shadowed declaration is here
   3147 |     PCIDevice *pcidev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE);
        |                ^~~~~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230918145850.241074-6-clg@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ppc/spapr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 4fe82e490a..d4230d3647 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3214,8 +3214,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
 
     if (g_str_equal("pci-bridge", qdev_fw_name(dev))) {
         /* SLOF uses "pci" instead of "pci-bridge" for PCI bridges */
-        PCIDevice *pcidev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE);
-        return g_strdup_printf("pci@%x", PCI_SLOT(pcidev->devfn));
+        PCIDevice *pdev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE);
+        return g_strdup_printf("pci@%x", PCI_SLOT(pdev->devfn));
     }
 
     if (pcidev) {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 34/56] spapr/drc: Clean up local variable shadowing in rtas_ibm_configure_connector()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (32 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 33/56] spapr: Clean up local variable shadowing in spapr_get_fw_dev_path() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 35/56] spapr/pci: Clean up local variable shadowing in spapr_phb_realize() Markus Armbruster
                   ` (22 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Harsh Prateek Bora

From: Cédric Le Goater <clg@kaod.org>

Remove extra 'drc_index' variable to avoid this warning :

  ../hw/ppc/spapr_drc.c: In function ‘rtas_ibm_configure_connector’:
  ../hw/ppc/spapr_drc.c:1240:26: warning: declaration of ‘drc_index’ shadows a previous local [-Wshadow=compatible-local]
   1240 |                 uint32_t drc_index = spapr_drc_index(drc);
        |                          ^~~~~~~~~
  ../hw/ppc/spapr_drc.c:1155:14: note: shadowed declaration is here
   1155 |     uint32_t drc_index;
        |              ^~~~~~~~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230918145850.241074-7-clg@kaod.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ppc/spapr_drc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index b5c400a94d..843e318312 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -1237,8 +1237,6 @@ static void rtas_ibm_configure_connector(PowerPCCPU *cpu,
         case FDT_END_NODE:
             drc->ccs_depth--;
             if (drc->ccs_depth == 0) {
-                uint32_t drc_index = spapr_drc_index(drc);
-
                 /* done sending the device tree, move to configured state */
                 trace_spapr_drc_set_configured(drc_index);
                 drc->state = drck->ready_state;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 35/56] spapr/pci: Clean up local variable shadowing in spapr_phb_realize()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (33 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 34/56] spapr/drc: Clean up local variable shadowing in rtas_ibm_configure_connector() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 36/56] spapr/drc: Clean up local variable shadowing in prop_get_fdt() Markus Armbruster
                   ` (21 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Harsh Prateek Bora

From: Cédric Le Goater <clg@kaod.org>

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>
Message-ID: <20230918145850.241074-8-clg@kaod.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 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 ce14959317..370c5a90f2 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;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 36/56] spapr/drc: Clean up local variable shadowing in prop_get_fdt()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (34 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 35/56] spapr/pci: Clean up local variable shadowing in spapr_phb_realize() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 37/56] test-throttle: don't shadow 'index' variable in do_test_accounting() Markus Armbruster
                   ` (20 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Cédric Le Goater, Philippe Mathieu-Daudé,
	Harsh Prateek Bora

From: Cédric Le Goater <clg@kaod.org>

Rename 'name' variable to avoid this warning :

  ../hw/ppc/spapr_drc.c: In function ‘prop_get_fdt’:
  ../hw/ppc/spapr_drc.c:344:21: warning: declaration of ‘name’ shadows a parameter [-Wshadow=compatible-local]
    344 |         const char *name = NULL;
        |                     ^~~~
  ../hw/ppc/spapr_drc.c:325:63: note: shadowed declaration is here
    325 | static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
        |                                                   ~~~~~~~~~~~~^~~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230918145850.241074-9-clg@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ppc/spapr_drc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 843e318312..2b99d3b4b1 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -341,7 +341,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
     fdt_depth = 0;
 
     do {
-        const char *name = NULL;
+        const char *dt_name = NULL;
         const struct fdt_property *prop = NULL;
         int prop_len = 0, name_len = 0;
         uint32_t tag;
@@ -351,8 +351,8 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
         switch (tag) {
         case FDT_BEGIN_NODE:
             fdt_depth++;
-            name = fdt_get_name(fdt, fdt_offset, &name_len);
-            if (!visit_start_struct(v, name, NULL, 0, errp)) {
+            dt_name = fdt_get_name(fdt, fdt_offset, &name_len);
+            if (!visit_start_struct(v, dt_name, NULL, 0, errp)) {
                 return;
             }
             break;
@@ -369,8 +369,8 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
         case FDT_PROP: {
             int i;
             prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
-            name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
-            if (!visit_start_list(v, name, NULL, 0, errp)) {
+            dt_name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
+            if (!visit_start_list(v, dt_name, NULL, 0, errp)) {
                 return;
             }
             for (i = 0; i < prop_len; i++) {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 37/56] test-throttle: don't shadow 'index' variable in do_test_accounting()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (35 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 36/56] spapr/drc: Clean up local variable shadowing in prop_get_fdt() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local Markus Armbruster
                   ` (19 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Alberto Garcia

From: Alberto Garcia <berto@igalia.com>

Fixes build with -Wshadow=local

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-ID: <20230922105742.81317-1-berto@igalia.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/unit/test-throttle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/unit/test-throttle.c b/tests/unit/test-throttle.c
index cb587e33e7..ac35d65d19 100644
--- a/tests/unit/test-throttle.c
+++ b/tests/unit/test-throttle.c
@@ -625,7 +625,7 @@ static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */
     throttle_config_init(&cfg);
 
     for (i = 0; i < 3; i++) {
-        BucketType index = to_test[is_ops][i];
+        index = to_test[is_ops][i];
         cfg.buckets[index].avg = avg;
     }
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (36 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 37/56] test-throttle: don't shadow 'index' variable in do_test_accounting() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-30  3:54   ` Ani Sinha
  2023-09-29  8:50 ` [PULL 39/56] hw/intc/arm_gicv3_its: Avoid shadowing variable in do_process_its_cmd() Markus Armbruster
                   ` (18 subsequent siblings)
  56 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Ani Sinha, Philippe Mathieu-Daude, mst, imammedo

From: Ani Sinha <anisinha@redhat.com>

Code changes in acpi that addresses all compiler complaints coming from enabling
-Wshadow flags. Enabling -Wshadow catches cases of local variables shadowing
other local variables or parameters. These makes the code confusing and/or adds
bugs that are difficult to catch.  See also

    Subject: Help wanted for enabling -Wshadow=local
    Message-Id: <87r0mqlf9x.fsf@pond.sub.org>
    https://lore.kernel.org/qemu-devel/87r0mqlf9x.fsf@pond.sub.org

The code is tested to build with and without the flag turned on.

CC: Markus Armbruster <armbru@redhat.com>
CC: Philippe Mathieu-Daude <philmd@linaro.org>
CC: mst@redhat.com
CC: imammedo@redhat.com
Signed-off-by: Ani Sinha <anisinha@redhat.com>
Message-ID: <20230922124203.127110-1-anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/acpi/cpu_hotplug.c | 25 +++++++++++++------------
 hw/i386/acpi-build.c  | 24 ++++++++++++------------
 hw/smbios/smbios.c    | 37 +++++++++++++++++++------------------
 3 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index ff14c3f410..634bbecb31 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -265,26 +265,27 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,
 
     /* build Processor object for each processor */
     for (i = 0; i < apic_ids->len; i++) {
-        int apic_id = apic_ids->cpus[i].arch_id;
+        int cpu_apic_id = apic_ids->cpus[i].arch_id;
 
-        assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);
+        assert(cpu_apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);
 
-        dev = aml_processor(i, 0, 0, "CP%.02X", apic_id);
+        dev = aml_processor(i, 0, 0, "CP%.02X", cpu_apic_id);
 
         method = aml_method("_MAT", 0, AML_NOTSERIALIZED);
         aml_append(method,
-            aml_return(aml_call2(CPU_MAT_METHOD, aml_int(apic_id), aml_int(i))
+            aml_return(aml_call2(CPU_MAT_METHOD,
+                                 aml_int(cpu_apic_id), aml_int(i))
         ));
         aml_append(dev, method);
 
         method = aml_method("_STA", 0, AML_NOTSERIALIZED);
         aml_append(method,
-            aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id))));
+            aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(cpu_apic_id))));
         aml_append(dev, method);
 
         method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
         aml_append(method,
-            aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id),
+            aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(cpu_apic_id),
                 aml_arg(0)))
         );
         aml_append(dev, method);
@@ -298,11 +299,11 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,
     /* Arg0 = APIC ID */
     method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
     for (i = 0; i < apic_ids->len; i++) {
-        int apic_id = apic_ids->cpus[i].arch_id;
+        int cpu_apic_id = apic_ids->cpus[i].arch_id;
 
-        if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));
+        if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(cpu_apic_id)));
         aml_append(if_ctx,
-            aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1))
+            aml_notify(aml_name("CP%.02X", cpu_apic_id), aml_arg(1))
         );
         aml_append(method, if_ctx);
     }
@@ -319,13 +320,13 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,
                                         aml_varpackage(x86ms->apic_id_limit);
 
     for (i = 0, apic_idx = 0; i < apic_ids->len; i++) {
-        int apic_id = apic_ids->cpus[i].arch_id;
+        int cpu_apic_id = apic_ids->cpus[i].arch_id;
 
-        for (; apic_idx < apic_id; apic_idx++) {
+        for (; apic_idx < cpu_apic_id; apic_idx++) {
             aml_append(pkg, aml_int(0));
         }
         aml_append(pkg, aml_int(apic_ids->cpus[i].cpu ? 1 : 0));
-        apic_idx = apic_id + 1;
+        apic_idx = cpu_apic_id + 1;
     }
     aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg));
     aml_append(ctx, sb_scope);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 4d2d40bab5..95199c8900 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1585,12 +1585,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             aml_append(dev, aml_name_decl("_UID", aml_int(bus_num)));
             aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
             if (pci_bus_is_cxl(bus)) {
-                struct Aml *pkg = aml_package(2);
+                struct Aml *aml_pkg = aml_package(2);
 
                 aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0016")));
-                aml_append(pkg, aml_eisaid("PNP0A08"));
-                aml_append(pkg, aml_eisaid("PNP0A03"));
-                aml_append(dev, aml_name_decl("_CID", pkg));
+                aml_append(aml_pkg, aml_eisaid("PNP0A08"));
+                aml_append(aml_pkg, aml_eisaid("PNP0A03"));
+                aml_append(dev, aml_name_decl("_CID", aml_pkg));
                 build_cxl_osc_method(dev);
             } else if (pci_bus_is_express(bus)) {
                 aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
@@ -1783,14 +1783,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         Object *pci_host = acpi_get_i386_pci_host();
 
         if (pci_host) {
-            PCIBus *bus = PCI_HOST_BRIDGE(pci_host)->bus;
-            Aml *scope = aml_scope("PCI0");
+            PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
+            Aml *ascope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus);
-            if (object_property_find(OBJECT(bus), ACPI_PCIHP_PROP_BSEL)) {
-                build_append_pcihp_slots(scope, bus);
+            build_append_pci_bus_devices(ascope, pbus);
+            if (object_property_find(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL)) {
+                build_append_pcihp_slots(ascope, pbus);
             }
-            aml_append(sb_scope, scope);
+            aml_append(sb_scope, ascope);
         }
     }
 
@@ -1842,10 +1842,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         bool has_pcnt;
 
         Object *pci_host = acpi_get_i386_pci_host();
-        PCIBus *bus = PCI_HOST_BRIDGE(pci_host)->bus;
+        PCIBus *b = PCI_HOST_BRIDGE(pci_host)->bus;
 
         scope = aml_scope("\\_SB.PCI0");
-        has_pcnt = build_append_notfication_callback(scope, bus);
+        has_pcnt = build_append_notfication_callback(scope, b);
         if (has_pcnt) {
             aml_append(dsdt, scope);
         }
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index b753705856..2a90601ac5 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -1423,13 +1423,14 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
             if (!qemu_opts_validate(opts, qemu_smbios_type8_opts, errp)) {
                 return;
             }
-            struct type8_instance *t;
-            t = g_new0(struct type8_instance, 1);
-            save_opt(&t->internal_reference, opts, "internal_reference");
-            save_opt(&t->external_reference, opts, "external_reference");
-            t->connector_type = qemu_opt_get_number(opts, "connector_type", 0);
-            t->port_type = qemu_opt_get_number(opts, "port_type", 0);
-            QTAILQ_INSERT_TAIL(&type8, t, next);
+            struct type8_instance *t8_i;
+            t8_i = g_new0(struct type8_instance, 1);
+            save_opt(&t8_i->internal_reference, opts, "internal_reference");
+            save_opt(&t8_i->external_reference, opts, "external_reference");
+            t8_i->connector_type = qemu_opt_get_number(opts,
+                                                       "connector_type", 0);
+            t8_i->port_type = qemu_opt_get_number(opts, "port_type", 0);
+            QTAILQ_INSERT_TAIL(&type8, t8_i, next);
             return;
         case 11:
             if (!qemu_opts_validate(opts, qemu_smbios_type11_opts, errp)) {
@@ -1452,27 +1453,27 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
             type17.speed = qemu_opt_get_number(opts, "speed", 0);
             return;
         case 41: {
-            struct type41_instance *t;
+            struct type41_instance *t41_i;
             Error *local_err = NULL;
 
             if (!qemu_opts_validate(opts, qemu_smbios_type41_opts, errp)) {
                 return;
             }
-            t = g_new0(struct type41_instance, 1);
-            save_opt(&t->designation, opts, "designation");
-            t->kind = qapi_enum_parse(&type41_kind_lookup,
-                                      qemu_opt_get(opts, "kind"),
-                                      0, &local_err) + 1;
-            t->kind |= 0x80;     /* enabled */
+            t41_i = g_new0(struct type41_instance, 1);
+            save_opt(&t41_i->designation, opts, "designation");
+            t41_i->kind = qapi_enum_parse(&type41_kind_lookup,
+                                          qemu_opt_get(opts, "kind"),
+                                          0, &local_err) + 1;
+            t41_i->kind |= 0x80;     /* enabled */
             if (local_err != NULL) {
                 error_propagate(errp, local_err);
-                g_free(t);
+                g_free(t41_i);
                 return;
             }
-            t->instance = qemu_opt_get_number(opts, "instance", 1);
-            save_opt(&t->pcidev, opts, "pcidev");
+            t41_i->instance = qemu_opt_get_number(opts, "instance", 1);
+            save_opt(&t41_i->pcidev, opts, "pcidev");
 
-            QTAILQ_INSERT_TAIL(&type41, t, next);
+            QTAILQ_INSERT_TAIL(&type41, t41_i, next);
             return;
         }
         default:
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 39/56] hw/intc/arm_gicv3_its: Avoid shadowing variable in do_process_its_cmd()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (37 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 40/56] hw/misc/arm_sysctl.c: Avoid shadowing local variable Markus Armbruster
                   ` (17 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Peter Maydell, Philippe Mathieu-Daudé, Eric Auger

From: Peter Maydell <peter.maydell@linaro.org>

Avoid shadowing a local variable in do_process_its_cmd():

../../hw/intc/arm_gicv3_its.c:548:17: warning: declaration of ‘ite’ shadows a previous local [-Wshadow=compatible-local]
  548 |         ITEntry ite = {};
      |                 ^~~
../../hw/intc/arm_gicv3_its.c:518:13: note: shadowed declaration is here
  518 |     ITEntry ite;
      |             ^~~

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230922152944.3583438-2-peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/intc/arm_gicv3_its.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
index 5f552b4d37..52e9aca9c6 100644
--- a/hw/intc/arm_gicv3_its.c
+++ b/hw/intc/arm_gicv3_its.c
@@ -545,10 +545,10 @@ static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid,
     }
 
     if (cmdres == CMD_CONTINUE_OK && cmd == DISCARD) {
-        ITEntry ite = {};
+        ITEntry i = {};
         /* remove mapping from interrupt translation table */
-        ite.valid = false;
-        return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE_OK : CMD_STALL;
+        i.valid = false;
+        return update_ite(s, eventid, &dte, &i) ? CMD_CONTINUE_OK : CMD_STALL;
     }
     return CMD_CONTINUE_OK;
 }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 40/56] hw/misc/arm_sysctl.c: Avoid shadowing local variable
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (38 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 39/56] hw/intc/arm_gicv3_its: Avoid shadowing variable in do_process_its_cmd() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 41/56] hw/arm/smmuv3.c: Avoid shadowing variable Markus Armbruster
                   ` (16 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Peter Maydell, Philippe Mathieu-Daudé, Eric Auger

From: Peter Maydell <peter.maydell@linaro.org>

Avoid shadowing a local variable in arm_sysctl_write():

../../hw/misc/arm_sysctl.c: In function ‘arm_sysctl_write’:
../../hw/misc/arm_sysctl.c:537:26: warning: declaration of ‘val’ shadows a parameter [-Wshadow=local]
  537 |                 uint32_t val;
      |                          ^~~
../../hw/misc/arm_sysctl.c:388:39: note: shadowed declaration is here
  388 |                              uint64_t val, unsigned size)
      |                              ~~~~~~~~~^~~

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230922152944.3583438-3-peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/misc/arm_sysctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c
index 42d4693854..3e4f4b0524 100644
--- a/hw/misc/arm_sysctl.c
+++ b/hw/misc/arm_sysctl.c
@@ -534,12 +534,12 @@ static void arm_sysctl_write(void *opaque, hwaddr offset,
                     s->sys_cfgstat |= 2;        /* error */
                 }
             } else {
-                uint32_t val;
+                uint32_t data;
                 if (!vexpress_cfgctrl_read(s, dcc, function, site, position,
-                                           device, &val)) {
+                                           device, &data)) {
                     s->sys_cfgstat |= 2;        /* error */
                 } else {
-                    s->sys_cfgdata = val;
+                    s->sys_cfgdata = data;
                 }
             }
         }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 41/56] hw/arm/smmuv3.c: Avoid shadowing variable
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (39 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 40/56] hw/misc/arm_sysctl.c: Avoid shadowing local variable Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 42/56] hw/arm/smmuv3-internal.h: Don't use locals in statement macros Markus Armbruster
                   ` (15 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Peter Maydell, Philippe Mathieu-Daudé, Eric Auger

From: Peter Maydell <peter.maydell@linaro.org>

Avoid shadowing a variable in smmuv3_notify_iova():

../../hw/arm/smmuv3.c: In function ‘smmuv3_notify_iova’:
../../hw/arm/smmuv3.c:1043:23: warning: declaration of ‘event’ shadows a previous local [-Wshadow=local]
 1043 |         SMMUEventInfo event = {.inval_ste_allowed = true};
      |                       ^~~~~
../../hw/arm/smmuv3.c:1038:19: note: shadowed declaration is here
 1038 |     IOMMUTLBEvent event;
      |                   ^~~~~

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230922152944.3583438-4-peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/arm/smmuv3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index 1e9be8e89a..6f2b2bd45f 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -1040,8 +1040,8 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
     SMMUv3State *s = sdev->smmu;
 
     if (!tg) {
-        SMMUEventInfo event = {.inval_ste_allowed = true};
-        SMMUTransCfg *cfg = smmuv3_get_config(sdev, &event);
+        SMMUEventInfo eventinfo = {.inval_ste_allowed = true};
+        SMMUTransCfg *cfg = smmuv3_get_config(sdev, &eventinfo);
         SMMUTransTableInfo *tt;
 
         if (!cfg) {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 42/56] hw/arm/smmuv3-internal.h: Don't use locals in statement macros
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (40 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 41/56] hw/arm/smmuv3.c: Avoid shadowing variable Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 43/56] aspeed/i2c: Clean up local variable shadowing Markus Armbruster
                   ` (14 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Peter Maydell, Eric Auger

From: Peter Maydell <peter.maydell@linaro.org>

The STE_CTXPTR() and STE_S2TTB() macros both extract two halves
of an address from fields in the STE and combine them into a
single value to return. The current code for this uses a GCC
statement expression. There are two problems with this:

(1) The type chosen for the variable in the statement expr
is 'unsigned long', which might not be 64 bits

(2) the name chosen for the variable causes -Wshadow warnings
because it's the same as a variable in use at the callsite:

In file included from ../../hw/arm/smmuv3.c:34:
../../hw/arm/smmuv3.c: In function ‘smmu_get_cd’:
../../hw/arm/smmuv3-internal.h:538:23: warning: declaration of ‘addr’ shadows a previous local [-Wshadow=compatible-local]
  538 |         unsigned long addr;                                     \
      |                       ^~~~
../../hw/arm/smmuv3.c:339:23: note: in expansion of macro ‘STE_CTXPTR’
  339 |     dma_addr_t addr = STE_CTXPTR(ste);
      |                       ^~~~~~~~~~
../../hw/arm/smmuv3.c:339:16: note: shadowed declaration is here
  339 |     dma_addr_t addr = STE_CTXPTR(ste);
      |                ^~~~

Sidestep both of these problems by just using a single
expression rather than a statement expr.

For CMD_ADDR, we got the type of the variable right but still
run into -Wshadow problems:

In file included from ../../hw/arm/smmuv3.c:34:
../../hw/arm/smmuv3.c: In function ‘smmuv3_range_inval’:
../../hw/arm/smmuv3-internal.h:334:22: warning: declaration of ‘addr’ shadows a previous local [-Wshadow=compatible-local]
  334 |             uint64_t addr = high << 32 | (low << 12);         \
      |                      ^~~~
../../hw/arm/smmuv3.c:1104:28: note: in expansion of macro ‘CMD_ADDR’
 1104 |     dma_addr_t end, addr = CMD_ADDR(cmd);
      |                            ^~~~~~~~
../../hw/arm/smmuv3.c:1104:21: note: shadowed declaration is here
 1104 |     dma_addr_t end, addr = CMD_ADDR(cmd);
      |                     ^~~~

so convert it too.

CD_TTB has neither problem, but it is the only other macro in
the file that uses this pattern, so we convert it also for
consistency's sake.

We use extract64() rather than extract32() to avoid having
to explicitly cast the result to uint64_t.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230922152944.3583438-5-peter.maydell@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/arm/smmuv3-internal.h | 41 +++++++++++++---------------------------
 1 file changed, 13 insertions(+), 28 deletions(-)

diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
index 6d1c1edab7..648c2e37a2 100644
--- a/hw/arm/smmuv3-internal.h
+++ b/hw/arm/smmuv3-internal.h
@@ -328,12 +328,9 @@ enum { /* Command completion notification */
 #define CMD_TTL(x)          extract32((x)->word[2], 8 , 2)
 #define CMD_TG(x)           extract32((x)->word[2], 10, 2)
 #define CMD_STE_RANGE(x)    extract32((x)->word[2], 0 , 5)
-#define CMD_ADDR(x) ({                                        \
-            uint64_t high = (uint64_t)(x)->word[3];           \
-            uint64_t low = extract32((x)->word[2], 12, 20);    \
-            uint64_t addr = high << 32 | (low << 12);         \
-            addr;                                             \
-        })
+#define CMD_ADDR(x)                             \
+    (((uint64_t)((x)->word[3]) << 32) |         \
+     ((extract64((x)->word[2], 12, 20)) << 12))
 
 #define SMMU_FEATURE_2LVL_STE (1 << 0)
 
@@ -533,21 +530,13 @@ typedef struct CD {
 #define STE_S2S(x)         extract32((x)->word[5], 25, 1)
 #define STE_S2R(x)         extract32((x)->word[5], 26, 1)
 
-#define STE_CTXPTR(x)                                           \
-    ({                                                          \
-        unsigned long addr;                                     \
-        addr = (uint64_t)extract32((x)->word[1], 0, 16) << 32;  \
-        addr |= (uint64_t)((x)->word[0] & 0xffffffc0);          \
-        addr;                                                   \
-    })
+#define STE_CTXPTR(x)                                   \
+    ((extract64((x)->word[1], 0, 16) << 32) |           \
+     ((x)->word[0] & 0xffffffc0))
 
-#define STE_S2TTB(x)                                            \
-    ({                                                          \
-        unsigned long addr;                                     \
-        addr = (uint64_t)extract32((x)->word[7], 0, 16) << 32;  \
-        addr |= (uint64_t)((x)->word[6] & 0xfffffff0);          \
-        addr;                                                   \
-    })
+#define STE_S2TTB(x)                                    \
+    ((extract64((x)->word[7], 0, 16) << 32) |           \
+     ((x)->word[6] & 0xfffffff0))
 
 static inline int oas2bits(int oas_field)
 {
@@ -585,14 +574,10 @@ static inline int pa_range(STE *ste)
 
 #define CD_VALID(x)   extract32((x)->word[0], 31, 1)
 #define CD_ASID(x)    extract32((x)->word[1], 16, 16)
-#define CD_TTB(x, sel)                                      \
-    ({                                                      \
-        uint64_t hi, lo;                                    \
-        hi = extract32((x)->word[(sel) * 2 + 3], 0, 19);    \
-        hi <<= 32;                                          \
-        lo = (x)->word[(sel) * 2 + 2] & ~0xfULL;            \
-        hi | lo;                                            \
-    })
+#define CD_TTB(x, sel)                                          \
+    ((extract64((x)->word[(sel) * 2 + 3], 0, 19) << 32) |       \
+     ((x)->word[(sel) * 2 + 2] & ~0xfULL))
+
 #define CD_HAD(x, sel)   extract32((x)->word[(sel) * 2 + 2], 1, 1)
 
 #define CD_TSZ(x, sel)   extract32((x)->word[0], (16 * (sel)) + 0, 6)
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 43/56] aspeed/i2c: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (41 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 42/56] hw/arm/smmuv3-internal.h: Don't use locals in statement macros Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 44/56] aspeed: " Markus Armbruster
                   ` (13 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Cédric Le Goater, Philippe Mathieu-Daudé,
	Joel Stanley

From: Cédric Le Goater <clg@kaod.org>

Remove superfluous local 'data' variable and use the one define at the
top of the routine. This fixes :

  ../hw/i2c/aspeed_i2c.c: In function ‘aspeed_i2c_bus_recv’:
  ../hw/i2c/aspeed_i2c.c:315:17: warning: declaration of ‘data’ shadows a previous local [-Wshadow=compatible-local]
    315 |         uint8_t data;
        |                 ^~~~
  ../hw/i2c/aspeed_i2c.c:288:13: note: shadowed declaration is here
    288 |     uint8_t data;
        |             ^~~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230922155924.1172019-2-clg@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/i2c/aspeed_i2c.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
index 7275d40749..1037c22b2f 100644
--- a/hw/i2c/aspeed_i2c.c
+++ b/hw/i2c/aspeed_i2c.c
@@ -312,7 +312,6 @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus)
         SHARED_ARRAY_FIELD_DP32(bus->regs, reg_pool_ctrl, RX_COUNT, i & 0xff);
         SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, RX_BUFF_EN, 0);
     } else if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, RX_DMA_EN)) {
-        uint8_t data;
         /* In new mode, clear how many bytes we RXed */
         if (aspeed_i2c_is_new_mode(bus->controller)) {
             ARRAY_FIELD_DP32(bus->regs, I2CM_DMA_LEN_STS, RX_LEN, 0);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 44/56] aspeed: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (42 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 43/56] aspeed/i2c: Clean up local variable shadowing Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 45/56] aspeed/i3c: Rename variable shadowing a local Markus Armbruster
                   ` (12 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Philippe Mathieu-Daudé

From: Cédric Le Goater <clg@kaod.org>

Remove superfluous local 'irq' variables and use the one define at the
top of the routine. This fixes warnings in aspeed_soc_ast2600_realize()
such as :

  ../hw/arm/aspeed_ast2600.c: In function ‘aspeed_soc_ast2600_realize’:
  ../hw/arm/aspeed_ast2600.c:420:18: warning: declaration of ‘irq’ shadows a previous local [-Wshadow=compatible-local]
    420 |         qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
        |                  ^~~
  ../hw/arm/aspeed_ast2600.c:312:14: note: shadowed declaration is here
    312 |     qemu_irq irq;
        |              ^~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230922155924.1172019-3-clg@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/arm/aspeed_ast2600.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index a8b3a8065a..e122e1c32d 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -388,7 +388,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
     aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0,
                     sc->memmap[ASPEED_DEV_TIMER1]);
     for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
-        qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
+        irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
     }
 
@@ -413,8 +413,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
     }
     aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]);
     for (i = 0; i < ASPEED_I2C_GET_CLASS(&s->i2c)->num_busses; i++) {
-        qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
-                                        sc->irqmap[ASPEED_DEV_I2C] + i);
+        irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
+                               sc->irqmap[ASPEED_DEV_I2C] + i);
         /* The AST2600 I2C controller has one IRQ per bus. */
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c.busses[i]), 0, irq);
     }
@@ -611,8 +611,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
     }
     aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]);
     for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) {
-        qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
-                                        sc->irqmap[ASPEED_DEV_I3C] + i);
+        irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
+                               sc->irqmap[ASPEED_DEV_I3C] + i);
         /* The AST2600 I3C controller has one IRQ per bus. */
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq);
     }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 45/56] aspeed/i3c: Rename variable shadowing a local
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (43 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 44/56] aspeed: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 46/56] aspeed/timer: Clean up local variable shadowing Markus Armbruster
                   ` (11 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Cédric Le Goater, Philippe Mathieu-Daudé,
	Andrew Jeffery

From: Cédric Le Goater <clg@kaod.org>

to fix warning :

  ../hw/i3c/aspeed_i3c.c: In function ‘aspeed_i3c_realize’:
  ../hw/i3c/aspeed_i3c.c:1959:17: warning: declaration of ‘dev’ shadows a parameter [-Wshadow=local]
   1959 |         Object *dev = OBJECT(&s->devices[i]);
        |                 ^~~
  ../hw/i3c/aspeed_i3c.c:1942:45: note: shadowed declaration is here
   1942 | static void aspeed_i3c_realize(DeviceState *dev, Error **errp)
        |                                ~~~~~~~~~~~~~^~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230922155924.1172019-4-clg@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/misc/aspeed_i3c.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/misc/aspeed_i3c.c b/hw/misc/aspeed_i3c.c
index f54f5da522..d1ff617671 100644
--- a/hw/misc/aspeed_i3c.c
+++ b/hw/misc/aspeed_i3c.c
@@ -296,13 +296,13 @@ static void aspeed_i3c_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion(&s->iomem_container, 0x0, &s->iomem);
 
     for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) {
-        Object *dev = OBJECT(&s->devices[i]);
+        Object *i3c_dev = OBJECT(&s->devices[i]);
 
-        if (!object_property_set_uint(dev, "device-id", i, errp)) {
+        if (!object_property_set_uint(i3c_dev, "device-id", i, errp)) {
             return;
         }
 
-        if (!sysbus_realize(SYS_BUS_DEVICE(dev), errp)) {
+        if (!sysbus_realize(SYS_BUS_DEVICE(i3c_dev), errp)) {
             return;
         }
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 46/56] aspeed/timer: Clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (44 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 45/56] aspeed/i3c: Rename variable shadowing a local Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 47/56] intel_iommu: Fix shadow local variables on "size" Markus Armbruster
                   ` (10 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Cédric Le Goater, Joel Stanley, Andrew Jeffery,
	Philippe Mathieu-Daudé

From: Cédric Le Goater <clg@kaod.org>

commit 8137355e850f ("aspeed/timer: Fix behaviour running Linux")
introduced a MAX() expression to calculate the next timer deadline :

    return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0));

The second MAX() is not necessary since the compared values are an
unsigned and 0. Simply remove it and fix warning :

  ../hw/timer/aspeed_timer.c: In function ‘calculate_next’:
  ../include/qemu/osdep.h:396:31: warning: declaration of ‘_a’ shadows a previous local [-Wshadow=compatible-local]
    396 |         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
        |                               ^~
  ../hw/timer/aspeed_timer.c:170:12: note: in expansion of macro ‘MAX’
    170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
        |            ^~~
  ../hw/timer/aspeed_timer.c:170:16: note: in expansion of macro ‘MAX’
    170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
        |                ^~~
  /home/legoater/work/qemu/qemu-aspeed.git/include/qemu/osdep.h:396:31: note: shadowed declaration is here
    396 |         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
        |                               ^~
  ../hw/timer/aspeed_timer.c:170:12: note: in expansion of macro ‘MAX’
    170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
        |            ^~~

Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230922155924.1172019-5-clg@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/timer/aspeed_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
index 9c20b3d6ad..72161f07bb 100644
--- a/hw/timer/aspeed_timer.c
+++ b/hw/timer/aspeed_timer.c
@@ -167,7 +167,7 @@ static uint64_t calculate_next(struct AspeedTimer *t)
         qemu_set_irq(t->irq, t->level);
     }
 
-    next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
+    next = MAX(calculate_match(t, 0), calculate_match(t, 1));
     t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 
     return calculate_time(t, next);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 47/56] intel_iommu: Fix shadow local variables on "size"
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (45 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 46/56] aspeed/timer: Clean up local variable shadowing Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 48/56] crypto: remove shadowed 'ret' variable Markus Armbruster
                   ` (9 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Peter Xu, Jason Wang, Eric Auger, Michael S . Tsirkin,
	Philippe Mathieu-Daudé

From: Peter Xu <peterx@redhat.com>

This patch fixes the warning of shadowed local variable:

../hw/i386/intel_iommu.c: In function ‘vtd_address_space_unmap’:
../hw/i386/intel_iommu.c:3773:18: warning: declaration of ‘size’ shadows a previous local [-Wshadow=compatible-local]
 3773 |         uint64_t size = mask + 1;
      |                  ^~~~
../hw/i386/intel_iommu.c:3747:12: note: shadowed declaration is here
 3747 |     hwaddr size, remain;
      |            ^~~~

Cc: Jason Wang <jasowang@redhat.com>
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-ID: <20230922160410.138786-1-peterx@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/i386/intel_iommu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index c0ce896668..2c832ab68b 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3744,7 +3744,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus,
 /* Unmap the whole range in the notifier's scope. */
 static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
 {
-    hwaddr size, remain;
+    hwaddr total, remain;
     hwaddr start = n->start;
     hwaddr end = n->end;
     IntelIOMMUState *s = as->iommu_state;
@@ -3765,7 +3765,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
     }
 
     assert(start <= end);
-    size = remain = end - start + 1;
+    total = remain = end - start + 1;
 
     while (remain >= VTD_PAGE_SIZE) {
         IOMMUTLBEvent event;
@@ -3793,10 +3793,10 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
     trace_vtd_as_unmap_whole(pci_bus_num(as->bus),
                              VTD_PCI_SLOT(as->devfn),
                              VTD_PCI_FUNC(as->devfn),
-                             n->start, size);
+                             n->start, total);
 
     map.iova = n->start;
-    map.size = size - 1; /* Inclusive */
+    map.size = total - 1; /* Inclusive */
     iova_tree_remove(as->iova_tree, map);
 }
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 48/56] crypto: remove shadowed 'ret' variable
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (46 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 47/56] intel_iommu: Fix shadow local variables on "size" Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 49/56] seccomp: avoid shadowing of 'action' variable Markus Armbruster
                   ` (8 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Daniel P. Berrangé, Philippe Mathieu-Daudé

From: Daniel P. Berrangé <berrange@redhat.com>

Both instances of 'ret' are used to store a gnutls API return code.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20230922160644.438631-2-berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 crypto/tls-cipher-suites.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/crypto/tls-cipher-suites.c b/crypto/tls-cipher-suites.c
index 5e4f597464..d0df4badc0 100644
--- a/crypto/tls-cipher-suites.c
+++ b/crypto/tls-cipher-suites.c
@@ -52,7 +52,6 @@ GByteArray *qcrypto_tls_cipher_suites_get_data(QCryptoTLSCipherSuites *obj,
     byte_array = g_byte_array_new();
 
     for (i = 0;; i++) {
-        int ret;
         unsigned idx;
         const char *name;
         IANA_TLS_CIPHER cipher;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 49/56] seccomp: avoid shadowing of 'action' variable
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (47 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 48/56] crypto: remove shadowed 'ret' variable Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 50/56] qemu-nbd: changes towards enabling -Wshadow=local Markus Armbruster
                   ` (7 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Daniel P. Berrangé

From: Daniel P. Berrangé <berrange@redhat.com>

This is confusing as one 'action' variable is used for storing
a SCMP_ enum value, while the other 'action' variable is used
for storing a SECCOMP_ enum value.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20230922160644.438631-3-berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 softmmu/qemu-seccomp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/softmmu/qemu-seccomp.c b/softmmu/qemu-seccomp.c
index d66a2a1226..4d7439e7f7 100644
--- a/softmmu/qemu-seccomp.c
+++ b/softmmu/qemu-seccomp.c
@@ -283,9 +283,9 @@ static uint32_t qemu_seccomp_update_action(uint32_t action)
     if (action == SCMP_ACT_TRAP) {
         static int kill_process = -1;
         if (kill_process == -1) {
-            uint32_t action = SECCOMP_RET_KILL_PROCESS;
+            uint32_t testaction = SECCOMP_RET_KILL_PROCESS;
 
-            if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &action) == 0) {
+            if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &testaction) == 0) {
                 kill_process = 1;
             } else {
                 kill_process = 0;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 50/56] qemu-nbd: changes towards enabling -Wshadow=local
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (48 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 49/56] seccomp: avoid shadowing of 'action' variable Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 51/56] hw/riscv: opentitan: Fixup local variables shadowing Markus Armbruster
                   ` (6 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Eric Blake, Daniel P . Berrangé

From: Eric Blake <eblake@redhat.com>

Address all compiler complaints from -Wshadow in qemu-nbd.  Several
instances of 'int ret' became shadows when commit 4fbec260 added 'ret'
at a higher scope in main.  More interesting was the 'void *ret'
capturing the result of a pthread; where we were conceptually doing
'(void*)(intptr_t)EXIT_FAILURE != NULL' which just feels wrong (even
though it happens to compile correctly), so it was worth a better
cleanup.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20230922205019.2755352-2-eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-nbd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 70aa3c487a..54faa87a0c 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -939,7 +939,6 @@ int main(int argc, char **argv)
         g_autoptr(GError) err = NULL;
         int stderr_fd[2];
         pid_t pid;
-        int ret;
 
         if (!g_unix_open_pipe(stderr_fd, FD_CLOEXEC, &err)) {
             error_report("Error setting up communication pipe: %s",
@@ -1172,7 +1171,6 @@ int main(int argc, char **argv)
 
     if (opts.device) {
 #if HAVE_NBD_DEVICE
-        int ret;
         ret = pthread_create(&client_thread, NULL, nbd_client_thread, &opts);
         if (ret != 0) {
             error_report("Failed to create client thread: %s", strerror(ret));
@@ -1219,9 +1217,10 @@ int main(int argc, char **argv)
     qemu_opts_del(sn_opts);
 
     if (opts.device) {
-        void *ret;
-        pthread_join(client_thread, &ret);
-        exit(ret != NULL);
+        void *result;
+        pthread_join(client_thread, &result);
+        ret = (intptr_t)result;
+        exit(ret);
     } else {
         exit(EXIT_SUCCESS);
     }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 51/56] hw/riscv: opentitan: Fixup local variables shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (49 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 50/56] qemu-nbd: changes towards enabling -Wshadow=local Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 52/56] target/riscv: cpu: " Markus Armbruster
                   ` (5 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Alistair Francis, Alistair Francis, Daniel Henrique Barboza

From: Alistair Francis <alistair23@gmail.com>

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Bugs love to hide in such code.
Evidence: "[PATCH v3 1/7] migration/rdma: Fix save_page method to fail
on polling error".

This patch removes the local variable shadowing. Tested by adding:

    --extra-cflags='-Wshadow=local -Wno-error=shadow=local -Wno-error=shadow=compatible-local'

To configure

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20230925043023.71448-2-alistair.francis@wdc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/riscv/opentitan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
index 6a2fcc4ade..436503f1ba 100644
--- a/hw/riscv/opentitan.c
+++ b/hw/riscv/opentitan.c
@@ -227,7 +227,7 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
                                            IRQ_M_TIMER));
 
     /* SPI-Hosts */
-    for (int i = 0; i < OPENTITAN_NUM_SPI_HOSTS; ++i) {
+    for (i = 0; i < OPENTITAN_NUM_SPI_HOSTS; ++i) {
         dev = DEVICE(&(s->spi_host[i]));
         if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi_host[i]), errp)) {
             return;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 52/56] target/riscv: cpu: Fixup local variables shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (50 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 51/56] hw/riscv: opentitan: Fixup local variables shadowing Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 53/56] target/riscv: vector_helper: " Markus Armbruster
                   ` (4 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Alistair Francis, Alistair Francis, Daniel Henrique Barboza

From: Alistair Francis <alistair23@gmail.com>

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Bugs love to hide in such code.
Evidence: "[PATCH v3 1/7] migration/rdma: Fix save_page method to fail
on polling error".

This patch removes the local variable shadowing. Tested by adding:

    --extra-cflags='-Wshadow=local -Wno-error=shadow=local -Wno-error=shadow=compatible-local'

To configure

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20230925043023.71448-3-alistair.francis@wdc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/riscv/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index f227c7664e..4140899c52 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -704,7 +704,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
             CSR_MPMMASK,
         };
 
-        for (int i = 0; i < ARRAY_SIZE(dump_csrs); ++i) {
+        for (i = 0; i < ARRAY_SIZE(dump_csrs); ++i) {
             int csrno = dump_csrs[i];
             target_ulong val = 0;
             RISCVException res = riscv_csrrw_debug(env, csrno, &val, 0, 0);
@@ -747,7 +747,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
                     CSR_VTYPE,
                     CSR_VLENB,
                 };
-        for (int i = 0; i < ARRAY_SIZE(dump_rvv_csrs); ++i) {
+        for (i = 0; i < ARRAY_SIZE(dump_rvv_csrs); ++i) {
             int csrno = dump_rvv_csrs[i];
             target_ulong val = 0;
             RISCVException res = riscv_csrrw_debug(env, csrno, &val, 0, 0);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 53/56] target/riscv: vector_helper: Fixup local variables shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (51 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 52/56] target/riscv: cpu: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 54/56] softmmu/device_tree: " Markus Armbruster
                   ` (3 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Alistair Francis, Alistair Francis, Daniel Henrique Barboza

From: Alistair Francis <alistair23@gmail.com>

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Bugs love to hide in such code.
Evidence: "[PATCH v3 1/7] migration/rdma: Fix save_page method to fail
on polling error".

This patch removes the local variable shadowing. Tested by adding:

    --extra-cflags='-Wshadow=local -Wno-error=shadow=local -Wno-error=shadow=compatible-local'

To configure

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20230925043023.71448-4-alistair.francis@wdc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/riscv/vector_helper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index 3fb05cc3d6..cba02c1320 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -516,7 +516,7 @@ ProbeSuccess:
                 k++;
                 continue;
             }
-            target_ulong addr = base + ((i * nf + k) << log2_esz);
+            addr = base + ((i * nf + k) << log2_esz);
             ldst_elem(env, adjust_addr(env, addr), i + k * max_elems, vd, ra);
             k++;
         }
@@ -4791,9 +4791,10 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2,         \
     uint32_t total_elems = vext_get_total_elems(env, desc, esz);          \
     uint32_t vta = vext_vta(desc);                                        \
     uint32_t vma = vext_vma(desc);                                        \
-    target_ulong i_max, i;                                                \
+    target_ulong i_max, i_min, i;                                         \
                                                                           \
-    i_max = MAX(MIN(s1 < vlmax ? vlmax - s1 : 0, vl), env->vstart);       \
+    i_min = MIN(s1 < vlmax ? vlmax - s1 : 0, vl);                         \
+    i_max = MAX(i_min, env->vstart);                                      \
     for (i = env->vstart; i < i_max; ++i) {                               \
         if (!vm && !vext_elem_mask(v0, i)) {                              \
             /* set masked-off elements to 1s */                           \
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 54/56] softmmu/device_tree: Fixup local variables shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (52 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 53/56] target/riscv: vector_helper: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 55/56] hw/nvme: Clean up local variable shadowing in nvme_ns_init() Markus Armbruster
                   ` (2 subsequent siblings)
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Alistair Francis, Alistair Francis, Daniel Henrique Barboza

From: Alistair Francis <alistair23@gmail.com>

Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Bugs love to hide in such code.
Evidence: "[PATCH v3 1/7] migration/rdma: Fix save_page method to fail
on polling error".

This patch removes the local variable shadowing. Tested by adding:

    --extra-cflags='-Wshadow=local -Wno-error=shadow=local -Wno-error=shadow=compatible-local'

To configure

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20230925043023.71448-5-alistair.francis@wdc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 softmmu/device_tree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c
index 30aa3aea9f..eb5166ca36 100644
--- a/softmmu/device_tree.c
+++ b/softmmu/device_tree.c
@@ -418,9 +418,9 @@ int qemu_fdt_setprop_string_array(void *fdt, const char *node_path,
     }
     p = str = g_malloc0(total_len);
     for (i = 0; i < len; i++) {
-        int len = strlen(array[i]) + 1;
-        pstrcpy(p, len, array[i]);
-        p += len;
+        int offset = strlen(array[i]) + 1;
+        pstrcpy(p, offset, array[i]);
+        p += offset;
     }
 
     ret = qemu_fdt_setprop(fdt, node_path, prop, str, total_len);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 55/56] hw/nvme: Clean up local variable shadowing in nvme_ns_init()
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (53 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 54/56] softmmu/device_tree: " Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-09-29  8:50 ` [PULL 56/56] disas/m68k: clean up local variable shadowing Markus Armbruster
  2023-10-02 21:57 ` [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Stefan Hajnoczi
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Klaus Jensen, Jesper Wendel Devantier

From: Klaus Jensen <k.jensen@samsung.com>

Fix local variable shadowing in nvme_ns_init().

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Message-ID: <20230925-fix-local-shadowing-v1-1-3a1172132377@samsung.com>
Reviewed-by: Jesper Wendel Devantier <j.devantier@samsung.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/nvme/ns.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c
index 44aba8f4d9..0eabcf5cf5 100644
--- a/hw/nvme/ns.c
+++ b/hw/nvme/ns.c
@@ -107,7 +107,7 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp)
 
     ns->pif = ns->params.pif;
 
-    static const NvmeLBAF lbaf[16] = {
+    static const NvmeLBAF defaults[16] = {
         [0] = { .ds =  9           },
         [1] = { .ds =  9, .ms =  8 },
         [2] = { .ds =  9, .ms = 16 },
@@ -120,7 +120,7 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp)
 
     ns->nlbaf = 8;
 
-    memcpy(&id_ns->lbaf, &lbaf, sizeof(lbaf));
+    memcpy(&id_ns->lbaf, &defaults, sizeof(defaults));
 
     for (i = 0; i < ns->nlbaf; i++) {
         NvmeLBAF *lbaf = &id_ns->lbaf[i];
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* [PULL 56/56] disas/m68k: clean up local variable shadowing
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (54 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 55/56] hw/nvme: Clean up local variable shadowing in nvme_ns_init() Markus Armbruster
@ 2023-09-29  8:50 ` Markus Armbruster
  2023-10-02 21:57 ` [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Stefan Hajnoczi
  56 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2023-09-29  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Laurent Vivier, Thomas Huth

From: Laurent Vivier <laurent@vivier.eu>

Fix following warnings

.../disas/m68k.c: In function ‘print_insn_arg’:
.../disas/m68k.c:1635:13: warning: declaration of ‘val’ shadows a previous local [-Wshadow=compatible-local]
 1635 |         int val = fetch_arg (buffer, place, 5, info);
      |             ^~~
.../disas/m68k.c:1093:7: note: shadowed declaration is here
 1093 |   int val = 0;
      |       ^~~

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-ID: <20230925084455.395150-1-laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 disas/m68k.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/disas/m68k.c b/disas/m68k.c
index aefaecfbd6..1f16e295ab 100644
--- a/disas/m68k.c
+++ b/disas/m68k.c
@@ -1632,10 +1632,10 @@ print_insn_arg (const char *d,
     case '2':
     case '3':
       {
-	int val = fetch_arg (buffer, place, 5, info);
+	int reg = fetch_arg (buffer, place, 5, info);
         const char *name = 0;
 
-	switch (val)
+	switch (reg)
 	  {
 	  case 2: name = "%tt0"; break;
 	  case 3: name = "%tt1"; break;
@@ -1655,12 +1655,12 @@ print_insn_arg (const char *d,
 	      int break_reg = ((buffer[3] >> 2) & 7);
 
 	      (*info->fprintf_func)
-		(info->stream, val == 0x1c ? "%%bad%d" : "%%bac%d",
+		(info->stream, reg == 0x1c ? "%%bad%d" : "%%bac%d",
 		 break_reg);
 	    }
 	    break;
 	  default:
-	    (*info->fprintf_func) (info->stream, "<mmu register %d>", val);
+	    (*info->fprintf_func) (info->stream, "<mmu register %d>", reg);
 	  }
 	if (name)
 	  (*info->fprintf_func) (info->stream, "%s", name);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 61+ messages in thread

* Re: [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local
  2023-09-29  8:50 ` [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local Markus Armbruster
@ 2023-09-30  3:54   ` Ani Sinha
  2023-09-30  8:41     ` Markus Armbruster
  0 siblings, 1 reply; 61+ messages in thread
From: Ani Sinha @ 2023-09-30  3:54 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: qemu-devel, Stefan Hajnoczi, Philippe Mathieu-Daude,
	Michael S. Tsirkin, imammedo



> On 29-Sep-2023, at 2:20 PM, Markus Armbruster <armbru@redhat.com> wrote:
> 
> From: Ani Sinha <anisinha@redhat.com>
> 
> Code changes in acpi that addresses all compiler complaints coming from enabling
> -Wshadow flags. Enabling -Wshadow catches cases of local variables shadowing
> other local variables or parameters. These makes the code confusing and/or adds
> bugs that are difficult to catch.  See also
> 
>    Subject: Help wanted for enabling -Wshadow=local
>    Message-Id: <87r0mqlf9x.fsf@pond.sub.org>
>    https://lore.kernel.org/qemu-devel/87r0mqlf9x.fsf@pond.sub.org
> 
> The code is tested to build with and without the flag turned on.
> 
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Philippe Mathieu-Daude <philmd@linaro.org>
> CC: mst@redhat.com
> CC: imammedo@redhat.com
> Signed-off-by: Ani Sinha <anisinha@redhat.com>
> Message-ID: <20230922124203.127110-1-anisinha@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> [Commit message tweaked]
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Thanks!
Are you not going to pick up "hw/i386: changes towards enabling -Wshadow=local” ?

> ---
> hw/acpi/cpu_hotplug.c | 25 +++++++++++++------------
> hw/i386/acpi-build.c  | 24 ++++++++++++------------
> hw/smbios/smbios.c    | 37 +++++++++++++++++++------------------
> 3 files changed, 44 insertions(+), 42 deletions(-)
> 
> diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
> index ff14c3f410..634bbecb31 100644
> --- a/hw/acpi/cpu_hotplug.c
> +++ b/hw/acpi/cpu_hotplug.c
> @@ -265,26 +265,27 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,
> 
>     /* build Processor object for each processor */
>     for (i = 0; i < apic_ids->len; i++) {
> -        int apic_id = apic_ids->cpus[i].arch_id;
> +        int cpu_apic_id = apic_ids->cpus[i].arch_id;
> 
> -        assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);
> +        assert(cpu_apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);
> 
> -        dev = aml_processor(i, 0, 0, "CP%.02X", apic_id);
> +        dev = aml_processor(i, 0, 0, "CP%.02X", cpu_apic_id);
> 
>         method = aml_method("_MAT", 0, AML_NOTSERIALIZED);
>         aml_append(method,
> -            aml_return(aml_call2(CPU_MAT_METHOD, aml_int(apic_id), aml_int(i))
> +            aml_return(aml_call2(CPU_MAT_METHOD,
> +                                 aml_int(cpu_apic_id), aml_int(i))
>         ));
>         aml_append(dev, method);
> 
>         method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>         aml_append(method,
> -            aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id))));
> +            aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(cpu_apic_id))));
>         aml_append(dev, method);
> 
>         method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
>         aml_append(method,
> -            aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id),
> +            aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(cpu_apic_id),
>                 aml_arg(0)))
>         );
>         aml_append(dev, method);
> @@ -298,11 +299,11 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,
>     /* Arg0 = APIC ID */
>     method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
>     for (i = 0; i < apic_ids->len; i++) {
> -        int apic_id = apic_ids->cpus[i].arch_id;
> +        int cpu_apic_id = apic_ids->cpus[i].arch_id;
> 
> -        if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));
> +        if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(cpu_apic_id)));
>         aml_append(if_ctx,
> -            aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1))
> +            aml_notify(aml_name("CP%.02X", cpu_apic_id), aml_arg(1))
>         );
>         aml_append(method, if_ctx);
>     }
> @@ -319,13 +320,13 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,
>                                         aml_varpackage(x86ms->apic_id_limit);
> 
>     for (i = 0, apic_idx = 0; i < apic_ids->len; i++) {
> -        int apic_id = apic_ids->cpus[i].arch_id;
> +        int cpu_apic_id = apic_ids->cpus[i].arch_id;
> 
> -        for (; apic_idx < apic_id; apic_idx++) {
> +        for (; apic_idx < cpu_apic_id; apic_idx++) {
>             aml_append(pkg, aml_int(0));
>         }
>         aml_append(pkg, aml_int(apic_ids->cpus[i].cpu ? 1 : 0));
> -        apic_idx = apic_id + 1;
> +        apic_idx = cpu_apic_id + 1;
>     }
>     aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg));
>     aml_append(ctx, sb_scope);
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 4d2d40bab5..95199c8900 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1585,12 +1585,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>             aml_append(dev, aml_name_decl("_UID", aml_int(bus_num)));
>             aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
>             if (pci_bus_is_cxl(bus)) {
> -                struct Aml *pkg = aml_package(2);
> +                struct Aml *aml_pkg = aml_package(2);
> 
>                 aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0016")));
> -                aml_append(pkg, aml_eisaid("PNP0A08"));
> -                aml_append(pkg, aml_eisaid("PNP0A03"));
> -                aml_append(dev, aml_name_decl("_CID", pkg));
> +                aml_append(aml_pkg, aml_eisaid("PNP0A08"));
> +                aml_append(aml_pkg, aml_eisaid("PNP0A03"));
> +                aml_append(dev, aml_name_decl("_CID", aml_pkg));
>                 build_cxl_osc_method(dev);
>             } else if (pci_bus_is_express(bus)) {
>                 aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
> @@ -1783,14 +1783,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>         Object *pci_host = acpi_get_i386_pci_host();
> 
>         if (pci_host) {
> -            PCIBus *bus = PCI_HOST_BRIDGE(pci_host)->bus;
> -            Aml *scope = aml_scope("PCI0");
> +            PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
> +            Aml *ascope = aml_scope("PCI0");
>             /* Scan all PCI buses. Generate tables to support hotplug. */
> -            build_append_pci_bus_devices(scope, bus);
> -            if (object_property_find(OBJECT(bus), ACPI_PCIHP_PROP_BSEL)) {
> -                build_append_pcihp_slots(scope, bus);
> +            build_append_pci_bus_devices(ascope, pbus);
> +            if (object_property_find(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL)) {
> +                build_append_pcihp_slots(ascope, pbus);
>             }
> -            aml_append(sb_scope, scope);
> +            aml_append(sb_scope, ascope);
>         }
>     }
> 
> @@ -1842,10 +1842,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>         bool has_pcnt;
> 
>         Object *pci_host = acpi_get_i386_pci_host();
> -        PCIBus *bus = PCI_HOST_BRIDGE(pci_host)->bus;
> +        PCIBus *b = PCI_HOST_BRIDGE(pci_host)->bus;
> 
>         scope = aml_scope("\\_SB.PCI0");
> -        has_pcnt = build_append_notfication_callback(scope, bus);
> +        has_pcnt = build_append_notfication_callback(scope, b);
>         if (has_pcnt) {
>             aml_append(dsdt, scope);
>         }
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index b753705856..2a90601ac5 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -1423,13 +1423,14 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
>             if (!qemu_opts_validate(opts, qemu_smbios_type8_opts, errp)) {
>                 return;
>             }
> -            struct type8_instance *t;
> -            t = g_new0(struct type8_instance, 1);
> -            save_opt(&t->internal_reference, opts, "internal_reference");
> -            save_opt(&t->external_reference, opts, "external_reference");
> -            t->connector_type = qemu_opt_get_number(opts, "connector_type", 0);
> -            t->port_type = qemu_opt_get_number(opts, "port_type", 0);
> -            QTAILQ_INSERT_TAIL(&type8, t, next);
> +            struct type8_instance *t8_i;
> +            t8_i = g_new0(struct type8_instance, 1);
> +            save_opt(&t8_i->internal_reference, opts, "internal_reference");
> +            save_opt(&t8_i->external_reference, opts, "external_reference");
> +            t8_i->connector_type = qemu_opt_get_number(opts,
> +                                                       "connector_type", 0);
> +            t8_i->port_type = qemu_opt_get_number(opts, "port_type", 0);
> +            QTAILQ_INSERT_TAIL(&type8, t8_i, next);
>             return;
>         case 11:
>             if (!qemu_opts_validate(opts, qemu_smbios_type11_opts, errp)) {
> @@ -1452,27 +1453,27 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
>             type17.speed = qemu_opt_get_number(opts, "speed", 0);
>             return;
>         case 41: {
> -            struct type41_instance *t;
> +            struct type41_instance *t41_i;
>             Error *local_err = NULL;
> 
>             if (!qemu_opts_validate(opts, qemu_smbios_type41_opts, errp)) {
>                 return;
>             }
> -            t = g_new0(struct type41_instance, 1);
> -            save_opt(&t->designation, opts, "designation");
> -            t->kind = qapi_enum_parse(&type41_kind_lookup,
> -                                      qemu_opt_get(opts, "kind"),
> -                                      0, &local_err) + 1;
> -            t->kind |= 0x80;     /* enabled */
> +            t41_i = g_new0(struct type41_instance, 1);
> +            save_opt(&t41_i->designation, opts, "designation");
> +            t41_i->kind = qapi_enum_parse(&type41_kind_lookup,
> +                                          qemu_opt_get(opts, "kind"),
> +                                          0, &local_err) + 1;
> +            t41_i->kind |= 0x80;     /* enabled */
>             if (local_err != NULL) {
>                 error_propagate(errp, local_err);
> -                g_free(t);
> +                g_free(t41_i);
>                 return;
>             }
> -            t->instance = qemu_opt_get_number(opts, "instance", 1);
> -            save_opt(&t->pcidev, opts, "pcidev");
> +            t41_i->instance = qemu_opt_get_number(opts, "instance", 1);
> +            save_opt(&t41_i->pcidev, opts, "pcidev");
> 
> -            QTAILQ_INSERT_TAIL(&type41, t, next);
> +            QTAILQ_INSERT_TAIL(&type41, t41_i, next);
>             return;
>         }
>         default:
> -- 
> 2.41.0
> 



^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local
  2023-09-30  3:54   ` Ani Sinha
@ 2023-09-30  8:41     ` Markus Armbruster
  2023-10-02 10:49       ` Michael S. Tsirkin
  0 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2023-09-30  8:41 UTC (permalink / raw)
  To: Ani Sinha
  Cc: qemu-devel, Stefan Hajnoczi, Philippe Mathieu-Daude,
	Michael S. Tsirkin, imammedo

Ani Sinha <anisinha@redhat.com> writes:

>> On 29-Sep-2023, at 2:20 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> 
>> From: Ani Sinha <anisinha@redhat.com>
>> 
>> Code changes in acpi that addresses all compiler complaints coming from enabling
>> -Wshadow flags. Enabling -Wshadow catches cases of local variables shadowing
>> other local variables or parameters. These makes the code confusing and/or adds
>> bugs that are difficult to catch.  See also
>> 
>>    Subject: Help wanted for enabling -Wshadow=local
>>    Message-Id: <87r0mqlf9x.fsf@pond.sub.org>
>>    https://lore.kernel.org/qemu-devel/87r0mqlf9x.fsf@pond.sub.org
>> 
>> The code is tested to build with and without the flag turned on.
>> 
>> CC: Markus Armbruster <armbru@redhat.com>
>> CC: Philippe Mathieu-Daude <philmd@linaro.org>
>> CC: mst@redhat.com
>> CC: imammedo@redhat.com
>> Signed-off-by: Ani Sinha <anisinha@redhat.com>
>> Message-ID: <20230922124203.127110-1-anisinha@redhat.com>
>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>> [Commit message tweaked]
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> Thanks!
> Are you not going to pick up "hw/i386: changes towards enabling -Wshadow=local” ?

Your conversation with Michael looked unfinished to me, so I didn't
include your patch in my pull request.  I did add it to shadow-next.



^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local
  2023-09-30  8:41     ` Markus Armbruster
@ 2023-10-02 10:49       ` Michael S. Tsirkin
  0 siblings, 0 replies; 61+ messages in thread
From: Michael S. Tsirkin @ 2023-10-02 10:49 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Ani Sinha, qemu-devel, Stefan Hajnoczi, Philippe Mathieu-Daude, imammedo

On Sat, Sep 30, 2023 at 10:41:12AM +0200, Markus Armbruster wrote:
> Ani Sinha <anisinha@redhat.com> writes:
> 
> >> On 29-Sep-2023, at 2:20 PM, Markus Armbruster <armbru@redhat.com> wrote:
> >> 
> >> From: Ani Sinha <anisinha@redhat.com>
> >> 
> >> Code changes in acpi that addresses all compiler complaints coming from enabling
> >> -Wshadow flags. Enabling -Wshadow catches cases of local variables shadowing
> >> other local variables or parameters. These makes the code confusing and/or adds
> >> bugs that are difficult to catch.  See also
> >> 
> >>    Subject: Help wanted for enabling -Wshadow=local
> >>    Message-Id: <87r0mqlf9x.fsf@pond.sub.org>
> >>    https://lore.kernel.org/qemu-devel/87r0mqlf9x.fsf@pond.sub.org
> >> 
> >> The code is tested to build with and without the flag turned on.
> >> 
> >> CC: Markus Armbruster <armbru@redhat.com>
> >> CC: Philippe Mathieu-Daude <philmd@linaro.org>
> >> CC: mst@redhat.com
> >> CC: imammedo@redhat.com
> >> Signed-off-by: Ani Sinha <anisinha@redhat.com>
> >> Message-ID: <20230922124203.127110-1-anisinha@redhat.com>
> >> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> >> [Commit message tweaked]
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >
> > Thanks!
> > Are you not going to pick up "hw/i386: changes towards enabling -Wshadow=local” ?
> 
> Your conversation with Michael looked unfinished to me, so I didn't
> include your patch in my pull request.  I did add it to shadow-next.

Yes - I clarified what I meant. These patch just always
changed the name of the inner scope variable but that is not
always the best thing to do.

-- 
MST



^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PULL 00/56] -Wshadow=local patches patches for 2023-09-29
  2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
                   ` (55 preceding siblings ...)
  2023-09-29  8:50 ` [PULL 56/56] disas/m68k: clean up local variable shadowing Markus Armbruster
@ 2023-10-02 21:57 ` Stefan Hajnoczi
  56 siblings, 0 replies; 61+ messages in thread
From: Stefan Hajnoczi @ 2023-10-02 21:57 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, stefanha

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

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 61+ messages in thread

end of thread, other threads:[~2023-10-02 21:58 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-29  8:49 [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Markus Armbruster
2023-09-29  8:49 ` [PULL 01/56] migration/rdma: Fix save_page method to fail on polling error Markus Armbruster
2023-09-29  8:49 ` [PULL 02/56] migration: Clean up local variable shadowing Markus Armbruster
2023-09-29  8:50 ` [PULL 03/56] ui: " Markus Armbruster
2023-09-29  8:50 ` [PULL 04/56] block/dirty-bitmap: " Markus Armbruster
2023-09-29  8:50 ` [PULL 05/56] block/vdi: " Markus Armbruster
2023-09-29  8:50 ` [PULL 06/56] block: " Markus Armbruster
2023-09-29  8:50 ` [PULL 07/56] qobject atomics osdep: Make a few macros more hygienic Markus Armbruster
2023-09-29  8:50 ` [PULL 08/56] tcg: Clean up local variable shadowing Markus Armbruster
2023-09-29  8:50 ` [PULL 09/56] target/arm/tcg: " Markus Armbruster
2023-09-29  8:50 ` [PULL 10/56] target/arm/hvf: " Markus Armbruster
2023-09-29  8:50 ` [PULL 11/56] target/mips: " Markus Armbruster
2023-09-29  8:50 ` [PULL 12/56] target/m68k: " Markus Armbruster
2023-09-29  8:50 ` [PULL 13/56] target/tricore: " Markus Armbruster
2023-09-29  8:50 ` [PULL 14/56] hw/arm/armv7m: " Markus Armbruster
2023-09-29  8:50 ` [PULL 15/56] hw/arm/virt: " Markus Armbruster
2023-09-29  8:50 ` [PULL 16/56] hw/arm/allwinner: " Markus Armbruster
2023-09-29  8:50 ` [PULL 17/56] hw/m68k: " Markus Armbruster
2023-09-29  8:50 ` [PULL 18/56] hw/microblaze: " Markus Armbruster
2023-09-29  8:50 ` [PULL 19/56] hw/nios2: " Markus Armbruster
2023-09-29  8:50 ` [PULL 20/56] net/eth: " Markus Armbruster
2023-09-29  8:50 ` [PULL 21/56] crypto/cipher-gnutls.c: " Markus Armbruster
2023-09-29  8:50 ` [PULL 22/56] util/vhost-user-server: " Markus Armbruster
2023-09-29  8:50 ` [PULL 23/56] linux-user/strace: " Markus Armbruster
2023-09-29  8:50 ` [PULL 24/56] sysemu/device_tree: " Markus Armbruster
2023-09-29  8:50 ` [PULL 25/56] softmmu/memory: " Markus Armbruster
2023-09-29  8:50 ` [PULL 26/56] softmmu/physmem: " Markus Armbruster
2023-09-29  8:50 ` [PULL 27/56] hw/core/machine: " Markus Armbruster
2023-09-29  8:50 ` [PULL 28/56] hw/intc/openpic: " Markus Armbruster
2023-09-29  8:50 ` [PULL 29/56] hw/ppc: Clean up local variable shadowing in _FDT helper routine Markus Armbruster
2023-09-29  8:50 ` [PULL 30/56] pnv/psi: Clean up local variable shadowing Markus Armbruster
2023-09-29  8:50 ` [PULL 31/56] spapr: Clean up local variable shadowing in spapr_dt_cpus() Markus Armbruster
2023-09-29  8:50 ` [PULL 32/56] spapr: Clean up local variable shadowing in spapr_init_cpus() Markus Armbruster
2023-09-29  8:50 ` [PULL 33/56] spapr: Clean up local variable shadowing in spapr_get_fw_dev_path() Markus Armbruster
2023-09-29  8:50 ` [PULL 34/56] spapr/drc: Clean up local variable shadowing in rtas_ibm_configure_connector() Markus Armbruster
2023-09-29  8:50 ` [PULL 35/56] spapr/pci: Clean up local variable shadowing in spapr_phb_realize() Markus Armbruster
2023-09-29  8:50 ` [PULL 36/56] spapr/drc: Clean up local variable shadowing in prop_get_fdt() Markus Armbruster
2023-09-29  8:50 ` [PULL 37/56] test-throttle: don't shadow 'index' variable in do_test_accounting() Markus Armbruster
2023-09-29  8:50 ` [PULL 38/56] hw/acpi: changes towards enabling -Wshadow=local Markus Armbruster
2023-09-30  3:54   ` Ani Sinha
2023-09-30  8:41     ` Markus Armbruster
2023-10-02 10:49       ` Michael S. Tsirkin
2023-09-29  8:50 ` [PULL 39/56] hw/intc/arm_gicv3_its: Avoid shadowing variable in do_process_its_cmd() Markus Armbruster
2023-09-29  8:50 ` [PULL 40/56] hw/misc/arm_sysctl.c: Avoid shadowing local variable Markus Armbruster
2023-09-29  8:50 ` [PULL 41/56] hw/arm/smmuv3.c: Avoid shadowing variable Markus Armbruster
2023-09-29  8:50 ` [PULL 42/56] hw/arm/smmuv3-internal.h: Don't use locals in statement macros Markus Armbruster
2023-09-29  8:50 ` [PULL 43/56] aspeed/i2c: Clean up local variable shadowing Markus Armbruster
2023-09-29  8:50 ` [PULL 44/56] aspeed: " Markus Armbruster
2023-09-29  8:50 ` [PULL 45/56] aspeed/i3c: Rename variable shadowing a local Markus Armbruster
2023-09-29  8:50 ` [PULL 46/56] aspeed/timer: Clean up local variable shadowing Markus Armbruster
2023-09-29  8:50 ` [PULL 47/56] intel_iommu: Fix shadow local variables on "size" Markus Armbruster
2023-09-29  8:50 ` [PULL 48/56] crypto: remove shadowed 'ret' variable Markus Armbruster
2023-09-29  8:50 ` [PULL 49/56] seccomp: avoid shadowing of 'action' variable Markus Armbruster
2023-09-29  8:50 ` [PULL 50/56] qemu-nbd: changes towards enabling -Wshadow=local Markus Armbruster
2023-09-29  8:50 ` [PULL 51/56] hw/riscv: opentitan: Fixup local variables shadowing Markus Armbruster
2023-09-29  8:50 ` [PULL 52/56] target/riscv: cpu: " Markus Armbruster
2023-09-29  8:50 ` [PULL 53/56] target/riscv: vector_helper: " Markus Armbruster
2023-09-29  8:50 ` [PULL 54/56] softmmu/device_tree: " Markus Armbruster
2023-09-29  8:50 ` [PULL 55/56] hw/nvme: Clean up local variable shadowing in nvme_ns_init() Markus Armbruster
2023-09-29  8:50 ` [PULL 56/56] disas/m68k: clean up local variable shadowing Markus Armbruster
2023-10-02 21:57 ` [PULL 00/56] -Wshadow=local patches patches for 2023-09-29 Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.