From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: Fangrui Song <i@maskray.me>,
richard.henderson@linaro.org, dgilbert@redhat.com,
quintela@redhat.com
Subject: Re: [PATCH v3 1/2] migration: Fix incorrect integer->float conversion caught by clang
Date: Fri, 22 Nov 2019 11:31:49 +0100 [thread overview]
Message-ID: <2827a9a2-16fa-9639-d3b7-076e2acefae9@redhat.com> (raw)
In-Reply-To: <20191122080039.12771-2-armbru@redhat.com>
On 11/22/19 9:00 AM, Markus Armbruster wrote:
> From: Fangrui Song <i@maskray.me>
>
> Clang does not like qmp_migrate_set_downtime()'s code to clamp double
> @value to 0..INT64_MAX:
>
> qemu/migration/migration.c:2038:24: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
>
> The warning will be enabled by default in clang 10. It is not
> available for clang <= 9.
>
> The clamp is actually useless; @value is checked to be within
> 0..MAX_MIGRATE_DOWNTIME_SECONDS immediately before. Delete it.
>
> While there, make the conversion from double to int64_t explicit.
>
> Signed-off-by: Fangrui Song <i@maskray.me>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> [Patch split, commit message improved]
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> migration/migration.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index 354ad072fa..09b150663f 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -2035,11 +2035,10 @@ void qmp_migrate_set_downtime(double value, Error **errp)
> }
>
> value *= 1000; /* Convert to milliseconds */
> - value = MAX(0, MIN(INT64_MAX, value));
>
> MigrateSetParameters p = {
> .has_downtime_limit = true,
> - .downtime_limit = value,
> + .downtime_limit = (int64_t)value,
I agree with Eric a one line comment about the explicit cast is
welcomed. We can still use 'git blame', find the last commit sha, then
look at the commit description. But having it along the code is
straightforward.
Preferably with a comment (the maintainer queing this can amend it):
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> };
>
> qmp_migrate_set_parameters(&p, errp);
>
next prev parent reply other threads:[~2019-11-22 10:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 8:00 [PATCH v3 0/2] Fix incorrect integer->float conversion caught by clang Markus Armbruster
2019-11-22 8:00 ` [PATCH v3 1/2] migration: " Markus Armbruster
2019-11-22 8:13 ` Richard Henderson
2019-11-22 8:54 ` Juan Quintela
2019-11-22 14:05 ` Markus Armbruster
2020-01-14 10:00 ` Markus Armbruster
2020-01-14 11:08 ` Juan Quintela
2020-01-20 18:43 ` Dr. David Alan Gilbert
2019-11-22 10:31 ` Philippe Mathieu-Daudé [this message]
2019-11-22 8:00 ` [PATCH v3 2/2] util/cutils: " Markus Armbruster
2019-11-22 8:13 ` Richard Henderson
2019-11-22 8:55 ` Juan Quintela
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=2827a9a2-16fa-9639-d3b7-076e2acefae9@redhat.com \
--to=philmd@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=i@maskray.me \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=richard.henderson@linaro.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).