summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Maydell2019-11-25 16:05:52 +0100
committerPeter Maydell2019-11-25 16:05:53 +0100
commit6d05e39d69a6876d8a604773157a303da9bec16b (patch)
tree21cd63561c8b6558943e983a5d0a9548e909b28d
parentMerge remote-tracking branch 'remotes/gkurz/tags/9p-fix-2019-11-23' into staging (diff)
parentutil/cutils: Fix incorrect integer->float conversion caught by clang (diff)
downloadqemu-6d05e39d69a6876d8a604773157a303da9bec16b.tar.gz
qemu-6d05e39d69a6876d8a604773157a303da9bec16b.tar.xz
qemu-6d05e39d69a6876d8a604773157a303da9bec16b.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2019-11-25' into staging
Miscellaneous patches for 2019-11-25 # gpg: Signature made Mon 25 Nov 2019 06:00:24 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-misc-2019-11-25: util/cutils: Fix incorrect integer->float conversion caught by clang Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--util/cutils.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/util/cutils.c b/util/cutils.c
index fd591cadf0..77acadc70a 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -239,10 +239,12 @@ static int do_strtosz(const char *nptr, const char **end,
goto out;
}
/*
- * Values >= 0xfffffffffffffc00 overflow uint64_t after their trip
- * through double (53 bits of precision).
+ * Values near UINT64_MAX overflow to 2**64 when converting to double
+ * precision. Compare against the maximum representable double precision
+ * value below 2**64, computed as "the next value after 2**64 (0x1p64) in
+ * the direction of 0".
*/
- if ((val * mul >= 0xfffffffffffffc00) || val < 0) {
+ if ((val * mul > nextafter(0x1p64, 0)) || val < 0) {
retval = -ERANGE;
goto out;
}