qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 00/32] -Wshadow=local patches patches for 2023-10-06
@ 2023-10-06 11:36 Markus Armbruster
  2023-10-06 11:36 ` [PULL 01/32] hw/cxl: Fix local variable shadowing of cap_hdrs Markus Armbruster
                   ` (32 more replies)
  0 siblings, 33 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha

The following changes since commit 2f3913f4b2ad74baeb5a6f1d36efbd9ecdf1057d:

  Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging (2023-10-05 09:01:01 -0400)

are available in the Git repository at:

  https://repo.or.cz/qemu/armbru.git tags/pull-shadow-2023-10-06

for you to fetch changes up to 77c9f177e02dccd8688eba9550a4fb961742a638:

  linux-user/syscall.c: clean up local variable shadowing in xattr syscalls (2023-10-06 13:27:48 +0200)

----------------------------------------------------------------
-Wshadow=local patches patches for 2023-10-06

----------------------------------------------------------------
Ani Sinha (1):
      hw/i386: changes towards enabling -Wshadow=local for x86 machines

Cédric Le Goater (2):
      target/ppc: Rename variables to avoid local variable shadowing in VUPKPX
      target/ppc: Clean up local variable shadowing in kvm_arch_*_registers()

Jonathan Cameron (1):
      hw/cxl: Fix local variable shadowing of cap_hdrs

Laurent Vivier (5):
      linux-user/flatload: clean up local variable shadowing
      linux-user/mmap.c: clean up local variable shadowing
      linux-user/syscall.c: clean up local variable shadowing in do_ioctl_dm()
      linux-user/syscall.c: clean up local variable shadowing in TARGET_NR_getcpu
      linux-user/syscall.c: clean up local variable shadowing in xattr syscalls

Philippe Mathieu-Daudé (16):
      hw/audio/soundhw: Clean up global variable shadowing
      hw/ide/ahci: Clean up local variable shadowing
      net/net: Clean up global variable shadowing
      os-posix: Clean up global variable shadowing
      plugins/loader: Clean up global variable shadowing
      qemu-img: Clean up global variable shadowing
      qemu-io: Clean up global variable shadowing
      qom/object_interfaces: Clean up global variable shadowing
      semihosting: Clean up global variable shadowing
      ui/cocoa: Clean up global variable shadowing
      util/cutils: Clean up global variable shadowing in get_relocated_path()
      util/guest-random: Clean up global variable shadowing
      semihosting/arm-compat: Clean up local variable shadowing
      softmmu/vl: Clean up global variable shadowing
      sysemu/tpm: Clean up global variable shadowing
      trace/control: Clean up global variable shadowing

Song Gao (1):
      target/loongarch: Clean up local variable shadowing

Thomas Huth (6):
      audio/ossaudio: Fix compiler warning with -Wshadow
      hw/net/vhost_net: Silence compiler warning when compiling with -Wshadow
      hw/virtio/virtio-pci: Avoid compiler warning with -Wshadow
      hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
      dump: Silence compiler warning in dump code when compiling with -Wshadow
      hw/usb: Silence compiler warnings in USB code when compiling with -Wshadow

 include/hw/audio/soundhw.h      |  2 +-
 include/net/net.h               |  6 +++---
 include/qemu/guest-random.h     |  8 ++++----
 include/qemu/plugin.h           |  4 ++--
 include/qom/object_interfaces.h | 16 ++++++++--------
 include/semihosting/semihost.h  |  2 +-
 include/sysemu/os-posix.h       |  4 ++--
 include/sysemu/tpm.h            |  2 +-
 trace/control.h                 |  4 ++--
 audio/ossaudio.c                |  1 -
 dump/dump.c                     |  8 ++++----
 hw/audio/soundhw.c              |  6 +++---
 hw/cxl/cxl-device-utils.c       |  8 ++++----
 hw/i386/acpi-microvm.c          |  4 ++--
 hw/i386/pc.c                    |  1 -
 hw/i386/x86.c                   |  2 --
 hw/ide/ahci.c                   |  4 +---
 hw/loongarch/virt.c             |  2 +-
 hw/net/vhost_net.c              |  8 ++++----
 hw/usb/desc.c                   |  2 +-
 hw/usb/dev-hub.c                |  8 ++++----
 hw/usb/dev-storage.c            |  6 +++---
 hw/usb/hcd-xhci.c               | 10 +++++-----
 hw/usb/host-libusb.c            |  2 +-
 hw/virtio/vhost.c               |  8 ++++----
 hw/virtio/virtio-pci.c          | 20 ++++++++++----------
 linux-user/flatload.c           |  8 ++++----
 linux-user/mmap.c               |  6 +++---
 linux-user/syscall.c            | 36 ++++++++++++++++++------------------
 net/net.c                       | 14 +++++++-------
 os-posix.c                      | 12 ++++++------
 plugins/loader.c                |  4 ++--
 qemu-img.c                      | 22 +++++++++++-----------
 qemu-io.c                       |  4 ++--
 qom/object_interfaces.c         | 16 ++++++++--------
 semihosting/arm-compat-semi.c   |  5 ++++-
 semihosting/config.c            |  8 ++++----
 softmmu/tpm.c                   |  6 +++---
 softmmu/vl.c                    | 26 +++++++++++++-------------
 stubs/semihost.c                |  2 +-
 target/ppc/int_helper.c         | 12 ++++++------
 target/ppc/kvm.c                |  4 ----
 trace/control.c                 |  4 ++--
 util/cutils.c                   |  1 -
 util/guest-random.c             |  6 +++---
 ui/cocoa.m                      |  4 ++--
 46 files changed, 170 insertions(+), 178 deletions(-)

-- 
2.41.0



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

* [PULL 01/32] hw/cxl: Fix local variable shadowing of cap_hdrs
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 02/32] target/loongarch: Clean up local variable shadowing Markus Armbruster
                   ` (31 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Jonathan Cameron, Michael S . Tsirkin, Fan Ni

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Rename the version not burried in the macro to cap_h.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-ID: <20230925152258.5444-1-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/cxl/cxl-device-utils.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c
index 517f06d869..bd68328032 100644
--- a/hw/cxl/cxl-device-utils.c
+++ b/hw/cxl/cxl-device-utils.c
@@ -283,13 +283,13 @@ static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) { }
 
 void cxl_device_register_init_common(CXLDeviceState *cxl_dstate)
 {
-    uint64_t *cap_hdrs = cxl_dstate->caps_reg_state64;
+    uint64_t *cap_h = cxl_dstate->caps_reg_state64;
     const int cap_count = 3;
 
     /* CXL Device Capabilities Array Register */
-    ARRAY_FIELD_DP64(cap_hdrs, CXL_DEV_CAP_ARRAY, CAP_ID, 0);
-    ARRAY_FIELD_DP64(cap_hdrs, CXL_DEV_CAP_ARRAY, CAP_VERSION, 1);
-    ARRAY_FIELD_DP64(cap_hdrs, CXL_DEV_CAP_ARRAY, CAP_COUNT, cap_count);
+    ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_ID, 0);
+    ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_VERSION, 1);
+    ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_COUNT, cap_count);
 
     cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1, 2);
     device_reg_init_common(cxl_dstate);
-- 
2.41.0



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

* [PULL 02/32] target/loongarch: Clean up local variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
  2023-10-06 11:36 ` [PULL 01/32] hw/cxl: Fix local variable shadowing of cap_hdrs Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 03/32] target/ppc: Rename variables to avoid local variable shadowing in VUPKPX Markus Armbruster
                   ` (30 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Song Gao

From: Song Gao <gaosong@loongson.cn>

Fix:

  [1839/2601] Compiling C object libqemu-loongarch64-softmmu.fa.p/hw_loongarch_virt.c.o
  ../hw/loongarch/virt.c: In function 'loongarch_irq_init':
  ../hw/loongarch/virt.c:665:14: warning: declaration of 'i' shadows a previous local [-Wshadow=compatible-local]
       for (int i = 0; i < num; i++) {
                ^
  ../hw/loongarch/virt.c:582:19: note: shadowed declaration is here
       int cpu, pin, i, start, num;

Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-ID: <20230926071253.3601021-1-gaosong@loongson.cn>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/loongarch/virt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 2629128aed..b0a004f860 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -662,7 +662,7 @@ static void loongarch_irq_init(LoongArchMachineState *lams)
                             sysbus_mmio_get_region(d, 2));
 
     /* Connect pch_pic irqs to extioi */
-    for (int i = 0; i < num; i++) {
+    for (i = 0; i < num; i++) {
         qdev_connect_gpio_out(DEVICE(d), i, qdev_get_gpio_in(extioi, i));
     }
 
-- 
2.41.0



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

* [PULL 03/32] target/ppc: Rename variables to avoid local variable shadowing in VUPKPX
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
  2023-10-06 11:36 ` [PULL 01/32] hw/cxl: Fix local variable shadowing of cap_hdrs Markus Armbruster
  2023-10-06 11:36 ` [PULL 02/32] target/loongarch: Clean up local variable shadowing Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 04/32] hw/i386: changes towards enabling -Wshadow=local for x86 machines Markus Armbruster
                   ` (29 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Michael Tokarev

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

and fix such warnings :

  ../target/ppc/int_helper.c: In function ‘helper_vupklpx’:
  ../target/ppc/int_helper.c:2025:21: warning: declaration of ‘r’ shadows a parameter [-Wshadow=local]
   2025 |             uint8_t r = (e >> 10) & 0x1f;                               \
        |                     ^
  ../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
   2033 | VUPKPX(lpx, UPKLO)
        | ^~~~~~
  ../target/ppc/int_helper.c:2017:41: note: shadowed declaration is here
   2017 |     void helper_vupk##suffix(ppc_avr_t *r, ppc_avr_t *b)                \
        |                              ~~~~~~~~~~~^
  ../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
   2033 | VUPKPX(lpx, UPKLO)
        | ^~~~~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20230929083143.234553-1-clg@kaod.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/ppc/int_helper.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index 6fd00684a5..0a5c3e78a4 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -2020,13 +2020,13 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
         ppc_avr_t result;                                               \
                                                                         \
         for (i = 0; i < ARRAY_SIZE(r->u32); i++) {                      \
-            uint16_t e = b->u16[hi ? i : i + 4];                        \
-            uint8_t a = (e >> 15) ? 0xff : 0;                           \
-            uint8_t r = (e >> 10) & 0x1f;                               \
-            uint8_t g = (e >> 5) & 0x1f;                                \
-            uint8_t b = e & 0x1f;                                       \
+            uint16_t _e = b->u16[hi ? i : i + 4];                       \
+            uint8_t _a = (_e >> 15) ? 0xff : 0;                         \
+            uint8_t _r = (_e >> 10) & 0x1f;                             \
+            uint8_t _g = (_e >> 5) & 0x1f;                              \
+            uint8_t _b = _e & 0x1f;                                     \
                                                                         \
-            result.u32[i] = (a << 24) | (r << 16) | (g << 8) | b;       \
+            result.u32[i] = (_a << 24) | (_r << 16) | (_g << 8) | _b;   \
         }                                                               \
         *r = result;                                                    \
     }
