Received: from eggs.gnu.org ([2001:4830:134:3::10]:57642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQxuh-00006z-4d for qemu-devel@nongnu.org; Mon, 08 Sep 2014 08:19:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XQxuW-0003EI-2x for qemu-devel@nongnu.org; Mon, 08 Sep 2014 08:19:19 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:57757 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQxuV-0003Dp-S1 for qemu-devel@nongnu.org; Mon, 08 Sep 2014 08:19:08 -0400 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Mon, 8 Sep 2014 14:18:11 +0200 Message-Id: <1410178693-23370-2-git-send-email-benoit.canet@nodalink.com> In-Reply-To: <1410178693-23370-1-git-send-email-benoit.canet@nodalink.com> References: <1410178693-23370-1-git-send-email-benoit.canet@nodalink.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [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: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Beno=C3=AEt=20Canet?= We will want to reuse this define in the future by making it common to mu= ltiples QEMU modules. It would be safer that this define be an integer so we avoid stranges flo= at rounding errors. Do this conversion. Signed-off-by: Beno=C3=AEt Canet --- include/qemu/throttle.h | 2 +- util/throttle.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 =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 del= ta_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_S= ECOND; =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; wait /=3D limit; return wait; } --=20 2.1.0