contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
PATCH v2 1/1 contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
Rename some variables to avoid compiler warnings when compiling with -Wshadow=local.
---
v2: Renamed the variable to something more unique
contrib/vhost-user-gpu/vugpu.h | 8 ++++---- contrib/vhost-user-gpu/vhost-user-gpu.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
contrib/vhost-user-gpu/vugpu.h +4 -4
@@ -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)
contrib/vhost-user-gpu/vhost-user-gpu.c +3 -3
@@ -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); }
Signature · 1 line
2.41.0
Quoted 22 lines · Thomas Huth
Rename some variables to avoid compiler warnings when compiling with -Wshadow=local.
Signed-off-by Thomas Huth <[email protected]>---
v2: Renamed the variable to something more uniquecontrib/vhost-user-gpu/vugpu.h | 8 ++++---- contrib/vhost-user-gpu/vhost-user-gpu.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)contrib/vhost-user-gpu/vugpu.h +1
-2@@ -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_ = \
contrib/vhost-user-gpu/vugpu.h struct virtio_gpu_ctrl_command { · line 175
Quoted 10 lines
contrib/vhost-user-gpu/vugpu.h +3
-2+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 )
I think I prefer VUGPU_FILL_CMD_s or VUGPU_FILL_CMD_s_ - makes it clear it's related to a macro.
Quoted 29 lines
contrib/vhost-user-gpu/vhost-user-gpu.c +3
-3@@ -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); }Signature · 1 line
2.41.0
Quoted 28 lines · Michael S. Tsirkin
Quoted 27 lines · Thomas Huth
Rename some variables to avoid compiler warnings when compiling with -Wshadow=local.
Signed-off-by Thomas Huth <[email protected]>---
v2: Renamed the variable to something more uniquecontrib/vhost-user-gpu/vugpu.h | 8 ++++---- contrib/vhost-user-gpu/vhost-user-gpu.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)contrib/vhost-user-gpu/vugpu.h +3
-3@@ -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", \
Quoted 8 lines
contrib/vhost-user-gpu/vugpu.h struct virtio_gpu_ctrl_command { · line 175
Quoted 5 lines
contrib/vhost-user-gpu/vugpu.h +1
-1- __func__, s, sizeof(out)); \ + __func__, vugpufillcmd_s_, sizeof(out)); \return ; \ } \ }while (0 )I think I prefer
VUGPU_FILL_CMD_sorVUGPU_FILL_CMD_s_- makes it clear it's related to a macro.
I have to say that I don't like that ... it's a variable after all, and naming it with capital letters looks rather confusing that helpful to me. I think it should be enough to have the underscore at the end here to make it unique enough.
Thomas
Quoted 36 lines · Thomas Huth
Quoted 26 lines · Michael S. Tsirkin
Quoted 25 lines · Thomas Huth
Rename some variables to avoid compiler warnings when compiling with -Wshadow=local.
Signed-off-by Thomas Huth <[email protected]>---
v2: Renamed the variable to something more uniquecontrib/vhost-user-gpu/vugpu.h | 8 ++++---- contrib/vhost-user-gpu/vhost-user-gpu.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)contrib/vhost-user-gpu/vugpu.h +3
-3@@ -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)) { \Quoted 8 lines
contrib/vhost-user-gpu/vugpu.h struct virtio_gpu_ctrl_command { · line 175
Quoted 6 lines
contrib/vhost-user-gpu/vugpu.h +1
-1g_critical ("%s: command size incorrect %zu vs %zu" , \ - __func__, s,sizeof (out)); \ + __func__, vugpufillcmd_s_,sizeof (out)); \return ; \ } \ }while (0 )I think I prefer
VUGPU_FILL_CMD_sorVUGPU_FILL_CMD_s_- makes it clear it's related to a macro.
Quoted 1 line
I have to say that I don't like that ... it's a variable after all, and naming it with capital letters looks rather confusing that helpful to me. I think it should be enough to have the underscore at the end here to make it unique enough.
Concur. Plenty of precedence in the tree.
Quoted 22 lines · Thomas Huth
Rename some variables to avoid compiler warnings when compiling with -Wshadow=local.
Signed-off-by Thomas Huth <[email protected]>---
v2: Renamed the variable to something more uniquecontrib/vhost-user-gpu/vugpu.h | 8 ++++---- contrib/vhost-user-gpu/vhost-user-gpu.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)contrib/vhost-user-gpu/vugpu.h +1
-2@@ -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_ = \
contrib/vhost-user-gpu/vugpu.h struct virtio_gpu_ctrl_command { · line 175
Quoted 10 lines
contrib/vhost-user-gpu/vugpu.h +3
-2+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 )
v1 renamed to s_ instead, which I find much easier to read. Michael asked you to change it so it's less likely to break if we pass it a macro that also uses s_. Unlikely to happen, and would fail safe: build breaks.
Quoted 17 lines
contrib/vhost-user-gpu/vhost-user-gpu.c +1
-1@@ -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,
contrib/vhost-user-gpu/vhost-user-gpu.c vg_resource_flush(VuGpu *g, · line 852
Quoted 10 lines
contrib/vhost-user-gpu/vhost-user-gpu.c +2
-2- 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); }
I'm going to queue v1. Michael, if you want me to queue v2 instead, or neither of the two, let me know.
Quoted 62 lines · Markus Armbruster
Quoted 22 lines · Thomas Huth
Rename some variables to avoid compiler warnings when compiling with -Wshadow=local.
Signed-off-by Thomas Huth <[email protected]>---
v2: Renamed the variable to something more uniquecontrib/vhost-user-gpu/vugpu.h | 8 ++++---- contrib/vhost-user-gpu/vhost-user-gpu.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)contrib/vhost-user-gpu/vugpu.h +1
-2@@ -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_ = \contrib/vhost-user-gpu/vugpu.h struct virtio_gpu_ctrl_command { · line 175
Quoted 10 lines
contrib/vhost-user-gpu/vugpu.h +3
-2+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 )v1 renamed to s_ instead, which I find much easier to read. Michael asked you to change it so it's less likely to break if we pass it a macro that also uses s_. Unlikely to happen, and would fail safe: build breaks.
Quoted 22 lines
contrib/vhost-user-gpu/vhost-user-gpu.c +2
-2@@ -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);
Quoted 8 lines
contrib/vhost-user-gpu/vhost-user-gpu.c vg_resource_flush(VuGpu *g, · line 852
Quoted 5 lines
contrib/vhost-user-gpu/vhost-user-gpu.c +1
-1-pixman_image_unref (i); +pixman_image_unref (img);vg_send_msg (g, msg,-1 );g_free (msg); }I'm going to queue v1. Michael, if you want me to queue v2 instead, or neither of the two, let me know.
Yea I think v2 is better, queue that please.
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Markus Armbruster
Quoted 6 lines · Thomas Huth
Rename some variables to avoid compiler warnings when compiling with -Wshadow=local.
Signed-off-by Thomas Huth <[email protected]>---
v2: Renamed the variable to something more unique
[...]
Quoted 4 lines
Quoted 4 lines
v1 renamed to s_ instead, which I find much easier to read. Michael asked you to change it so it's less likely to break if we pass it a macro that also uses s_. Unlikely to happen, and would fail safe: build breaks.
[...]
Quoted 4 lines
Quoted 2 lines
I'm going to queue v1. Michael, if you want me to queue v2 instead, or neither of the two, let me know.
Yea I think v2 is better, queue that please.
Done. Thanks!