Skip to contentSkip to conversation

contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow

PATCH Superseded Thomas Huth 3 participants 4 messages Oct 6, 2023 – Oct 8, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 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
index 509b679f03..5cede45134 100644
@@ -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 s_;                                              \
+        s_ = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \
                        &out, sizeof(out));                      \
-        if (s != sizeof(out)) {                                 \
+        if (s_ != sizeof(out)) {                                \
             g_critical("%s: command size incorrect %zu vs %zu", \
-                       __func__, s, sizeof(out));               \
+                       __func__, s_, sizeof(out));              \
             return;                                             \
         }                                                       \
     } while (0)
contrib/vhost-user-gpu/vhost-user-gpu.c +3 -3
index aa304475a0..bb41758e34 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Thomas Huth

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

Quoted 56 lines
---
 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
index 509b679f03..5cede45134 100644
@@ -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 s_;                                              \
+        s_ = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \
                        &out, sizeof(out));                      \
-        if (s != sizeof(out)) {                                 \
+        if (s_ != sizeof(out)) {                                \
             g_critical("%s: command size incorrect %zu vs %zu", \
-                       __func__, s, sizeof(out));               \
+                       __func__, s_, sizeof(out));              \
             return;                                             \
         }                                                       \
     } while (0)
contrib/vhost-user-gpu/vhost-user-gpu.c +3 -4
index aa304475a0..bb41758e34 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 4 lines · Thomas Huth

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

Quoted 55 lines
---
 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
index 509b679f03..5cede45134 100644
@@ -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 s_;                                              \
+        s_ = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \
                        &out, sizeof(out));                      \
-        if (s != sizeof(out)) {                                 \
+        if (s_ != sizeof(out)) {                                \
             g_critical("%s: command size incorrect %zu vs %zu", \
-                       __func__, s, sizeof(out));               \
+                       __func__, s_, sizeof(out));              \
             return;                                             \
         }                                                       \
     } while (0)
contrib/vhost-user-gpu/vhost-user-gpu.c +3 -3
index aa304475a0..bb41758e34 100644
@@ -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
#3 lore raw
In reply to Thomas Huth
Quoted 20 lines · Thomas Huth

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

---
 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 +1 -2
index 509b679f03..5cede45134 100644
@@ -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 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
+        s_ = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \
                        &out, sizeof(out));                      \
-        if (s != sizeof(out)) {                                 \
+        if (s_ != sizeof(out)) {                                \
             g_critical("%s: command size incorrect %zu vs %zu", \
-                       __func__, s, sizeof(out));               \
+                       __func__, s_, sizeof(out));              \
             return;                                             \
         }                                                       \
     } while (0)

Oh wait this is the same issue. Fixes it now but can start failing down the road. Let's use something specific to this macro. VUGPU_FILL_CMD_s ?

Quoted 29 lines
contrib/vhost-user-gpu/vhost-user-gpu.c +3 -3
index aa304475a0..bb41758e34 100644
@@ -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