qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>, qemu-devel@nongnu.org
Cc: Juan Quintela <quintela@redhat.com>,
	Leonardo Bras <leobras@redhat.com>, Peter Xu <peterx@redhat.com>,
	qemu-trivial@nongnu.org
Subject: Re: [PATCH 1/2] migration: factor out "resume_requested" in qmp_migrate()
Date: Thu, 6 Jul 2023 16:36:42 +0200	[thread overview]
Message-ID: <8f579ca4-b51c-db7c-b76e-0de2d083af68@redhat.com> (raw)
In-Reply-To: <33088999-cc41-7dd6-b522-84af01913172@tls.msk.ru>

On 7/6/23 15:28, Michael Tokarev wrote:
> 06.07.2023 13:29, Laszlo Ersek пишет:
>> It cuts back on those awkward, duplicated !(has_resume && resume)
>> expressions.
>>
>> Cc: Juan Quintela <quintela@redhat.com> (maintainer:Migration)
>> Cc: Leonardo Bras <leobras@redhat.com> (reviewer:Migration)
>> Cc: Peter Xu <peterx@redhat.com> (reviewer:Migration)
>> Cc: qemu-trivial@nongnu.org
>> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2018404
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>> ---
>>   migration/migration.c | 10 ++++++----
>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/migration/migration.c b/migration/migration.c
>> index 096e8191d15c..a60a5acee533 100644
>> --- a/migration/migration.c
>> +++ b/migration/migration.c
>> @@ -1637,6 +1637,7 @@ void qmp_migrate(const char *uri, bool has_blk,
>> bool blk,
>>                    bool has_inc, bool inc, bool has_detach, bool detach,
>>                    bool has_resume, bool resume, Error **errp)
>>   {
>> +    bool resume_requested;
>>       Error *local_err = NULL;
>>       MigrationState *s = migrate_get_current();
>>       const char *p = NULL;
>> @@ -1646,13 +1647,14 @@ void qmp_migrate(const char *uri, bool
>> has_blk, bool blk,
>>           return;
>>       }
>>   +    resume_requested = has_resume && resume;
> 
> Dunno if it's worth it or cleaner, but it can be reduced to
> 
>       if (!has_resume)  resume = false;
> 
> and checking for only resume below this point.
> In other words, there's no need for an additional local var.

I vehemently disagree with overwriting (input) parameters. One situation
where that practice is a disaster is single-stepping through the
function in an interactive debugger. You won't see the actual argument
the function was originally called with.

I know it's sometimes comfortable to just reuse a "count" input
paramater as a loop index that runs to zero -- I resist that too, it's a
trap (for the same reason), IMO.

> 
> All other params (has_inc & inc, has_detach_detach etc) are like this
> too.
> 
> Anyway,
> 
> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

Thanks!
Laszlo



  reply	other threads:[~2023-07-06 14:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 10:29 [PATCH 0/2] migration: trivialities Laszlo Ersek
2023-07-06 10:29 ` [PATCH 1/2] migration: factor out "resume_requested" in qmp_migrate() Laszlo Ersek
2023-07-06 11:42   ` Juan Quintela
2023-07-06 13:28   ` Michael Tokarev
2023-07-06 14:36     ` Laszlo Ersek [this message]
2023-07-06 16:42   ` Philippe Mathieu-Daudé
2023-07-06 10:29 ` [PATCH 2/2] migration: unexport migrate_fd_error() Laszlo Ersek
2023-07-06 11:42   ` Juan Quintela
2023-07-06 16:44   ` Philippe Mathieu-Daudé
2023-07-06 12:05 ` [PATCH 0/2] migration: trivialities Peter Xu
2023-07-06 17:09 ` Michael Tokarev

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=8f579ca4-b51c-db7c-b76e-0de2d083af68@redhat.com \
    --to=lersek@redhat.com \
    --cc=leobras@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).