hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow
PATCH v2 1/1 hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow
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
---
v2: Renamed the variable to something even less trivial
include/hw/virtio/virtio-gpu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/hw/virtio/virtio-gpu.h +4 -4
@@ -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)
Signature · 1 line
2.41.0
Quoted 20 lines · Thomas Huth
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_ts;
| ^../../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_ts;
| ^
cc1: all warnings being treated as errors
Quoted 6 lines
Signed-off-by Thomas Huth <[email protected]>---
v2: Renamed the variable to something even less trivialinclude/hw/virtio/virtio-gpu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Apropos why is this header not in include/hw/display/
Quoted 24 lines
include/hw/virtio/virtio-gpu.h +4
-4@@ -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)Signature · 1 line
2.41.0
Markus Armbruster
AppliedQuoted 14 lines · Thomas Huth
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_ts;
| ^../../qemu/hw/display/virtio-gpu-virgl.c:215:5: note: in expansion of macro
‘VIRTIO_GPU_FILL_CMD’215 | VIRTIO_GPU_FILL_CMD(cs); | ^~~~~~~~~~~~~~~~~~~
Quoted 7 lines
../../qemu/hw/display/virtio-gpu-virgl.c:213:12: note: shadowed declaration
is here
213 |size_ts;
| ^
cc1: all warnings being treated as errorsSigned-off-by Thomas Huth <[email protected]>
Queued. Thanks!