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: Sergey Fedorov
Subject: Re: [Qemu-devel] [PATCH] qtest: fix qtest_clock_warp() for no deadline case
Date: Tue, 10 Jun 2014 13:08:01 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

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 <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.

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
>>
>>
>>




reply via email to

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