qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/5] -Wshadow=local patches for 2023-10-12
@ 2023-10-12 14:57 Markus Armbruster
  2023-10-12 14:57 ` [PULL 1/5] libvduse: Fix compiler warning with -Wshadow=local Markus Armbruster
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Markus Armbruster @ 2023-10-12 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha

The following changes since commit a51e5124a655b3dad80b36b18547cb1eca2c5eb2:

  Merge tag 'pull-omnibus-111023-1' of https://gitlab.com/stsquad/qemu into staging (2023-10-11 09:43:10 -0400)

are available in the Git repository at:

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

for you to fetch changes up to c35b2fb1fdc7f6926653cc6df289e5bd77ecbad3:

  target/i386: fix shadowed variable pasto (2023-10-12 16:37:31 +0200)

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

----------------------------------------------------------------
Paolo Bonzini (1):
      target/i386: fix shadowed variable pasto

Thomas Huth (4):
      libvduse: Fix compiler warning with -Wshadow=local
      libvhost-user: Fix compiler warning with -Wshadow=local
      hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow
      contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow

 contrib/vhost-user-gpu/vugpu.h            |  8 ++++----
 include/hw/virtio/virtio-gpu.h            |  8 ++++----
 contrib/vhost-user-gpu/vhost-user-gpu.c   |  6 +++---
 subprojects/libvduse/libvduse.c           |  2 +-
 subprojects/libvhost-user/libvhost-user.c | 12 ++++++------
 target/i386/tcg/seg_helper.c              |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)

-- 
2.41.0



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

* [PULL 1/5] libvduse: Fix compiler warning with -Wshadow=local
  2023-10-12 14:57 [PULL 0/5] -Wshadow=local patches for 2023-10-12 Markus Armbruster
@ 2023-10-12 14:57 ` Markus Armbruster
  2023-10-12 14:57 ` [PULL 2/5] libvhost-user: " Markus Armbruster
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2023-10-12 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth, Xie Yongji

From: Thomas Huth <thuth@redhat.com>

No need to declare a new variable with the same name here,
we can simple re-use the one from the top of the function.
With this change, the file now compiles fine with -Wshadow=local.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231006120819.480792-1-thuth@redhat.com>
Reviewed-by: Xie Yongji <xieyongji@bytedance.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 subprojects/libvduse/libvduse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
index 377959a0b4..21ffbb5b8d 100644
--- a/subprojects/libvduse/libvduse.c
+++ b/subprojects/libvduse/libvduse.c
@@ -1031,7 +1031,7 @@ int vduse_dev_handler(VduseDev *dev)
         /* The iova will be updated by iova_to_va() later, so just remove it */
         vduse_iova_remove_region(dev, req.iova.start, req.iova.last);
         for (i = 0; i < dev->num_queues; i++) {
-            VduseVirtq *vq = &dev->vqs[i];
+            vq = &dev->vqs[i];
             if (vq->ready) {
                 if (vduse_queue_update_vring(vq, vq->vring.desc_addr,
                                              vq->vring.avail_addr,
-- 
2.41.0



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

* [PULL 2/5] libvhost-user: Fix compiler warning with -Wshadow=local
  2023-10-12 14:57 [PULL 0/5] -Wshadow=local patches for 2023-10-12 Markus Armbruster
  2023-10-12 14:57 ` [PULL 1/5] libvduse: Fix compiler warning with -Wshadow=local Markus Armbruster
@ 2023-10-12 14:57 ` Markus Armbruster
  2023-10-12 14:57 ` [PULL 3/5] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow Markus Armbruster
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2023-10-12 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth, Michael S . Tsirkin

From: Thomas Huth <thuth@redhat.com>

