From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuI2P-0003ZY-3e for qemu-devel@nongnu.org; Tue, 10 Jun 2014 05:08:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuI2G-0006XA-2X for qemu-devel@nongnu.org; Tue, 10 Jun 2014 05:08:13 -0400 Received: from mail-la0-x232.google.com ([2a00:1450:4010:c03::232]:57260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuI2F-0006X2-Qr for qemu-devel@nongnu.org; Tue, 10 Jun 2014 05:08:04 -0400 Received: by mail-la0-f50.google.com with SMTP id b8so3789659lan.9 for ; Tue, 10 Jun 2014 02:08:02 -0700 (PDT) Message-ID: <5396CAF1.6070200@gmail.com> Date: Tue, 10 Jun 2014 13:08:01 +0400 From: Sergey Fedorov MIME-Version: 1.0 References: <1402332171-7159-1-git-send-email-serge.fdrv@gmail.com> <92F4C938-662F-4458-BF51-1BEC1C9869E7@alex.org.uk> In-Reply-To: <92F4C938-662F-4458-BF51-1BEC1C9869E7@alex.org.uk> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qtest: fix qtest_clock_warp() for no deadline case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: Paolo Bonzini , Richard Henderson , qemu-devel@nongnu.org, Stefan Hajnoczi , =?ISO-8859-1?Q?Andreas_F=E4rber?= On 09.06.2014 21:36, Alex Bligh wrote: > On 9 Jun 2014, at 17:42, Sergey Fedorov wrote: > >> If there is no deadline across all timerlists attached to the clock >> then qemu_clock_deadline_ns_all() returns -1. Cast it to unsinged so >> MIN() do not treat it as minimum. >> >> Signed-off-by: Sergey Fedorov >> --- >> cpus.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/cpus.c b/cpus.c >> index dd7ac13..3ec15cb 100644 >> --- a/cpus.c >> +++ b/cpus.c >> @@ -346,8 +346,8 @@ void qtest_clock_warp(int64_t dest) >> int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); >> assert(qtest_enabled()); >> while (clock < dest) { >> - int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); >> - int64_t warp = MIN(dest - clock, deadline); >> + uint64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); >> + uint64_t warp = MIN(dest - clock, deadline); > Please don't do that. It looks like a bug where you've not read the return > type. > > Instead, just do > > int64_t warp = qemu_soonest_timeout(dest - clock, deadline); > > which puts all the ugly casting stuff in one nicely documented inline function > and will generate the same code. Thank you! I'm resubmitting the patch. > >> seqlock_write_lock(&timers_state.vm_clock_seqlock); >> qemu_icount_bias += warp; >> seqlock_write_unlock(&timers_state.vm_clock_seqlock); >> -- >> 1.9.1 >> >> >>