qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 25f740: util/cutils: Fix incorrect integer->f


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 25f740: util/cutils: Fix incorrect integer->float conversi...
Date: Mon, 25 Nov 2019 07:47:30 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 25f74087c695364dfaa87443b1040a3aa5c29008
      
https://github.com/qemu/qemu/commit/25f74087c695364dfaa87443b1040a3aa5c29008
  Author: Fangrui Song <address@hidden>
  Date:   2019-11-25 (Mon, 25 Nov 2019)

  Changed paths:
    M util/cutils.c

  Log Message:
  -----------
  util/cutils: Fix incorrect integer->float conversion caught by clang

Clang does not like do_strtosz()'s code to guard against overflow:

    qemu/util/cutils.c:245:23: error: implicit conversion from 'unsigned long' 
to 'double' changes value from 18446744073709550592 to 18446744073709551616 
[-Werror,-Wimplicit-int-float-conversion]

The warning will be enabled by default in clang 10. It is not
available for clang <= 9.

val * mul >= 0xfffffffffffffc00 is indeed wrong.  0xfffffffffffffc00
is not representable exactly as double.  It's half-way between the
representable values 0xfffffffffffff800 and 0x10000000000000000.
Which one we get is implementation-defined.  Bad.

We want val * mul > (the largest uint64_t exactly representable as
double).  That's 0xfffffffffffff800.  Write it as nextafter(0x1p64, 0)
with a suitable comment.

Signed-off-by: Fangrui Song <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
[Patch split, commit message improved]
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>


  Commit: 6d05e39d69a6876d8a604773157a303da9bec16b
      
https://github.com/qemu/qemu/commit/6d05e39d69a6876d8a604773157a303da9bec16b
  Author: Peter Maydell <address@hidden>
  Date:   2019-11-25 (Mon, 25 Nov 2019)

  Changed paths:
    M util/cutils.c

  Log Message:
  -----------
  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 "address@hidden"
# gpg: Good signature from "Markus Armbruster <address@hidden>" [full]
# gpg:                 aka "Markus Armbruster <address@hidden>" [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 <address@hidden>


Compare: https://github.com/qemu/qemu/compare/122e6d2a9c1b...6d05e39d69a6



reply via email to

[Prev in Thread] Current Thread [Next in Thread]