Rename shadowing variables to make this code compilable
with -Wshadow=local.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231006121129.487251-1-thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index 051a611da3..ea2822a44c 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -870,10 +870,10 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
     for (i = 0; i < dev->nregions; i++) {
         if (reg_equal(&dev->regions[i], msg_region)) {
             VuDevRegion *r = &dev->regions[i];
-            void *m = (void *) (uintptr_t) r->mmap_addr;
+            void *ma = (void *) (uintptr_t) r->mmap_addr;
 
-            if (m) {
-                munmap(m, r->size + r->mmap_offset);
+            if (ma) {
+                munmap(ma, r->size + r->mmap_offset);
             }
 
             /*
@@ -1005,10 +1005,10 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)
 
     for (i = 0; i < dev->nregions; i++) {
         VuDevRegion *r = &dev->regions[i];
-        void *m = (void *) (uintptr_t) r->mmap_addr;
+        void *ma = (void *) (uintptr_t) r->mmap_addr;
 
-        if (m) {
-            munmap(m, r->size + r->mmap_offset);
+        if (ma) {
+            munmap(ma, r->size + r->mmap_offset);
         }
     }
     dev->nregions = memory->nregions;
-- 
2.41.0



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

* [PULL 3/5] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow
  2023-10-12 14:57 [PULL 0/5] -Wshadow=local patches for 2023-10-12 Markus Armbruster
  2023-10-12 14:57 ` [PULL 1/5] libvduse: Fix compiler warning with -Wshadow=local Markus Armbruster
  2023-10-12 14:57 ` [PULL 2/5] libvhost-user: " Markus Armbruster
@ 2023-10-12 14:57 ` Markus Armbruster
  2023-10-12 14:57 ` [PULL 4/5] contrib/vhost-user-gpu: " Markus Armbruster
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2023-10-12 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth, Michael S . Tsirkin

From: Thomas Huth <thuth@redhat.com>

Avoid using trivial variable names in macros, otherwise we get
the following compiler warning when compiling with -Wshadow=local:

In file included from ../../qemu/hw/display/virtio-gpu-virgl.c:19:
../../home/thuth/devel/qemu/hw/display/virtio-gpu-virgl.c:
 In function ‘virgl_cmd_submit_3d’:
../../qemu/include/hw/virtio/virtio-gpu.h:228:16: error: declaration of ‘s’
 shadows a previous local [-Werror=shadow=compatible-local]
  228 |         size_t s;
      |                ^
../../qemu/hw/display/virtio-gpu-virgl.c:215:5: note: in expansion of macro
 ‘VIRTIO_GPU_FILL_CMD’
  215 |     VIRTIO_GPU_FILL_CMD(cs);
      |     ^~~~~~~~~~~~~~~~~~~
../../qemu/hw/display/virtio-gpu-virgl.c:213:12: note: shadowed declaration
 is here
  213 |     size_t s;
      |            ^
cc1: all warnings being treated as errors

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

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 390c4642b8..4739fa4689 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -225,13 +225,13 @@ struct VhostUserGPU {
 };
 
 #define VIRTIO_GPU_FILL_CMD(out) do {                                   \
-        size_t s;                                                       \
-        s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0,          \
+        size_t virtiogpufillcmd_s_ =                                    \
+            iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0,          \
                        &out, sizeof(out));                              \
-        if (s != sizeof(out)) {                                         \
+        if (virtiogpufillcmd_s_ != sizeof(out)) {                       \
             qemu_log_mask(LOG_GUEST_ERROR,                              \
                           "%s: command size incorrect %zu vs %zu\n",    \
-                          __func__, s, sizeof(out));                    \
+                          __func__, virtiogpufillcmd_s_, sizeof(out));  \
             return;                                                     \
         }                                                               \
     } while (0)
-- 
2.41.0



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

* [PULL 4/5] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
  2023-10-12 14:57 [PULL 0/5] -Wshadow=local patches for 2023-10-12 Markus Armbruster
                   ` (2 preceding siblings ...)
  2023-10-12 14:57 ` [PULL 3/5] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow Markus Armbruster
@ 2023-10-12 14:57 ` Markus Armbruster
  2023-10-12 14:57 ` [PULL 5/5] target/i386: fix shadowed variable pasto Markus Armbruster
  2023-10-16 19:20 ` [PULL 0/5] -Wshadow=local patches for 2023-10-12 Stefan Hajnoczi
  5 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2023-10-12 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Thomas Huth

From: Thomas Huth <thuth@redhat.com>

Rename some variables to avoid compiler warnings when compiling
with -Wshadow=local.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231009083726.30301-1-thuth@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 contrib/vhost-user-gpu/vugpu.h          | 8 ++++----
 contrib/vhost-user-gpu/vhost-user-gpu.c | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/contrib/vhost-user-gpu/vugpu.h b/contrib/vhost-user-gpu/vugpu.h
index 509b679f03..654c392fbb 100644
--- a/contrib/vhost-user-gpu/vugpu.h
+++ b/contrib/vhost-user-gpu/vugpu.h
@@ -164,12 +164,12 @@ struct virtio_gpu_ctrl_command {
 };
 
 #define VUGPU_FILL_CMD(out) do {                                \
-        size_t s;                                               \
-        s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0,  \
+        size_t vugpufillcmd_s_ =                                \
+            iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0,  \
                        &out, sizeof(out));                      \
-        if (s != sizeof(out)) {                                 \
+        if (vugpufillcmd_s_ != sizeof(out)) {                   \
             g_critical("%s: command size incorrect %zu vs %zu", \
-                       __func__, s, sizeof(out));               \
+                       __func__, vugpufillcmd_s_, sizeof(out)); \
             return;                                             \
         }                                                       \
     } while (0)
diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c
index aa304475a0..bb41758e34 100644
--- a/contrib/vhost-user-gpu/vhost-user-gpu.c
+++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
@@ -834,7 +834,7 @@ vg_resource_flush(VuGpu *g,
                 .width = width,
                 .height = height,
             };
-            pixman_image_t *i =
+            pixman_image_t *img =
                 pixman_image_create_bits(pixman_image_get_format(res->image),
                                          msg->payload.update.width,
                                          msg->payload.update.height,
@@ -842,11 +842,11 @@ vg_resource_flush(VuGpu *g,
                                                       payload.update.data),
                                          width * bpp);
             pixman_image_composite(PIXMAN_OP_SRC,
-                                   res->image, NULL, i,
+                                   res->image, NULL, img,
                                    extents->x1, extents->y1,
                                    0, 0, 0, 0,
                                    width, height);
-            pixman_image_unref(i);
+            pixman_image_unref(img);
             vg_send_msg(g, msg, -1);
             g_free(msg);
         }
-- 
2.41.0



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

* [PULL 5/5] target/i386: fix shadowed variable pasto
  2023-10-12 14:57 [PULL 0/5] -Wshadow=local patches for 2023-10-12 Markus Armbruster
                   ` (3 preceding siblings ...)
  2023-10-12 14:57 ` [PULL 4/5] contrib/vhost-user-gpu: " Markus Armbruster
@ 2023-10-12 14:57 ` Markus Armbruster
  2023-10-16 19:20 ` [PULL 0/5] -Wshadow=local patches for 2023-10-12 Stefan Hajnoczi
  5 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2023-10-12 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Paolo Bonzini, Philippe Mathieu-Daudé

From: Paolo Bonzini <pbonzini@redhat.com>

Commit a908985971a ("target/i386/seg_helper: introduce tss_set_busy",
2023-09-26) failed to use the tss_selector argument of the new function,
which was therefore unused.

This shows up as a #GP fault when booting old versions of 32-bit
Linux.

Fixes: a908985971a ("target/i386/seg_helper: introduce tss_set_busy", 2023-09-26)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20231011135350.438492-1-pbonzini@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target/i386/tcg/seg_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c
index 2b92aee207..eb29a1fd4e 100644
--- a/target/i386/tcg/seg_helper.c
+++ b/target/i386/tcg/seg_helper.c
@@ -229,7 +229,7 @@ static void tss_load_seg(CPUX86State *env, X86Seg seg_reg, int selector,
 static void tss_set_busy(CPUX86State *env, int tss_selector, bool value,
                          uintptr_t retaddr)
 {
-    target_ulong ptr = env->gdt.base + (env->tr.selector & ~7);
+    target_ulong ptr = env->gdt.base + (tss_selector & ~7);
     uint32_t e2 = cpu_ldl_kernel_ra(env, ptr + 4, retaddr);
 
     if (value) {
-- 
2.41.0



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

* Re: [PULL 0/5] -Wshadow=local patches for 2023-10-12
  2023-10-12 14:57 [PULL 0/5] -Wshadow=local patches for 2023-10-12 Markus Armbruster
                   ` (4 preceding siblings ...)
  2023-10-12 14:57 ` [PULL 5/5] target/i386: fix shadowed variable pasto Markus Armbruster
@ 2023-10-16 19:20 ` Stefan Hajnoczi
  5 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2023-10-16 19:20 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] 7+ messages in thread

end of thread, other threads:[~2023-10-16 19:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-12 14:57 [PULL 0/5] -Wshadow=local patches for 2023-10-12 Markus Armbruster
2023-10-12 14:57 ` [PULL 1/5] libvduse: Fix compiler warning with -Wshadow=local Markus Armbruster
2023-10-12 14:57 ` [PULL 2/5] libvhost-user: " Markus Armbruster
2023-10-12 14:57 ` [PULL 3/5] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow Markus Armbruster
2023-10-12 14:57 ` [PULL 4/5] contrib/vhost-user-gpu: " Markus Armbruster
2023-10-12 14:57 ` [PULL 5/5] target/i386: fix shadowed variable pasto Markus Armbruster
2023-10-16 19:20 ` [PULL 0/5] -Wshadow=local patches for 2023-10-12 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).