From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XR0Cu-00079X-Fx for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:46:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XR0Cq-0001uo-08 for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:46:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XR0Cp-0001uh-Nr for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:46:11 -0400 Message-ID: <540DC12D.6090401@redhat.com> Date: Mon, 08 Sep 2014 08:46:05 -0600 From: Eric Blake MIME-Version: 1.0 References: <1410178693-23370-1-git-send-email-benoit.canet@nodalink.com> <1410178693-23370-2-git-send-email-benoit.canet@nodalink.com> In-Reply-To: <1410178693-23370-2-git-send-email-benoit.canet@nodalink.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GlQRBIucq0dJM2hRwblcwpKlu3RKCp6bA" Subject: Re: [Qemu-devel] [PATCH v2 1/3] throttle: Make NANOSECONDS_PER_SECOND an integer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QmVub8OudCBDYW5ldA==?= , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GlQRBIucq0dJM2hRwblcwpKlu3RKCp6bA Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/08/2014 06:18 AM, Beno=C3=AEt Canet wrote: > We will want to reuse this define in the future by making it common to = multiples s/multiples/multiple/ > QEMU modules. > It would be safer that this define be an integer so we avoid stranges f= loat s/stranges/strange/ > rounding errors. > Do this conversion. >=20 > Signed-off-by: Beno=C3=AEt Canet > --- > include/qemu/throttle.h | 2 +- > util/throttle.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h > index b890613..8f9e611 100644 > --- a/include/qemu/throttle.h > +++ b/include/qemu/throttle.h > @@ -27,7 +27,7 @@ > #include "qemu-common.h" > #include "qemu/timer.h" > =20 > -#define NANOSECONDS_PER_SECOND 1000000000.0 > +#define NANOSECONDS_PER_SECOND 1000000000 This hunk is good. > =20 > typedef enum { > THROTTLE_BPS_TOTAL, > diff --git a/util/throttle.c b/util/throttle.c > index f976ac7..af8445a 100644 > --- a/util/throttle.c > +++ b/util/throttle.c > @@ -34,7 +34,7 @@ void throttle_leak_bucket(LeakyBucket *bkt, int64_t d= elta_ns) > double leak; > =20 > /* compute how much to leak */ > - leak =3D (bkt->avg * (double) delta_ns) / NANOSECONDS_PER_SECOND; > + leak =3D (bkt->avg * (double) delta_ns) / (double) NANOSECONDS_PER= _SECOND; This hunk is spurious. With just your first hunk, it evaluates to the following types via promotion rules: (double * double) / int double / int double / double double so the explicit cast isn't changing anything. > =20 > /* make the bucket leak */ > bkt->level =3D MAX(bkt->level - leak, 0); > @@ -70,7 +70,7 @@ static void throttle_do_leak(ThrottleState *ts, int64= _t now) > */ > static int64_t throttle_do_compute_wait(double limit, double extra) > { > - double wait =3D extra * NANOSECONDS_PER_SECOND; > + double wait =3D extra * (double) NANOSECONDS_PER_SECOND; This hunk is also spurious. Again, with just your first hunk, it evaluates through the following promotion rules: double * int double * double double and the cast isn't changing anything. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GlQRBIucq0dJM2hRwblcwpKlu3RKCp6bA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUDcEtAAoJEKeha0olJ0NqUvMH/3MR/eLOdl/2Csn0ylNDTeJ8 r4oV+bSqsEBXAwh5TI1yBmfhXG/1d24aO38kxa9RIbEwcsgVafiCmUkNnEgpf7bc yc3M+ZTMKpKSA6ikaUIL3p/M6G4hjyb8IzDZHbPjDGJZvUtDQuCFnkkrEfI2fiPL qkmWzuPxpjNglFl6J3m17CTGW5VIRRC0lXj5/ILN84x6dLiyNkidjTzv2NkGfOd7 ixRf9Gmq4Zs0bpoBaNXsb2tXogvQHZkfRERjJoaCuohlv/GB7WVBkW/sZcHu3VoR 9gvQ/Vgakr2UUxeUxnBT3EHGzuLn3GNJinA9dJl63bSqD0x5xa8U7SmZpk93qbg= =omBJ -----END PGP SIGNATURE----- --GlQRBIucq0dJM2hRwblcwpKlu3RKCp6bA--