-- 
2.41.0



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

* [PULL 04/32] hw/i386: changes towards enabling -Wshadow=local for x86 machines
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (2 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 03/32] target/ppc: Rename variables to avoid local variable shadowing in VUPKPX Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 05/32] audio/ossaudio: Fix compiler warning with -Wshadow Markus Armbruster
                   ` (28 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Ani Sinha, Philippe Mathieu-Daude, mst,
	Daniel P . Berrangé, Peter Xu

From: Ani Sinha <anisinha@redhat.com>

Code changes 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

CC: Markus Armbruster <armbru@redhat.com>
CC: Philippe Mathieu-Daude <philmd@linaro.org>
CC: mst@redhat.com

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-ID: <20231003102803.6163-1-anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/i386/acpi-microvm.c | 4 ++--
 hw/i386/pc.c           | 1 -
 hw/i386/x86.c          | 2 --
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c
index fec22d85c1..2909a73933 100644
--- a/hw/i386/acpi-microvm.c
+++ b/hw/i386/acpi-microvm.c
@@ -55,8 +55,8 @@ static void acpi_dsdt_add_virtio(Aml *scope,
 
     bus = sysbus_get_default();
     QTAILQ_FOREACH(kid, &bus->children, sibling) {
-        DeviceState *dev = kid->child;
-        Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MMIO);
+        Object *obj = object_dynamic_cast(OBJECT(kid->child),
+                                          TYPE_VIRTIO_MMIO);
 
         if (obj) {
             VirtIOMMIOProxy *mmio = VIRTIO_MMIO(obj);
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index aad7e8ccd1..bb3854d1d0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1049,7 +1049,6 @@ void pc_memory_init(PCMachineState *pcms,
 
     if (machine->device_memory) {
         uint64_t *val = g_malloc(sizeof(*val));
-        PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
         uint64_t res_mem_end = machine->device_memory->base;
 
         if (!pcmc->broken_reserved_end) {
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index f034df8bf6..b3d054889b 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -365,8 +365,6 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
 
     cpu_slot = x86_find_cpu_slot(MACHINE(x86ms), cpu->apic_id, &idx);
     if (!cpu_slot) {
-        MachineState *ms = MACHINE(x86ms);
-
         x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids);
         error_setg(errp,
             "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with"
-- 
2.41.0



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

* [PULL 05/32] audio/ossaudio: Fix compiler warning with -Wshadow
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (3 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 04/32] hw/i386: changes towards enabling -Wshadow=local for x86 machines Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 06/32] hw/net/vhost_net: Silence compiler warning when compiling " Markus Armbruster
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth, Philippe Mathieu-Daudé

From: Thomas Huth <thuth@redhat.com>

The "err" variable is only used twice in this code, in a very
local fashion of first assigning it and then checking it in the
next line. So there is no need to declare this variable a second
time in the innermost block, we can re-use the variable that is
declared at the beginning of the function. This fixes the compiler
warning that occurs with "-Wshadow".

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231004083900.95856-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 audio/ossaudio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 3f31852371..c5858284a1 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -549,7 +549,6 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
                        hw->size_emul);
             hw->buf_emul = NULL;
         } else {
-            int err;
             int trig = 0;
             if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
                 oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n");
-- 
2.41.0



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

* [PULL 06/32] hw/net/vhost_net: Silence compiler warning when compiling with -Wshadow
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (4 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 05/32] audio/ossaudio: Fix compiler warning with -Wshadow Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 07/32] hw/virtio/virtio-pci: Avoid compiler warning " Markus Armbruster
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth, Michael S . Tsirkin

From: Thomas Huth <thuth@redhat.com>

Rename the innermost local variables to avoid compiler warnings
with "-Wshadow".

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231004084939.96349-1-thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/net/vhost_net.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 57427a3997..e8e1661646 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -313,8 +313,8 @@ fail:
                 /* Queue might not be ready for start */
                 continue;
             }
-            int r = vhost_net_set_backend(&net->dev, &file);
-            assert(r >= 0);
+            int ret = vhost_net_set_backend(&net->dev, &file);
+            assert(ret >= 0);
         }
     }
     if (net->nc->info->poll) {
@@ -629,8 +629,8 @@ err_start:
     if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
         file.fd = VHOST_FILE_UNBIND;
         file.index = idx;
-        int r = vhost_net_set_backend(&net->dev, &file);
-        assert(r >= 0);
+        int ret = vhost_net_set_backend(&net->dev, &file);
+        assert(ret >= 0);
     }
 
     vhost_dev_stop(&net->dev, vdev, false);
-- 
2.41.0



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

* [PULL 07/32] hw/virtio/virtio-pci: Avoid compiler warning with -Wshadow
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (5 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 06/32] hw/net/vhost_net: Silence compiler warning when compiling " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 08/32] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow Markus Armbruster
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth, Philippe Mathieu-Daudé

From: Thomas Huth <thuth@redhat.com>

"len" is used as parameter of the functions virtio_write_config()
and virtio_read_config(), and additionally as a local variable,
so this causes a compiler warning when compiling with "-Wshadow"
and can be confusing for the reader. Rename the local variables
to "caplen" to avoid this problem.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231004095302.99037-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/virtio/virtio-pci.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index edbc0daa18..abebd0075a 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -780,15 +780,15 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
                                                                   pci_cfg_data),
                        sizeof cfg->pci_cfg_data)) {
         uint32_t off;
-        uint32_t len;
+        uint32_t caplen;
 
         cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);
         off = le32_to_cpu(cfg->cap.offset);
-        len = le32_to_cpu(cfg->cap.length);
+        caplen = le32_to_cpu(cfg->cap.length);
 
-        if (len == 1 || len == 2 || len == 4) {
-            assert(len <= sizeof cfg->pci_cfg_data);
-            virtio_address_space_write(proxy, off, cfg->pci_cfg_data, len);
+        if (caplen == 1 || caplen == 2 || caplen == 4) {
+            assert(caplen <= sizeof cfg->pci_cfg_data);
+            virtio_address_space_write(proxy, off, cfg->pci_cfg_data, caplen);
         }
     }
 }
@@ -804,15 +804,15 @@ static uint32_t virtio_read_config(PCIDevice *pci_dev,
                                                                   pci_cfg_data),
                        sizeof cfg->pci_cfg_data)) {
         uint32_t off;
-        uint32_t len;
+        uint32_t caplen;
 
         cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);
         off = le32_to_cpu(cfg->cap.offset);
-        len = le32_to_cpu(cfg->cap.length);
+        caplen = le32_to_cpu(cfg->cap.length);
 
-        if (len == 1 || len == 2 || len == 4) {
-            assert(len <= sizeof cfg->pci_cfg_data);
-            virtio_address_space_read(proxy, off, cfg->pci_cfg_data, len);
+        if (caplen == 1 || caplen == 2 || caplen == 4) {
+            assert(caplen <= sizeof cfg->pci_cfg_data);
+            virtio_address_space_read(proxy, off, cfg->pci_cfg_data, caplen);
         }
     }
 
-- 
2.41.0



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

* [PULL 08/32] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (6 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 07/32] hw/virtio/virtio-pci: Avoid compiler warning " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 09/32] dump: Silence compiler warning in dump code when compiling with -Wshadow Markus Armbruster
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth, Michael S . Tsirkin, Michael Tokarev

From: Thomas Huth <thuth@redhat.com>

Rename a variable in vhost_dev_sync_region() and remove a superfluous
declaration in vhost_commit() to make this code compilable with "-Wshadow".

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231004114809.105672-1-thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/virtio/vhost.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e2f6ffb446..9cfac40fde 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -66,12 +66,12 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
                                   uint64_t mfirst, uint64_t mlast,
                                   uint64_t rfirst, uint64_t rlast)
 {
-    vhost_log_chunk_t *log = dev->log->log;
+    vhost_log_chunk_t *dev_log = dev->log->log;
 
     uint64_t start = MAX(mfirst, rfirst);
     uint64_t end = MIN(mlast, rlast);
-    vhost_log_chunk_t *from = log + start / VHOST_LOG_CHUNK;
-    vhost_log_chunk_t *to = log + end / VHOST_LOG_CHUNK + 1;
+    vhost_log_chunk_t *from = dev_log + start / VHOST_LOG_CHUNK;
+    vhost_log_chunk_t *to = dev_log + end / VHOST_LOG_CHUNK + 1;
     uint64_t addr = QEMU_ALIGN_DOWN(start, VHOST_LOG_CHUNK);
 
     if (end < start) {
@@ -549,7 +549,7 @@ static void vhost_commit(MemoryListener *listener)
         changed = true;
     } else {
         /* Same size, lets check the contents */
-        for (int i = 0; i < n_old_sections; i++) {
+        for (i = 0; i < n_old_sections; i++) {
             if (!MemoryRegionSection_eq(&old_sections[i],
                                         &dev->mem_sections[i])) {
                 changed = true;
-- 
2.41.0



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

* [PULL 09/32] dump: Silence compiler warning in dump code when compiling with -Wshadow
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (7 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 08/32] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 10/32] hw/audio/soundhw: Clean up global variable shadowing Markus Armbruster
                   ` (23 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Thomas Huth, Philippe Mathieu-Daudé,
	Michael Tokarev

From: Thomas Huth <thuth@redhat.com>

Rename a variable to make this code compilable with -Wshadow.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231004131338.215081-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 dump/dump.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dump/dump.c b/dump/dump.c
index d4ef713cd0..d3578ddc62 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1872,20 +1872,20 @@ static void dump_init(DumpState *s, int fd, bool has_format,
     if (vmci) {
         uint64_t addr, note_head_size, name_size, desc_size;
         uint32_t size;
-        uint16_t format;
+        uint16_t guest_format;
 
         note_head_size = dump_is_64bit(s) ?
             sizeof(Elf64_Nhdr) : sizeof(Elf32_Nhdr);
 
-        format = le16_to_cpu(vmci->vmcoreinfo.guest_format);
+        guest_format = le16_to_cpu(vmci->vmcoreinfo.guest_format);
         size = le32_to_cpu(vmci->vmcoreinfo.size);
         addr = le64_to_cpu(vmci->vmcoreinfo.paddr);
         if (!vmci->has_vmcoreinfo) {
             warn_report("guest note is not present");
         } else if (size < note_head_size || size > MAX_GUEST_NOTE_SIZE) {
             warn_report("guest note size is invalid: %" PRIu32, size);
-        } else if (format != FW_CFG_VMCOREINFO_FORMAT_ELF) {
-            warn_report("guest note format is unsupported: %" PRIu16, format);
+        } else if (guest_format != FW_CFG_VMCOREINFO_FORMAT_ELF) {
+            warn_report("guest note format is unsupported: %" PRIu16, guest_format);
         } else {
             s->guest_note = g_malloc(size + 1); /* +1 for adding \0 */
             cpu_physical_memory_read(addr, s->guest_note, size);
-- 
2.41.0



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

* [PULL 10/32] hw/audio/soundhw: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (8 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 09/32] dump: Silence compiler warning in dump code when compiling with -Wshadow Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 11/32] hw/ide/ahci: Clean up local " Markus Armbruster
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson,
	Thomas Huth

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

Fix:

  hw/audio/soundhw.c:86:33: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  void select_soundhw(const char *optarg, const char *audiodev)
                                  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-2-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/hw/audio/soundhw.h | 2 +-
 hw/audio/soundhw.c         | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/hw/audio/soundhw.h b/include/hw/audio/soundhw.h
index 270717a06a..474c5ff94e 100644
--- a/include/hw/audio/soundhw.h
+++ b/include/hw/audio/soundhw.h
@@ -8,6 +8,6 @@ void deprecated_register_soundhw(const char *name, const char *descr,
 
 void soundhw_init(void);
 void show_valid_soundhw(void);
-void select_soundhw(const char *optarg, const char *audiodev);
+void select_soundhw(const char *name, const char *audiodev);
 
 #endif
diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c
index 94d9463e42..b387b0ef7d 100644
--- a/hw/audio/soundhw.c
+++ b/hw/audio/soundhw.c
@@ -83,7 +83,7 @@ void show_valid_soundhw(void)
 static struct soundhw *selected = NULL;
 static const char *audiodev_id;
 
-void select_soundhw(const char *optarg, const char *audiodev)
+void select_soundhw(const char *name, const char *audiodev)
 {
     struct soundhw *c;
 
@@ -92,7 +92,7 @@ void select_soundhw(const char *optarg, const char *audiodev)
     }
 
     for (c = soundhw; c->name; ++c) {
-        if (g_str_equal(c->name, optarg)) {
+        if (g_str_equal(c->name, name)) {
             selected = c;
             audiodev_id = audiodev;
             break;
@@ -100,7 +100,7 @@ void select_soundhw(const char *optarg, const char *audiodev)
     }
 
     if (!c->name) {
-        error_report("Unknown sound card name `%s'", optarg);
+        error_report("Unknown sound card name `%s'", name);
         show_valid_soundhw();
         exit(1);
     }
-- 
2.41.0



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

* [PULL 11/32] hw/ide/ahci: Clean up local variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (9 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 10/32] hw/audio/soundhw: Clean up global variable shadowing Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 12/32] net/net: Clean up global " Markus Armbruster
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson,
	John Snow

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

Fix:

  hw/ide/ahci.c:1577:23: error: declaration shadows a local variable [-Werror,-Wshadow]
            IDEState *s = &ad->port.ifs[j];
                      ^
  hw/ide/ahci.c:1569:29: note: previous declaration is here
    void ahci_uninit(AHCIState *s)
                                ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-3-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ide/ahci.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index d0a774bc17..fcc5476e9e 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1622,9 +1622,7 @@ void ahci_uninit(AHCIState *s)
         AHCIDevice *ad = &s->dev[i];
 
         for (j = 0; j < 2; j++) {
-            IDEState *s = &ad->port.ifs[j];
-
-            ide_exit(s);
+            ide_exit(&ad->port.ifs[j]);
         }
         object_unparent(OBJECT(&ad->port));
     }
-- 
2.41.0



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

* [PULL 12/32] net/net: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (10 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 11/32] hw/ide/ahci: Clean up local " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 13/32] os-posix: " Markus Armbruster
                   ` (20 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson,
	Thomas Huth

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

Fix:

  net/net.c:1680:35: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  bool netdev_is_modern(const char *optarg)
                                    ^
  net/net.c:1714:38: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  void netdev_parse_modern(const char *optarg)
                                       ^
  net/net.c:1728:60: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  void net_client_parse(QemuOptsList *opts_list, const char *optarg)
                                                             ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-4-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/net/net.h |  6 +++---
 net/net.c         | 14 +++++++-------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/net/net.h b/include/net/net.h
index 330d285930..2fb1c9181c 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -247,9 +247,9 @@ extern const char *host_net_devices[];
 
 /* from net.c */
 extern NetClientStateList net_clients;
-bool netdev_is_modern(const char *optarg);
-void netdev_parse_modern(const char *optarg);
-void net_client_parse(QemuOptsList *opts_list, const char *str);
+bool netdev_is_modern(const char *optstr);
+void netdev_parse_modern(const char *optstr);
+void net_client_parse(QemuOptsList *opts_list, const char *optstr);
 void show_netdevs(void);
 void net_init_clients(void);
 void net_check_clients(void);
diff --git a/net/net.c b/net/net.c
index 1c0bfdaa6c..c0c0cbe99e 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1677,7 +1677,7 @@ void net_init_clients(void)
  * Modern syntax is to be parsed with netdev_parse_modern().
  * Traditional syntax is to be parsed with net_client_parse().
  */
-bool netdev_is_modern(const char *optarg)
+bool netdev_is_modern(const char *optstr)
 {
     QemuOpts *opts;
     bool is_modern;
@@ -1689,13 +1689,13 @@ bool netdev_is_modern(const char *optarg)
         .desc = { { } },
     };
 
-    if (optarg[0] == '{') {
+    if (optstr[0] == '{') {
         /* This is JSON, which means it's modern syntax */
         return true;
     }
 
     opts = qemu_opts_create(&dummy_opts, NULL, false, &error_abort);
-    qemu_opts_do_parse(opts, optarg, dummy_opts.implied_opt_name,
+    qemu_opts_do_parse(opts, optstr, dummy_opts.implied_opt_name,
                        &error_abort);
     type = qemu_opt_get(opts, "type");
     is_modern = !g_strcmp0(type, "stream") || !g_strcmp0(type, "dgram");
@@ -1711,12 +1711,12 @@ bool netdev_is_modern(const char *optarg)
  * netdev_parse_modern() appends to @nd_queue, whereas net_client_parse()
  * appends to @qemu_netdev_opts.
  */
-void netdev_parse_modern(const char *optarg)
+void netdev_parse_modern(const char *optstr)
 {
     Visitor *v;
     NetdevQueueEntry *nd;
 
-    v = qobject_input_visitor_new_str(optarg, "type", &error_fatal);
+    v = qobject_input_visitor_new_str(optstr, "type", &error_fatal);
     nd = g_new(NetdevQueueEntry, 1);
     visit_type_Netdev(v, NULL, &nd->nd, &error_fatal);
     visit_free(v);
@@ -1725,9 +1725,9 @@ void netdev_parse_modern(const char *optarg)
     QSIMPLEQ_INSERT_TAIL(&nd_queue, nd, entry);
 }
 
-void net_client_parse(QemuOptsList *opts_list, const char *optarg)
+void net_client_parse(QemuOptsList *opts_list, const char *optstr)
 {
-    if (!qemu_opts_parse_noisily(opts_list, optarg, true)) {
+    if (!qemu_opts_parse_noisily(opts_list, optstr, true)) {
         exit(1);
     }
 }
-- 
2.41.0



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

* [PULL 13/32] os-posix: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (11 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 12/32] net/net: Clean up global " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 14/32] plugins/loader: " Markus Armbruster
                   ` (19 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Eric Blake,
	Richard Henderson

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

Fix:

  os-posix.c:103:31: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  bool os_set_runas(const char *optarg)
                                ^
  os-posix.c:176:32: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  void os_set_chroot(const char *optarg)
                                 ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-5-philmd@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/sysemu/os-posix.h |  4 ++--
 os-posix.c                | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
index 6dfdcbb086..dff32ae185 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -49,8 +49,8 @@ void os_setup_signal_handling(void);
 int os_set_daemonize(bool d);
 bool is_daemonized(void);
 void os_daemonize(void);
-bool os_set_runas(const char *optarg);
-void os_set_chroot(const char *optarg);
+bool os_set_runas(const char *user_id);
+void os_set_chroot(const char *path);
 void os_setup_post(void);
 int os_mlock(void);
 
diff --git a/os-posix.c b/os-posix.c
index f90dfda9b0..52ef6990ff 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -94,13 +94,13 @@ static uid_t user_uid = (uid_t)-1; /*   -1      -1        >=0    */
 static gid_t user_gid = (gid_t)-1; /*   -1      -1        >=0    */
 
 /*
- * Prepare to change user ID. optarg can be one of 3 forms:
+ * Prepare to change user ID. user_id can be one of 3 forms:
  *   - a username, in which case user ID will be changed to its uid,
  *     with primary and supplementary groups set up too;
  *   - a numeric uid, in which case only the uid will be set;
  *   - a pair of numeric uid:gid.
  */
-bool os_set_runas(const char *optarg)
+bool os_set_runas(const char *user_id)
 {
     unsigned long lv;
     const char *ep;
@@ -108,14 +108,14 @@ bool os_set_runas(const char *optarg)
     gid_t got_gid;
     int rc;
 
-    user_pwd = getpwnam(optarg);
+    user_pwd = getpwnam(user_id);
     if (user_pwd) {
         user_uid = -1;
         user_gid = -1;
         return true;
     }
 
-    rc = qemu_strtoul(optarg, &ep, 0, &lv);
+    rc = qemu_strtoul(user_id, &ep, 0, &lv);
     got_uid = lv; /* overflow here is ID in C99 */
     if (rc || *ep != ':' || got_uid != lv || got_uid == (uid_t)-1) {
         return false;
@@ -173,9 +173,9 @@ static void change_process_uid(void)
 
 static const char *chroot_dir;
 
-void os_set_chroot(const char *optarg)
+void os_set_chroot(const char *path)
 {
-    chroot_dir = optarg;
+    chroot_dir = path;
 }
 
 static void change_root(void)
-- 
2.41.0



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

* [PULL 14/32] plugins/loader: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (12 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 13/32] os-posix: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 15/32] qemu-img: " Markus Armbruster
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson

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

Fix:

  include/qemu/plugin.h:245:54: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static inline void qemu_plugin_opt_parse(const char *optarg,
                                                       ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-6-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/qemu/plugin.h | 4 ++--
 plugins/loader.c      | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index bc0781cab8..7fdc3a4849 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -50,7 +50,7 @@ static inline void qemu_plugin_add_opts(void)
     qemu_add_opts(&qemu_plugin_opts);
 }
 
-void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head);
+void qemu_plugin_opt_parse(const char *optstr, QemuPluginList *head);
 int qemu_plugin_load_list(QemuPluginList *head, Error **errp);
 
 union qemu_plugin_cb_sig {
@@ -242,7 +242,7 @@ void qemu_plugin_user_postfork(bool is_child);
 static inline void qemu_plugin_add_opts(void)
 { }
 
-static inline void qemu_plugin_opt_parse(const char *optarg,
+static inline void qemu_plugin_opt_parse(const char *optstr,
                                          QemuPluginList *head)
 {
     error_report("plugin interface not enabled in this build");
diff --git a/plugins/loader.c b/plugins/loader.c
index 809f3f9b13..734c11cae0 100644
--- a/plugins/loader.c
+++ b/plugins/loader.c
@@ -140,12 +140,12 @@ static int plugin_add(void *opaque, const char *name, const char *value,
     return 0;
 }
 
-void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head)
+void qemu_plugin_opt_parse(const char *optstr, QemuPluginList *head)
 {
     struct qemu_plugin_parse_arg arg;
     QemuOpts *opts;
 
-    opts = qemu_opts_parse_noisily(qemu_find_opts("plugin"), optarg, true);
+    opts = qemu_opts_parse_noisily(qemu_find_opts("plugin"), optstr, true);
     if (opts == NULL) {
         exit(1);
     }
-- 
2.41.0



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

* [PULL 15/32] qemu-img: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (13 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 14/32] plugins/loader: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 16/32] qemu-io: " Markus Armbruster
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Eric Blake,
	Richard Henderson

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

Fix:

  qemu-img.c:247:46: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static bool is_valid_option_list(const char *optarg)
                                               ^
  qemu-img.c:265:53: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static int accumulate_options(char **options, char *optarg)
                                                      ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-7-philmd@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-img.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index a48edb7101..6068ab0d27 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -235,25 +235,25 @@ void help(void)
 }
 
 /*
- * Is @optarg safe for accumulate_options()?
+ * Is @list safe for accumulate_options()?
  * It is when multiple of them can be joined together separated by ','.
- * To make that work, @optarg must not start with ',' (or else a
+ * To make that work, @list must not start with ',' (or else a
  * separating ',' preceding it gets escaped), and it must not end with
  * an odd number of ',' (or else a separating ',' following it gets
  * escaped), or be empty (or else a separating ',' preceding it can
  * escape a separating ',' following it).
  * 
  */
-static bool is_valid_option_list(const char *optarg)
+static bool is_valid_option_list(const char *list)
 {
-    size_t len = strlen(optarg);
+    size_t len = strlen(list);
     size_t i;
 
-    if (!optarg[0] || optarg[0] == ',') {
+    if (!list[0] || list[0] == ',') {
         return false;
     }
 
-    for (i = len; i > 0 && optarg[i - 1] == ','; i--) {
+    for (i = len; i > 0 && list[i - 1] == ','; i--) {
     }
     if ((len - i) % 2) {
         return false;
@@ -262,19 +262,19 @@ static bool is_valid_option_list(const char *optarg)
     return true;
 }
 
-static int accumulate_options(char **options, char *optarg)
+static int accumulate_options(char **options, char *list)
 {
     char *new_options;
 
-    if (!is_valid_option_list(optarg)) {
-        error_report("Invalid option list: %s", optarg);
+    if (!is_valid_option_list(list)) {
+        error_report("Invalid option list: %s", list);
         return -1;
     }
 
     if (!*options) {
-        *options = g_strdup(optarg);
+        *options = g_strdup(list);
     } else {
-        new_options = g_strdup_printf("%s,%s", *options, optarg);
+        new_options = g_strdup_printf("%s,%s", *options, list);
         g_free(*options);
         *options = new_options;
     }
-- 
2.41.0



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

* [PULL 16/32] qemu-io: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (14 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 15/32] qemu-img: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 17/32] qom/object_interfaces: " Markus Armbruster
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Eric Blake,
	Richard Henderson

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

Fix:

  qemu-io.c:478:36: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static void add_user_command(char *optarg)
                                     ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-8-philmd@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index 2bd7bfb650..050c70835f 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -475,10 +475,10 @@ static int command_loop(void)
     return last_error;
 }
 
-static void add_user_command(char *optarg)
+static void add_user_command(char *user_cmd)
 {
     cmdline = g_renew(char *, cmdline, ++ncmdline);
-    cmdline[ncmdline-1] = optarg;
+    cmdline[ncmdline - 1] = user_cmd;
 }
 
 static void reenable_tty_echo(void)
-- 
2.41.0



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

* [PULL 17/32] qom/object_interfaces: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (15 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 16/32] qemu-io: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 18/32] semihosting: " Markus Armbruster
                   ` (15 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson

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

Fix:

  qom/object_interfaces.c:262:53: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
                                                      ^
  qom/object_interfaces.c:298:46: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  bool user_creatable_add_from_str(const char *optarg, Error **errp)
                                               ^
  qom/object_interfaces.c:313:49: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  void user_creatable_process_cmdline(const char *optarg)
                                                  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-9-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/qom/object_interfaces.h | 16 ++++++++--------
 qom/object_interfaces.c         | 16 ++++++++--------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 81541e2080..02b11a7ef0 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -99,7 +99,7 @@ void user_creatable_add_qapi(ObjectOptions *options, Error **errp);
 
 /**
  * user_creatable_parse_str:
- * @optarg: the object definition string as passed on the command line
+ * @str: the object definition string as passed on the command line
  * @errp: if an error occurs, a pointer to an area to store the error
  *
  * Parses the option for the user creatable object with a keyval parser and
@@ -110,14 +110,14 @@ void user_creatable_add_qapi(ObjectOptions *options, Error **errp);
  * Returns: ObjectOptions on success, NULL when an error occurred (*errp is set
  * then) or help was printed (*errp is not set).
  */
-ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp);
+ObjectOptions *user_creatable_parse_str(const char *str, Error **errp);
 
 /**
  * user_creatable_add_from_str:
- * @optarg: the object definition string as passed on the command line
+ * @str: the object definition string as passed on the command line
  * @errp: if an error occurs, a pointer to an area to store the error
  *
- * Create an instance of the user creatable object by parsing optarg
+ * Create an instance of the user creatable object by parsing @str
  * with a keyval parser and implicit key 'qom-type', converting the
  * result to ObjectOptions and calling into qmp_object_add().
  *
@@ -126,13 +126,13 @@ ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp);
  * Returns: true when an object was successfully created, false when an error
  * occurred (*errp is set then) or help was printed (*errp is not set).
  */
-bool user_creatable_add_from_str(const char *optarg, Error **errp);
+bool user_creatable_add_from_str(const char *str, Error **errp);
 
 /**
  * user_creatable_process_cmdline:
- * @optarg: the object definition string as passed on the command line
+ * @cmdline: the object definition string as passed on the command line
  *
- * Create an instance of the user creatable object by parsing optarg
+ * Create an instance of the user creatable object by parsing @cmdline
  * with a keyval parser and implicit key 'qom-type', converting the
  * result to ObjectOptions and calling into qmp_object_add().
  *
@@ -141,7 +141,7 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp);
  * This function is only meant to be called during command line parsing.
  * It exits the process on failure or after printing help.
  */
-void user_creatable_process_cmdline(const char *optarg);
+void user_creatable_process_cmdline(const char *cmdline);
 
 /**
  * user_creatable_print_help:
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 7d31589b04..e0833c8bfe 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -259,7 +259,7 @@ static void user_creatable_print_help_from_qdict(QDict *args)
     }
 }
 
-ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
+ObjectOptions *user_creatable_parse_str(const char *str, Error **errp)
 {
     ERRP_GUARD();
     QObject *obj;
@@ -267,14 +267,14 @@ ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
     Visitor *v;
     ObjectOptions *options;
 
-    if (optarg[0] == '{') {
-        obj = qobject_from_json(optarg, errp);
+    if (str[0] == '{') {
+        obj = qobject_from_json(str, errp);
         if (!obj) {
             return NULL;
         }
         v = qobject_input_visitor_new(obj);
     } else {
-        QDict *args = keyval_parse(optarg, "qom-type", &help, errp);
+        QDict *args = keyval_parse(str, "qom-type", &help, errp);
         if (*errp) {
             return NULL;
         }
@@ -295,12 +295,12 @@ ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
     return options;
 }
 
-bool user_creatable_add_from_str(const char *optarg, Error **errp)
+bool user_creatable_add_from_str(const char *str, Error **errp)
 {
     ERRP_GUARD();
     ObjectOptions *options;
 
-    options = user_creatable_parse_str(optarg, errp);
+    options = user_creatable_parse_str(str, errp);
     if (!options) {
         return false;
     }
@@ -310,9 +310,9 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp)
     return !*errp;
 }
 
-void user_creatable_process_cmdline(const char *optarg)
+void user_creatable_process_cmdline(const char *cmdline)
 {
-    if (!user_creatable_add_from_str(optarg, &error_fatal)) {
+    if (!user_creatable_add_from_str(cmdline, &error_fatal)) {
         /* Help was printed */
         exit(EXIT_SUCCESS);
     }
-- 
2.41.0



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

* [PULL 18/32] semihosting: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (16 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 17/32] qom/object_interfaces: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 19/32] ui/cocoa: " Markus Armbruster
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Alex Bennée,
	Richard Henderson

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

Fix:

  semihosting/config.c:134:49: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  int qemu_semihosting_config_options(const char *optarg)
                                                  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-10-philmd@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/semihosting/semihost.h | 2 +-
 semihosting/config.c           | 8 ++++----
 stubs/semihost.c               | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/semihosting/semihost.h b/include/semihosting/semihost.h
index efd2efa25a..97d2a2ba99 100644
--- a/include/semihosting/semihost.h
+++ b/include/semihosting/semihost.h
@@ -66,7 +66,7 @@ const char *semihosting_get_cmdline(void);
 void semihosting_arg_fallback(const char *file, const char *cmd);
 /* for vl.c hooks */
 void qemu_semihosting_enable(void);
-int qemu_semihosting_config_options(const char *opt);
+int qemu_semihosting_config_options(const char *optstr);
 void qemu_semihosting_chardev_init(void);
 void qemu_semihosting_console_init(Chardev *);
 #endif /* CONFIG_USER_ONLY */
diff --git a/semihosting/config.c b/semihosting/config.c
index 8ca569735d..e826457733 100644
--- a/semihosting/config.c
+++ b/semihosting/config.c
@@ -131,10 +131,10 @@ void qemu_semihosting_enable(void)
     semihosting.target = SEMIHOSTING_TARGET_AUTO;
 }
 
-int qemu_semihosting_config_options(const char *optarg)
+int qemu_semihosting_config_options(const char *optstr)
 {
     QemuOptsList *opt_list = qemu_find_opts("semihosting-config");
-    QemuOpts *opts = qemu_opts_parse_noisily(opt_list, optarg, false);
+    QemuOpts *opts = qemu_opts_parse_noisily(opt_list, optstr, false);
 
     semihosting.enabled = true;
 
@@ -155,7 +155,7 @@ int qemu_semihosting_config_options(const char *optarg)
                 semihosting.target = SEMIHOSTING_TARGET_AUTO;
             } else {
                 error_report("unsupported semihosting-config %s",
-                             optarg);
+                             optstr);
                 return 1;
             }
         } else {
@@ -165,7 +165,7 @@ int qemu_semihosting_config_options(const char *optarg)
         qemu_opt_foreach(opts, add_semihosting_arg,
                          &semihosting, NULL);
     } else {
-        error_report("unsupported semihosting-config %s", optarg);
+        error_report("unsupported semihosting-config %s", optstr);
         return 1;
     }
 
diff --git a/stubs/semihost.c b/stubs/semihost.c
index aad7a70353..b3c61935b3 100644
--- a/stubs/semihost.c
+++ b/stubs/semihost.c
@@ -36,7 +36,7 @@ void qemu_semihosting_enable(void)
 {
 }
 
-int qemu_semihosting_config_options(const char *optarg)
+int qemu_semihosting_config_options(const char *optstr)
 {
     return 1;
 }
-- 
2.41.0



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

* [PULL 19/32] ui/cocoa: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (17 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 18/32] semihosting: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 20/32] util/cutils: Clean up global variable shadowing in get_relocated_path() Markus Armbruster
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson,
	Akihiko Odaki

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

Fix:

  ui/cocoa.m:346:20: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
      QemuCocoaView *cocoaView = userInfo;
                     ^
  ui/cocoa.m:342:16: note: previous declaration is here
  QemuCocoaView *cocoaView;
                 ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-11-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 ui/cocoa.m | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 145f42d190..d95276013c 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -343,9 +343,9 @@ - (void) raiseAllKeys;
 
 static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEventRef cgEvent, void *userInfo)
 {
-    QemuCocoaView *cocoaView = userInfo;
+    QemuCocoaView *view = userInfo;
     NSEvent *event = [NSEvent eventWithCGEvent:cgEvent];
-    if ([cocoaView isMouseGrabbed] && [cocoaView handleEvent:event]) {
+    if ([view isMouseGrabbed] && [view handleEvent:event]) {
         COCOA_DEBUG("Global events tap: qemu handled the event, capturing!\n");
         return NULL;
     }
-- 
2.41.0



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

* [PULL 20/32] util/cutils: Clean up global variable shadowing in get_relocated_path()
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (18 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 19/32] ui/cocoa: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 21/32] util/guest-random: Clean up global variable shadowing Markus Armbruster
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Eric Blake,
	Richard Henderson

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

Fix:

  util/cutils.c:1147:17: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
      const char *exec_dir = qemu_get_exec_dir();
                  ^
  util/cutils.c:1035:20: note: previous declaration is here
  static const char *exec_dir;
                     ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-12-philmd@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 util/cutils.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/util/cutils.c b/util/cutils.c
index 25373198ad..b44718a6a2 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -1144,7 +1144,6 @@ char *get_relocated_path(const char *dir)
 {
     size_t prefix_len = strlen(CONFIG_PREFIX);
     const char *bindir = CONFIG_BINDIR;
-    const char *exec_dir = qemu_get_exec_dir();
     GString *result;
     int len_dir, len_bindir;
 
-- 
2.41.0



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

* [PULL 21/32] util/guest-random: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (19 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 20/32] util/cutils: Clean up global variable shadowing in get_relocated_path() Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 22/32] semihosting/arm-compat: Clean up local " Markus Armbruster
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson

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

Fix:

  util/guest-random.c:90:45: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  int qemu_guest_random_seed_main(const char *optarg, Error **errp)
                                              ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-13-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/qemu/guest-random.h | 8 ++++----
 util/guest-random.c         | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/qemu/guest-random.h b/include/qemu/guest-random.h
index 09ff9c2236..5060d49d60 100644
--- a/include/qemu/guest-random.h
+++ b/include/qemu/guest-random.h
@@ -13,16 +13,16 @@
 #define QEMU_GUEST_RANDOM_H
 
 /**
- * qemu_guest_random_seed_main(const char *optarg, Error **errp)
- * @optarg: a non-NULL pointer to a C string
+ * qemu_guest_random_seed_main(const char *seedstr, Error **errp)
+ * @seedstr: a non-NULL pointer to a C string
  * @errp: an error indicator
  *
- * The @optarg value is that which accompanies the -seed argument.
+ * The @seedstr value is that which accompanies the -seed argument.
  * This forces qemu_guest_getrandom into deterministic mode.
  *
  * Returns 0 on success, < 0 on failure while setting *errp.
  */
-int qemu_guest_random_seed_main(const char *optarg, Error **errp);
+int qemu_guest_random_seed_main(const char *seedstr, Error **errp);
 
 /**
  * qemu_guest_random_seed_thread_part1(void)
diff --git a/util/guest-random.c b/util/guest-random.c
index 9465dda085..33607d5ff2 100644
--- a/util/guest-random.c
+++ b/util/guest-random.c
@@ -87,11 +87,11 @@ void qemu_guest_random_seed_thread_part2(uint64_t seed)
     }
 }
 
-int qemu_guest_random_seed_main(const char *optarg, Error **errp)
+int qemu_guest_random_seed_main(const char *seedstr, Error **errp)
 {
     uint64_t seed;
-    if (parse_uint_full(optarg, 0, &seed)) {
-        error_setg(errp, "Invalid seed number: %s", optarg);
+    if (parse_uint_full(seedstr, 0, &seed)) {
+        error_setg(errp, "Invalid seed number: %s", seedstr);
         return -1;
     } else {
         deterministic = true;
-- 
2.41.0



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

* [PULL 22/32] semihosting/arm-compat: Clean up local variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (20 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 21/32] util/guest-random: Clean up global variable shadowing Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 23/32] softmmu/vl: Clean up global " Markus Armbruster
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson

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

Fix:

  semihosting/arm-compat-semi.c: In function ‘do_common_semihosting’:
  semihosting/arm-compat-semi.c:379:13: warning: declaration of ‘ret’ shadows a previous local [-Wshadow=local]
    379 |         int ret, err = 0;
        |             ^~~
  semihosting/arm-compat-semi.c:370:14: note: shadowed declaration is here
    370 |     uint32_t ret;
        |              ^~~
  semihosting/arm-compat-semi.c:682:27: warning: declaration of ‘ret’ shadows a previous local [-Wshadow=local]
    682 |                 abi_ulong ret;
        |                           ^~~
  semihosting/arm-compat-semi.c:370:9: note: shadowed declaration is here
    370 |     int ret;
        |         ^~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-14-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 semihosting/arm-compat-semi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 29c5670fdf..ec959b3e01 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -367,7 +367,6 @@ void do_common_semihosting(CPUState *cs)
     target_ulong ul_ret;
     char * s;
     int nr;
-    uint32_t ret;
     int64_t elapsed;
 
     nr = common_semi_arg(cs, 0) & 0xffffffffU;
@@ -725,6 +724,9 @@ void do_common_semihosting(CPUState *cs)
 
     case TARGET_SYS_EXIT:
     case TARGET_SYS_EXIT_EXTENDED:
+    {
+        uint32_t ret;
+
         if (common_semi_sys_exit_extended(cs, nr)) {
             /*
              * The A64 version of SYS_EXIT takes a parameter block,
@@ -752,6 +754,7 @@ void do_common_semihosting(CPUState *cs)
         }
         gdb_exit(ret);
         exit(ret);
+    }
 
     case TARGET_SYS_ELAPSED:
         elapsed = get_clock() - clock_start;
-- 
2.41.0



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

* [PULL 23/32] softmmu/vl: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (21 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 22/32] semihosting/arm-compat: Clean up local " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 24/32] sysemu/tpm: " Markus Armbruster
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson

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

Fix:

  softmmu/vl.c:1069:44: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static void parse_display_qapi(const char *optarg)
                                             ^
  softmmu/vl.c:1224:39: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static void monitor_parse(const char *optarg, const char *mode, bool pretty)
                                        ^
  softmmu/vl.c:1634:17: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
      const char *optarg = qdict_get_try_str(qdict, "type");
                  ^
  softmmu/vl.c:1784:45: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static void object_option_parse(const char *optarg)
                                              ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-15-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Tweak two parameter names]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 softmmu/vl.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 98e071e63b..13c1b24706 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1066,12 +1066,12 @@ static void select_vgahw(const MachineClass *machine_class, const char *p)
     }
 }
 
-static void parse_display_qapi(const char *optarg)
+static void parse_display_qapi(const char *str)
 {
     DisplayOptions *opts;
     Visitor *v;
 
-    v = qobject_input_visitor_new_str(optarg, "type", &error_fatal);
+    v = qobject_input_visitor_new_str(str, "type", &error_fatal);
 
     visit_type_DisplayOptions(v, NULL, &opts, &error_fatal);
     QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts);
@@ -1221,21 +1221,21 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
     return monitor_init_opts(opts, errp);
 }
 
-static void monitor_parse(const char *optarg, const char *mode, bool pretty)
+static void monitor_parse(const char *str, const char *mode, bool pretty)
 {
     static int monitor_device_index = 0;
     QemuOpts *opts;
     const char *p;
     char label[32];
 
-    if (strstart(optarg, "chardev:", &p)) {
+    if (strstart(str, "chardev:", &p)) {
         snprintf(label, sizeof(label), "%s", p);
     } else {
         snprintf(label, sizeof(label), "compat_monitor%d",
                  monitor_device_index);
-        opts = qemu_chr_parse_compat(label, optarg, true);
+        opts = qemu_chr_parse_compat(label, str, true);
         if (!opts) {
-            error_report("parse error: %s", optarg);
+            error_report("parse error: %s", str);
             exit(1);
         }
     }
@@ -1631,13 +1631,13 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
 
 static MachineClass *select_machine(QDict *qdict, Error **errp)
 {
-    const char *optarg = qdict_get_try_str(qdict, "type");
+    const char *machine_type = qdict_get_try_str(qdict, "type");
     GSList *machines = object_class_get_list(TYPE_MACHINE, false);
     MachineClass *machine_class;
     Error *local_err = NULL;
 
-    if (optarg) {
-        machine_class = find_machine(optarg, machines);
+    if (machine_type) {
+        machine_class = find_machine(machine_type, machines);
         qdict_del(qdict, "type");
         if (!machine_class) {
             error_setg(&local_err, "unsupported machine type");
@@ -1781,20 +1781,20 @@ static void object_option_add_visitor(Visitor *v)
     QTAILQ_INSERT_TAIL(&object_opts, opt, next);
 }
 
-static void object_option_parse(const char *optarg)
+static void object_option_parse(const char *str)
 {
     QemuOpts *opts;
     const char *type;
     Visitor *v;
 
-    if (optarg[0] == '{') {
-        QObject *obj = qobject_from_json(optarg, &error_fatal);
+    if (str[0] == '{') {
+        QObject *obj = qobject_from_json(str, &error_fatal);
 
         v = qobject_input_visitor_new(obj);
         qobject_unref(obj);
     } else {
         opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
-                                       optarg, true);
+                                       str, true);
         if (!opts) {
             exit(1);
         }
-- 
2.41.0



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

* [PULL 24/32] sysemu/tpm: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (22 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 23/32] softmmu/vl: Clean up global " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 25/32] trace/control: " Markus Armbruster
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: stefanha, Philippe Mathieu-Daudé, Stefan Berger,
	Richard Henderson

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

Fix:

  softmmu/tpm.c:178:59: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  int tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
                                                            ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-16-philmd@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/sysemu/tpm.h | 2 +-
 softmmu/tpm.c        | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index 66e3b45f30..1ee568b3b6 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -17,7 +17,7 @@
 
 #ifdef CONFIG_TPM
 
-int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);
+int tpm_config_parse(QemuOptsList *opts_list, const char *optstr);
 int tpm_init(void);
 void tpm_cleanup(void);
 
diff --git a/softmmu/tpm.c b/softmmu/tpm.c
index 578563f05a..7164ea7ff1 100644
--- a/softmmu/tpm.c
+++ b/softmmu/tpm.c
@@ -175,15 +175,15 @@ int tpm_init(void)
  * Parse the TPM configuration options.
  * To display all available TPM backends the user may use '-tpmdev help'
  */
-int tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
+int tpm_config_parse(QemuOptsList *opts_list, const char *optstr)
 {
     QemuOpts *opts;
 
-    if (!strcmp(optarg, "help")) {
+    if (!strcmp(optstr, "help")) {
         tpm_display_backend_drivers();
         return -1;
     }
-    opts = qemu_opts_parse_noisily(opts_list, optarg, true);
+    opts = qemu_opts_parse_noisily(opts_list, optstr, true);
     if (!opts) {
         return -1;
     }
-- 
2.41.0



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

* [PULL 25/32] trace/control: Clean up global variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (23 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 24/32] sysemu/tpm: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 26/32] target/ppc: Clean up local variable shadowing in kvm_arch_*_registers() Markus Armbruster
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Philippe Mathieu-Daudé, Richard Henderson

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

Fix:

  trace/control.c:288:34: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  void trace_opt_parse(const char *optarg)
                                   ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-17-philmd@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 trace/control.h | 4 ++--
 trace/control.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/trace/control.h b/trace/control.h
index dfd209edd8..6754bfe052 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -197,11 +197,11 @@ extern QemuOptsList qemu_trace_opts;
 
 /**
  * trace_opt_parse:
- * @optarg: A string argument of --trace command line argument
+ * @optstr: A string argument of --trace command line argument
  *
  * Initialize tracing subsystem.
  */
-void trace_opt_parse(const char *optarg);
+void trace_opt_parse(const char *optstr);
 
 /**
  * trace_get_vcpu_event_count:
diff --git a/trace/control.c b/trace/control.c
index 1a48a7e266..ef107829ac 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -285,10 +285,10 @@ bool trace_init_backends(void)
     return true;
 }
 
-void trace_opt_parse(const char *optarg)
+void trace_opt_parse(const char *optstr)
 {
     QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
-                                             optarg, true);
+                                             optstr, true);
     if (!opts) {
         exit(1);
     }
-- 
2.41.0



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

* [PULL 26/32] target/ppc: Clean up local variable shadowing in kvm_arch_*_registers()
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (24 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 25/32] trace/control: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 27/32] hw/usb: Silence compiler warnings in USB code when compiling with -Wshadow Markus Armbruster
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Cédric Le Goater, Thomas Huth

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

Remove extra 'i' variable to fix this warning :

  ../target/ppc/kvm.c: In function ‘kvm_arch_put_registers’:
  ../target/ppc/kvm.c:963:13: warning: declaration of ‘i’ shadows a previous local [-Wshadow=compatible-local]
    963 |         int i;
        |             ^
  ../target/ppc/kvm.c:906:9: note: shadowed declaration is here
    906 |     int i;
        |         ^
  ../target/ppc/kvm.c: In function ‘kvm_arch_get_registers’:
  ../target/ppc/kvm.c:1265:13: warning: declaration of ‘i’ shadows a previous local [-Wshadow=compatible-local]
   1265 |         int i;
        |             ^
  ../target/ppc/kvm.c:1212:9: note: shadowed declaration is here
   1212 |     int i, ret;
        |         ^

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-ID: <20231006053526.1031252-1-clg@kaod.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/ppc/kvm.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 51112bd367..d0e2dcdc77 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -960,8 +960,6 @@ int kvm_arch_put_registers(CPUState *cs, int level)
     }
 
     if (cap_one_reg) {
-        int i;
-
         /*
          * We deliberately ignore errors here, for kernels which have
          * the ONE_REG calls, but don't support the specific
@@ -1262,8 +1260,6 @@ int kvm_arch_get_registers(CPUState *cs)
     }
 
     if (cap_one_reg) {
-        int i;
-
         /*
          * We deliberately ignore errors here, for kernels which have
          * the ONE_REG calls, but don't support the specific
-- 
2.41.0



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

* [PULL 27/32] hw/usb: Silence compiler warnings in USB code when compiling with -Wshadow
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (25 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 26/32] target/ppc: Clean up local variable shadowing in kvm_arch_*_registers() Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 28/32] linux-user/flatload: clean up local variable shadowing Markus Armbruster
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth, Michael Tokarev

From: Thomas Huth <thuth@redhat.com>

Rename variables or remove nested definitions where it makes sense,
so that we can finally compile the USB code with "-Wshadow", too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231004130822.113343-1-thuth@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/usb/desc.c        |  2 +-
 hw/usb/dev-hub.c     |  8 ++++----
 hw/usb/dev-storage.c |  6 +++---
 hw/usb/hcd-xhci.c    | 10 +++++-----
 hw/usb/host-libusb.c |  2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/hw/usb/desc.c b/hw/usb/desc.c
index 7f6cc2f99b..f2bdc05a95 100644
--- a/hw/usb/desc.c
+++ b/hw/usb/desc.c
@@ -227,7 +227,7 @@ int usb_desc_endpoint(const USBDescEndpoint *ep, int flags,
     }
 
     if (superlen) {
-        USBDescriptor *d = (void *)(dest + bLength);
+        d = (void *)(dest + bLength);
 
         d->bLength                       = 0x06;
         d->bDescriptorType               = USB_DT_ENDPOINT_COMPANION;
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index a6b50dbc8d..5703e0e826 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -402,7 +402,7 @@ static void usb_hub_handle_control(USBDevice *dev, USBPacket *p,
         {
             unsigned int n = index - 1;
             USBHubPort *port;
-            USBDevice *dev;
+            USBDevice *pdev;
 
             trace_usb_hub_set_port_feature(s->dev.addr, index,
                                            feature_name(value));
@@ -411,7 +411,7 @@ static void usb_hub_handle_control(USBDevice *dev, USBPacket *p,
                 goto fail;
             }
             port = &s->ports[n];
-            dev = port->port.dev;
+            pdev = port->port.dev;
             switch(value) {
             case PORT_SUSPEND:
                 port->wPortStatus |= PORT_STAT_SUSPEND;
@@ -419,8 +419,8 @@ static void usb_hub_handle_control(USBDevice *dev, USBPacket *p,
             case PORT_RESET:
                 usb_hub_port_set(port, PORT_STAT_RESET);
                 usb_hub_port_clear(port, PORT_STAT_RESET);
-                if (dev && dev->attached) {
-                    usb_device_reset(dev);
+                if (pdev && pdev->attached) {
+                    usb_device_reset(pdev);
                     usb_hub_port_set(port, PORT_STAT_ENABLE);
                 }
                 usb_wakeup(s->intr, 0);
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index e3bcffb3e0..a496c811a7 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -403,7 +403,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
     struct usb_msd_cbw cbw;
     uint8_t devep = p->ep->nr;
     SCSIDevice *scsi_dev;
-    uint32_t len;
+    int len;
 
     if (s->needs_reset) {
         p->status = USB_RET_STALL;
@@ -465,7 +465,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
                 usb_msd_copy_data(s, p);
             }
             if (le32_to_cpu(s->csw.residue)) {
-                int len = p->iov.size - p->actual_length;
+                len = p->iov.size - p->actual_length;
                 if (len) {
                     usb_packet_skip(p, len);
                     if (len > s->data_len) {
@@ -526,7 +526,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
                 usb_msd_copy_data(s, p);
             }
             if (le32_to_cpu(s->csw.residue)) {
-                int len = p->iov.size - p->actual_length;
+                len = p->iov.size - p->actual_length;
                 if (len) {
                     usb_packet_skip(p, len);
                     if (len > s->data_len) {
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 324177ad5d..4b60114207 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -217,10 +217,10 @@ enum {
     (((data) >> field##_SHIFT) & field##_MASK)
 
 #define set_field(data, newval, field) do {                     \
-        uint32_t val = *data;                                   \
-        val &= ~(field##_MASK << field##_SHIFT);                \
-        val |= ((newval) & field##_MASK) << field##_SHIFT;      \
-        *data = val;                                            \
+        uint32_t val_ = *data;                                  \
+        val_ &= ~(field##_MASK << field##_SHIFT);               \
+        val_ |= ((newval) & field##_MASK) << field##_SHIFT;     \
+        *data = val_;                                           \
     } while (0)
 
 typedef enum EPType {
@@ -1894,7 +1894,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
     }
 
     if (epctx->retry) {
-        XHCITransfer *xfer = epctx->retry;
+        xfer = epctx->retry;
 
         trace_usb_xhci_xfer_retry(xfer);
         assert(xfer->running_retry);
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index f500db85ab..d7060a42d5 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1010,7 +1010,7 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev, int hostfd)
          * Speeds are defined in linux/usb/ch9.h, file not included
          * due to name conflicts.
          */
-        int rc = ioctl(hostfd, USBDEVFS_GET_SPEED, NULL);
+        rc = ioctl(hostfd, USBDEVFS_GET_SPEED, NULL);
         switch (rc) {
         case 1: /* low */
             libusb_speed = LIBUSB_SPEED_LOW;
-- 
2.41.0



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

* [PULL 28/32] linux-user/flatload: clean up local variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (26 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 27/32] hw/usb: Silence compiler warnings in USB code when compiling with -Wshadow Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 29/32] linux-user/mmap.c: " Markus Armbruster
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Laurent Vivier, Thomas Huth

From: Laurent Vivier <laurent@vivier.eu>

Fix following warnings:

.../linux-user/flatload.c: In function 'load_flt_binary':
.../linux-user/flatload.c:758:23: warning: declaration of 'p' shadows a previous local [-Wshadow=compatible-local]
  758 |             abi_ulong p;
      |                       ^
../../../Projects/qemu/linux-user/flatload.c:722:15: note: shadowed declaration is here
  722 |     abi_ulong p;
      |               ^

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

diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 4331a11bf0..fdcc4610fa 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -755,15 +755,15 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
     /* Update data segment pointers for all libraries */
     for (i=0; i<MAX_SHARED_LIBS; i++) {
         if (libinfo[i].loaded) {
-            abi_ulong p;
-            p = libinfo[i].start_data;
+            abi_ulong seg;
+            seg = libinfo[i].start_data;
             for (j=0; j<MAX_SHARED_LIBS; j++) {
-                p -= 4;
+                seg -= 4;
                 /* FIXME - handle put_user() failures */
                 if (put_user_ual(libinfo[j].loaded
                                  ? libinfo[j].start_data
                                  : UNLOADED_LIB,
-                                 p))
+                                 seg))
                     return -EFAULT;
             }
         }
-- 
2.41.0



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

* [PULL 29/32] linux-user/mmap.c: clean up local variable shadowing
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (27 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 28/32] linux-user/flatload: clean up local variable shadowing Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 30/32] linux-user/syscall.c: clean up local variable shadowing in do_ioctl_dm() Markus Armbruster
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Laurent Vivier, Thomas Huth

From: Laurent Vivier <laurent@vivier.eu>

Fix following warnings:

.../linux-user/mmap.c: In function 'target_mremap':
.../linux-user/mmap.c:913:13: warning: declaration of 'prot' shadows a previous local [-Wshadow=compatible-local]
  913 |         int prot = 0;
      |             ^~~~
../../../Projects/qemu/linux-user/mmap.c:871:9: note: shadowed declaration is here
  871 |     int prot;
      |         ^~~~

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-ID: <20230925151029.461358-3-laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 linux-user/mmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 8eaf57b208..8ccaab7859 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -910,16 +910,16 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
             }
         }
     } else {
-        int prot = 0;
+        int page_flags = 0;
         if (reserved_va && old_size < new_size) {
             abi_ulong addr;
             for (addr = old_addr + old_size;
                  addr < old_addr + new_size;
                  addr++) {
-                prot |= page_get_flags(addr);
+                page_flags |= page_get_flags(addr);
             }
         }
-        if (prot == 0) {
+        if (page_flags == 0) {
             host_addr = mremap(g2h_untagged(old_addr),
                                old_size, new_size, flags);
 
-- 
2.41.0



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

* [PULL 30/32] linux-user/syscall.c: clean up local variable shadowing in do_ioctl_dm()
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (28 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 29/32] linux-user/mmap.c: " Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 31/32] linux-user/syscall.c: clean up local variable shadowing in TARGET_NR_getcpu Markus Armbruster
                   ` (2 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Laurent Vivier, Thomas Huth

From: Laurent Vivier <laurent@vivier.eu>

Fix following warnings:

.../linux-user/syscall.c: In function 'do_ioctl_dm':
.../linux-user/syscall.c:5053:23: warning: declaration of 'arg_type' shadows a previous local [-Wshadow=local]
 5053 |         const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
      |                       ^~~~~~~~
.../linux-user/syscall.c:4991:20: note: shadowed declaration is here
 4991 |     const argtype *arg_type = ie->arg_type;
      |                    ^~~~~~~~
...//linux-user/syscall.c:5102:27: warning: declaration of 'arg_type' shadows a previous local [-Wshadow=local]
 5102 |             const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_name_list) };
      |                           ^~~~~~~~
.../linux-user/syscall.c:4991:20: note: shadowed declaration is here
 4991 |     const argtype *arg_type = ie->arg_type;
      |                    ^~~~~~~~
.../linux-user/syscall.c:5130:27: warning: declaration of 'arg_type' shadows a previous local [-Wshadow=local]
 5130 |             const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
      |                           ^~~~~~~~
.../linux-user/syscall.c:4991:20: note: shadowed declaration is here
 4991 |     const argtype *arg_type = ie->arg_type;
      |                    ^~~~~~~~
.../linux-user/syscall.c:5170:27: warning: declaration of 'arg_type' shadows a previous local [-Wshadow=local]
 5170 |             const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_versions) };
      |                           ^~~~~~~~
.../linux-user/syscall.c:4991:20: note: shadowed declaration is here
 4991 |     const argtype *arg_type = ie->arg_type;
      |                    ^~~~~~~~

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-ID: <20230925151029.461358-4-laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 linux-user/syscall.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c6ffadd082..0f1ecc1e0b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5050,8 +5050,8 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
     {
         void *gspec = argptr;
         void *cur_data = host_data;
-        const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
-        int spec_size = thunk_type_size(arg_type, 0);
+        const argtype dm_arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
+        int spec_size = thunk_type_size(dm_arg_type, 0);
         int i;
 
         for (i = 0; i < host_dm->target_count; i++) {
@@ -5059,7 +5059,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
             uint32_t next;
             int slen;
 
-            thunk_convert(spec, gspec, arg_type, THUNK_HOST);
+            thunk_convert(spec, gspec, dm_arg_type, THUNK_HOST);
             slen = strlen((char*)gspec + spec_size) + 1;
             next = spec->next;
             spec->next = sizeof(*spec) + slen;
@@ -5099,7 +5099,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
             struct dm_name_list *nl = (void*)host_dm + host_dm->data_start;
             uint32_t remaining_data = guest_data_size;
             void *cur_data = argptr;
-            const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_name_list) };
+            const argtype dm_arg_type[] = { MK_STRUCT(STRUCT_dm_name_list) };
             int nl_size = 12; /* can't use thunk_size due to alignment */
 
             while (1) {
@@ -5111,7 +5111,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
                     host_dm->flags |= DM_BUFFER_FULL_FLAG;
                     break;
                 }
-                thunk_convert(cur_data, nl, arg_type, THUNK_TARGET);
+                thunk_convert(cur_data, nl, dm_arg_type, THUNK_TARGET);
                 strcpy(cur_data + nl_size, nl->name);
                 cur_data += nl->next;
                 remaining_data -= nl->next;
@@ -5127,8 +5127,8 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
         {
             struct dm_target_spec *spec = (void*)host_dm + host_dm->data_start;
             void *cur_data = argptr;
-            const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
-            int spec_size = thunk_type_size(arg_type, 0);
+            const argtype dm_arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
+            int spec_size = thunk_type_size(dm_arg_type, 0);
             int i;
 
             for (i = 0; i < host_dm->target_count; i++) {
@@ -5139,7 +5139,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
                     host_dm->flags |= DM_BUFFER_FULL_FLAG;
                     break;
                 }
-                thunk_convert(cur_data, spec, arg_type, THUNK_TARGET);
+                thunk_convert(cur_data, spec, dm_arg_type, THUNK_TARGET);
                 strcpy(cur_data + spec_size, (char*)&spec[1]);
                 cur_data = argptr + spec->next;
                 spec = (void*)host_dm + host_dm->data_start + next;
@@ -5167,8 +5167,8 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
             struct dm_target_versions *vers = (void*)host_dm + host_dm->data_start;
             uint32_t remaining_data = guest_data_size;
             void *cur_data = argptr;
-            const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_versions) };
-            int vers_size = thunk_type_size(arg_type, 0);
+            const argtype dm_arg_type[] = { MK_STRUCT(STRUCT_dm_target_versions) };
+            int vers_size = thunk_type_size(dm_arg_type, 0);
 
             while (1) {
                 uint32_t next = vers->next;
@@ -5179,7 +5179,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
                     host_dm->flags |= DM_BUFFER_FULL_FLAG;
                     break;
                 }
-                thunk_convert(cur_data, vers, arg_type, THUNK_TARGET);
+                thunk_convert(cur_data, vers, dm_arg_type, THUNK_TARGET);
                 strcpy(cur_data + vers_size, vers->name);
                 cur_data += vers->next;
                 remaining_data -= vers->next;
-- 
2.41.0



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

* [PULL 31/32] linux-user/syscall.c: clean up local variable shadowing in TARGET_NR_getcpu
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (29 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 30/32] linux-user/syscall.c: clean up local variable shadowing in do_ioctl_dm() Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-06 11:36 ` [PULL 32/32] linux-user/syscall.c: clean up local variable shadowing in xattr syscalls Markus Armbruster
  2023-10-10  1:28 ` [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Stefan Hajnoczi
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Laurent Vivier, Thomas Huth

From: Laurent Vivier <laurent@vivier.eu>

Fix following warnings:

.../linux-user/syscall.c: In function 'do_syscall1':
.../linux-user/syscall.c:11180:22: warning: declaration of 'cpu' shadows a previous local [-Wshadow=local]
11180 |             unsigned cpu, node;
      |                      ^~~
.../linux-user/syscall.c:8963:15: note: shadowed declaration is here
 8963 |     CPUState *cpu = env_cpu(cpu_env);
      |               ^~~

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-ID: <20230925151029.461358-5-laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0f1ecc1e0b..97a5e9ddf2 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11177,14 +11177,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         }
     case TARGET_NR_getcpu:
         {
-            unsigned cpu, node;
-            ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL,
+            unsigned cpuid, node;
+            ret = get_errno(sys_getcpu(arg1 ? &cpuid : NULL,
                                        arg2 ? &node : NULL,
                                        NULL));
             if (is_error(ret)) {
                 return ret;
             }
-            if (arg1 && put_user_u32(cpu, arg1)) {
+            if (arg1 && put_user_u32(cpuid, arg1)) {
                 return -TARGET_EFAULT;
             }
             if (arg2 && put_user_u32(node, arg2)) {
-- 
2.41.0



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

* [PULL 32/32] linux-user/syscall.c: clean up local variable shadowing in xattr syscalls
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (30 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 31/32] linux-user/syscall.c: clean up local variable shadowing in TARGET_NR_getcpu Markus Armbruster
@ 2023-10-06 11:36 ` Markus Armbruster
  2023-10-10  1:28 ` [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Stefan Hajnoczi
  32 siblings, 0 replies; 34+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Laurent Vivier, Thomas Huth

From: Laurent Vivier <laurent@vivier.eu>

p is a generic variable in syscall() and can be used by any syscall
case, so this patch removes the useless local variable declaration for
the following syscalls: TARGET_NR_llistxattr, TARGET_NR_listxattr,
TARGET_NR_setxattr, TARGET_NR_lsetxattr, TARGET_NR_getxattr,
TARGET_NR_lgetxattr, TARGET_NR_removexattr, TARGET_NR_lremovexattr.

Fix following warnings:

.../linux-user/syscall.c:12342:15: warning: declaration of 'p' shadows a previous local [-Wshadow=compatible-local]
12342 |         void *p, *b = 0;
      |               ^
.../linux-user/syscall.c:8975:11: note: shadowed declaration is here
 8975 |     void *p;
      |           ^
.../linux-user/syscall.c:12379:19: warning: declaration of 'p' shadows a previous local [-Wshadow=compatible-local]
12379 |             void *p, *n, *v = 0;
      |                   ^
.../linux-user/syscall.c:8975:11: note: shadowed declaration is here
 8975 |     void *p;
      |           ^
.../linux-user/syscall.c:12424:19: warning: declaration of 'p' shadows a previous local [-Wshadow=compatible-local]
12424 |             void *p, *n, *v = 0;
      |                   ^
.../linux-user/syscall.c:8975:11: note: shadowed declaration is here
 8975 |     void *p;
      |           ^
.../linux-user/syscall.c:12469:19: warning: declaration of 'p' shadows a previous local [-Wshadow=compatible-local]
12469 |             void *p, *n;
      |                   ^
.../linux-user/syscall.c:8975:11: note: shadowed declaration is here
 8975 |     void *p;
      |           ^

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

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 97a5e9ddf2..d49cd314a2 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -12339,7 +12339,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_listxattr:
     case TARGET_NR_llistxattr:
     {
-        void *p, *b = 0;
+        void *b = 0;
         if (arg2) {
             b = lock_user(VERIFY_WRITE, arg2, arg3, 0);
             if (!b) {
@@ -12376,7 +12376,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_setxattr:
     case TARGET_NR_lsetxattr:
         {
-            void *p, *n, *v = 0;
+            void *n, *v = 0;
             if (arg3) {
                 v = lock_user(VERIFY_READ, arg3, arg4, 1);
                 if (!v) {
@@ -12421,7 +12421,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_getxattr:
     case TARGET_NR_lgetxattr:
         {
-            void *p, *n, *v = 0;
+            void *n, *v = 0;
             if (arg3) {
                 v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
                 if (!v) {
@@ -12466,7 +12466,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_removexattr:
     case TARGET_NR_lremovexattr:
         {
-            void *p, *n;
+            void *n;
             p = lock_user_string(arg1);
             n = lock_user_string(arg2);
             if (p && n) {
-- 
2.41.0



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

* Re: [PULL 00/32] -Wshadow=local patches patches for 2023-10-06
  2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
                   ` (31 preceding siblings ...)
  2023-10-06 11:36 ` [PULL 32/32] linux-user/syscall.c: clean up local variable shadowing in xattr syscalls Markus Armbruster
@ 2023-10-10  1:28 ` Stefan Hajnoczi
  32 siblings, 0 replies; 34+ messages in thread
From: Stefan Hajnoczi @ 2023-10-10  1:28 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] 34+ messages in thread

end of thread, other threads:[~2023-10-10  1:29 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-06 11:36 [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Markus Armbruster
2023-10-06 11:36 ` [PULL 01/32] hw/cxl: Fix local variable shadowing of cap_hdrs Markus Armbruster
2023-10-06 11:36 ` [PULL 02/32] target/loongarch: Clean up local variable shadowing Markus Armbruster
2023-10-06 11:36 ` [PULL 03/32] target/ppc: Rename variables to avoid local variable shadowing in VUPKPX Markus Armbruster
2023-10-06 11:36 ` [PULL 04/32] hw/i386: changes towards enabling -Wshadow=local for x86 machines Markus Armbruster
2023-10-06 11:36 ` [PULL 05/32] audio/ossaudio: Fix compiler warning with -Wshadow Markus Armbruster
2023-10-06 11:36 ` [PULL 06/32] hw/net/vhost_net: Silence compiler warning when compiling " Markus Armbruster
2023-10-06 11:36 ` [PULL 07/32] hw/virtio/virtio-pci: Avoid compiler warning " Markus Armbruster
2023-10-06 11:36 ` [PULL 08/32] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow Markus Armbruster
2023-10-06 11:36 ` [PULL 09/32] dump: Silence compiler warning in dump code when compiling with -Wshadow Markus Armbruster
2023-10-06 11:36 ` [PULL 10/32] hw/audio/soundhw: Clean up global variable shadowing Markus Armbruster
2023-10-06 11:36 ` [PULL 11/32] hw/ide/ahci: Clean up local " Markus Armbruster
2023-10-06 11:36 ` [PULL 12/32] net/net: Clean up global " Markus Armbruster
2023-10-06 11:36 ` [PULL 13/32] os-posix: " Markus Armbruster
2023-10-06 11:36 ` [PULL 14/32] plugins/loader: " Markus Armbruster
2023-10-06 11:36 ` [PULL 15/32] qemu-img: " Markus Armbruster
2023-10-06 11:36 ` [PULL 16/32] qemu-io: " Markus Armbruster
2023-10-06 11:36 ` [PULL 17/32] qom/object_interfaces: " Markus Armbruster
2023-10-06 11:36 ` [PULL 18/32] semihosting: " Markus Armbruster
2023-10-06 11:36 ` [PULL 19/32] ui/cocoa: " Markus Armbruster
2023-10-06 11:36 ` [PULL 20/32] util/cutils: Clean up global variable shadowing in get_relocated_path() Markus Armbruster
2023-10-06 11:36 ` [PULL 21/32] util/guest-random: Clean up global variable shadowing Markus Armbruster
2023-10-06 11:36 ` [PULL 22/32] semihosting/arm-compat: Clean up local " Markus Armbruster
2023-10-06 11:36 ` [PULL 23/32] softmmu/vl: Clean up global " Markus Armbruster
2023-10-06 11:36 ` [PULL 24/32] sysemu/tpm: " Markus Armbruster
2023-10-06 11:36 ` [PULL 25/32] trace/control: " Markus Armbruster
2023-10-06 11:36 ` [PULL 26/32] target/ppc: Clean up local variable shadowing in kvm_arch_*_registers() Markus Armbruster
2023-10-06 11:36 ` [PULL 27/32] hw/usb: Silence compiler warnings in USB code when compiling with -Wshadow Markus Armbruster
2023-10-06 11:36 ` [PULL 28/32] linux-user/flatload: clean up local variable shadowing Markus Armbruster
2023-10-06 11:36 ` [PULL 29/32] linux-user/mmap.c: " Markus Armbruster
2023-10-06 11:36 ` [PULL 30/32] linux-user/syscall.c: clean up local variable shadowing in do_ioctl_dm() Markus Armbruster
2023-10-06 11:36 ` [PULL 31/32] linux-user/syscall.c: clean up local variable shadowing in TARGET_NR_getcpu Markus Armbruster
2023-10-06 11:36 ` [PULL 32/32] linux-user/syscall.c: clean up local variable shadowing in xattr syscalls Markus Armbruster
2023-10-10  1:28 ` [PULL 00/32] -Wshadow=local patches patches for 2023-10-06 Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).