* [PATCH v2] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow
@ 2023-10-09 8:45 Thomas Huth
2023-10-09 16:24 ` Michael S. Tsirkin
2023-10-12 6:08 ` Markus Armbruster
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Huth @ 2023-10-09 8:45 UTC (permalink / raw)
To: Gerd Hoffmann, Michael S. Tsirkin, qemu-devel; +Cc: Markus Armbruster
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>
---
v2: Renamed the variable to something even less trivial
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] 3+ messages in thread
* Re: [PATCH v2] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow
2023-10-09 8:45 [PATCH v2] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow Thomas Huth
@ 2023-10-09 16:24 ` Michael S. Tsirkin
2023-10-12 6:08 ` Markus Armbruster
1 sibling, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2023-10-09 16:24 UTC (permalink / raw)
To: Thomas Huth; +Cc: Gerd Hoffmann, qemu-devel, Markus Armbruster
On Mon, Oct 09, 2023 at 10:45:59AM +0200, Thomas Huth wrote:
> 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>
> ---
> v2: Renamed the variable to something even less trivial
>
> include/hw/virtio/virtio-gpu.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Apropos why is this header not in include/hw/display/
> 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 [flat|nested] 3+ messages in thread
* Re: [PATCH v2] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow
2023-10-09 8:45 [PATCH v2] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow Thomas Huth
2023-10-09 16:24 ` Michael S. Tsirkin
@ 2023-10-12 6:08 ` Markus Armbruster
1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2023-10-12 6:08 UTC (permalink / raw)
To: Thomas Huth; +Cc: Gerd Hoffmann, Michael S. Tsirkin, qemu-devel
Thomas Huth <thuth@redhat.com> writes:
> 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>
Queued. Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-12 6:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 8:45 [PATCH v2] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow Thomas Huth
2023-10-09 16:24 ` Michael S. Tsirkin
2023-10-12 6:08 ` Markus Armbruster
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).