* [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
@ 2023-10-09 8:37 Thomas Huth
2023-10-09 11:45 ` Michael S. Tsirkin
2023-10-12 12:18 ` Markus Armbruster
0 siblings, 2 replies; 7+ messages in thread
From: Thomas Huth @ 2023-10-09 8:37 UTC (permalink / raw)
To: Marc-André Lureau, Michael S. Tsirkin, qemu-devel
Cc: Gerd Hoffmann, Markus Armbruster
Rename some variables to avoid compiler warnings when compiling
with -Wshadow=local.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
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(-)
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
* Re: [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
2023-10-09 8:37 [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow Thomas Huth
@ 2023-10-09 11:45 ` Michael S. Tsirkin
2023-10-09 12:05 ` Thomas Huth
2023-10-12 12:18 ` Markus Armbruster
1 sibling, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2023-10-09 11:45 UTC (permalink / raw)
To: Thomas Huth
Cc: Marc-André Lureau, qemu-devel, Gerd Hoffmann, Markus Armbruster
On Mon, Oct 09, 2023 at 10:37:25AM +0200, Thomas Huth wrote:
> Rename some variables to avoid compiler warnings when compiling
> with -Wshadow=local.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> 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(-)
>
> 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)
I think I prefer VUGPU_FILL_CMD_s or VUGPU_FILL_CMD_s_ - makes it clear
it's related to a macro.
> 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 [flat|nested] 7+ messages in thread
* Re: [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
2023-10-09 11:45 ` Michael S. Tsirkin
@ 2023-10-09 12:05 ` Thomas Huth
2023-10-09 12:39 ` Markus Armbruster
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Huth @ 2023-10-09 12:05 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Marc-André Lureau, qemu-devel, Gerd Hoffmann, Markus Armbruster
On 09/10/2023 13.45, Michael S. Tsirkin wrote:
> On Mon, Oct 09, 2023 at 10:37:25AM +0200, Thomas Huth wrote:
>> Rename some variables to avoid compiler warnings when compiling
>> with -Wshadow=local.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>> 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(-)
>>
>> 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)
>
> I think I prefer VUGPU_FILL_CMD_s or VUGPU_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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
2023-10-09 12:05 ` Thomas Huth
@ 2023-10-09 12:39 ` Markus Armbruster
0 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2023-10-09 12:39 UTC (permalink / raw)
To: Thomas Huth
Cc: Michael S. Tsirkin, Marc-André Lureau, qemu-devel, Gerd Hoffmann
Thomas Huth <thuth@redhat.com> writes:
> On 09/10/2023 13.45, Michael S. Tsirkin wrote:
>> On Mon, Oct 09, 2023 at 10:37:25AM +0200, Thomas Huth wrote:
>>> Rename some variables to avoid compiler warnings when compiling
>>> with -Wshadow=local.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>> 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(-)
>>>
>>> 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)
>> I think I prefer VUGPU_FILL_CMD_s or VUGPU_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.
Concur. Plenty of precedence in the tree.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
2023-10-09 8:37 [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow Thomas Huth
2023-10-09 11:45 ` Michael S. Tsirkin
@ 2023-10-12 12:18 ` Markus Armbruster
2023-10-12 13:08 ` Michael S. Tsirkin
1 sibling, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2023-10-12 12:18 UTC (permalink / raw)
To: Thomas Huth
Cc: Marc-André Lureau, Michael S. Tsirkin, qemu-devel, Gerd Hoffmann
Thomas Huth <thuth@redhat.com> writes:
> Rename some variables to avoid compiler warnings when compiling
> with -Wshadow=local.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> 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(-)
>
> 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)
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.
> 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);
> }
I'm going to queue v1. Michael, if you want me to queue v2 instead, or
neither of the two, let me know.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
2023-10-12 12:18 ` Markus Armbruster
@ 2023-10-12 13:08 ` Michael S. Tsirkin
2023-10-12 15:17 ` Markus Armbruster
0 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2023-10-12 13:08 UTC (permalink / raw)
To: Markus Armbruster
Cc: Thomas Huth, Marc-André Lureau, qemu-devel, Gerd Hoffmann
On Thu, Oct 12, 2023 at 02:18:44PM +0200, Markus Armbruster wrote:
> Thomas Huth <thuth@redhat.com> writes:
>
> > Rename some variables to avoid compiler warnings when compiling
> > with -Wshadow=local.
> >
> > Signed-off-by: Thomas Huth <thuth@redhat.com>
> > ---
> > 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(-)
> >
> > 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)
>
> 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.
>
> > 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);
> > }
>
> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
2023-10-12 13:08 ` Michael S. Tsirkin
@ 2023-10-12 15:17 ` Markus Armbruster
0 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2023-10-12 15:17 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Thomas Huth, Marc-André Lureau, qemu-devel, Gerd Hoffmann
"Michael S. Tsirkin" <mst@redhat.com> writes:
> On Thu, Oct 12, 2023 at 02:18:44PM +0200, Markus Armbruster wrote:
>> Thomas Huth <thuth@redhat.com> writes:
>>
>> > Rename some variables to avoid compiler warnings when compiling
>> > with -Wshadow=local.
>> >
>> > Signed-off-by: Thomas Huth <thuth@redhat.com>
>> > ---
>> > v2: Renamed the variable to something more unique
[...]
>> 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.
[...]
>> 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!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-10-12 15:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-09 8:37 [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow Thomas Huth
2023-10-09 11:45 ` Michael S. Tsirkin
2023-10-09 12:05 ` Thomas Huth
2023-10-09 12:39 ` Markus Armbruster
2023-10-12 12:18 ` Markus Armbruster
2023-10-12 13:08 ` Michael S. Tsirkin
2023-10-12 15:17 ` Markus Armbruster
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.