qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	qemu-devel@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [PATCH v2] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow
Date: Mon, 9 Oct 2023 14:05:22 +0200	[thread overview]
Message-ID: <59c76034-62d5-c94c-8b3b-fa206768ee1d@redhat.com> (raw)
In-Reply-To: <20231009074333-mutt-send-email-mst@kernel.org>

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



  reply	other threads:[~2023-10-09 12:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59c76034-62d5-c94c-8b3b-fa206768ee1d@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).