qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>,
	Fabiano Rosas <farosas@suse.de>,
	Leonardo Bras <leobras@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH] migration/ram: Fix compilation with -Wshadow=local
Date: Mon, 23 Oct 2023 19:11:50 +0200	[thread overview]
Message-ID: <a326eafb-955b-4867-94f5-052672f93138@redhat.com> (raw)
In-Reply-To: <ZTaX00kf3UcQG/AF@x1n>

On 23/10/2023 17.57, Peter Xu wrote:
> On Mon, Oct 23, 2023 at 04:50:44PM +0200, Thomas Huth wrote:
>> No need for a new variable here, especially not for one that shadows
>> a variable from the beginning of the function scope. With this change
>> the code now successfully compiles with -Wshadow=local.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   migration/ram.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/migration/ram.c b/migration/ram.c
>> index 92769902bb..9de9e54fa9 100644
>> --- a/migration/ram.c
>> +++ b/migration/ram.c
>> @@ -3238,8 +3238,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
>>   
>>           ram_flush_compressed_data(rs);
>>   
>> -        int ret = rdma_registration_stop(f, RAM_CONTROL_FINISH);
>> -        if (ret < 0) {
>> +        if (rdma_registration_stop(f, RAM_CONTROL_FINISH) < 0) {
> 
> We may need to rename "ret" to something else?  qemu_file_set_error(),
> right below, will reference the error returned.
> 
>>               qemu_file_set_error(f, ret);   <-----------------

Oh, drat, right ... that's exactly one of the reasons why shadowing 
variables is a bad idea ;-)

I'll redo a v2.

  Thomas



  reply	other threads:[~2023-10-23 17:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 14:50 [PATCH] migration/ram: Fix compilation with -Wshadow=local Thomas Huth
2023-10-23 15:27 ` Markus Armbruster
2023-10-24  4:55   ` Markus Armbruster
2023-10-23 15:57 ` Peter Xu
2023-10-23 17:11   ` Thomas Huth [this message]
2023-10-23 17:30     ` ram_save_complete() is fishy (was: Re: [PATCH] migration/ram: Fix compilation with -Wshadow=local) Thomas Huth
2023-10-23 18:55       ` Peter Xu
2023-10-24  9:05         ` ram_save_complete() is fishy Thomas Huth
2023-10-24 13:12           ` Peter Xu

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=a326eafb-955b-4867-94f5-052672f93138@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=farosas@suse.de \
    --cc=leobras@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).