qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qtest: fix qtest_clock_warp() for no deadline c


From: Alex Bligh
Subject: Re: [Qemu-devel] [PATCH] qtest: fix qtest_clock_warp() for no deadline case
Date: Mon, 9 Jun 2014 18:36:51 +0100

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 <address@hidden>
> ---
> 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.

>         seqlock_write_lock(&timers_state.vm_clock_seqlock);
>         qemu_icount_bias += warp;
>         seqlock_write_unlock(&timers_state.vm_clock_seqlock);
> -- 
> 1.9.1
> 
> 
> 

-- 
Alex Bligh







reply via email to

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