qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/3]use int64 when compare two time


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH 1/3]use int64 when compare two time
Date: Fri, 06 Jan 2012 18:44:06 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0

Am 06.01.2012 08:37, schrieb Zhang, Yang Z:
> use int64 when compare two time
> 
> int32 only represent only 136 years when comparing two times based on second. 
> It would be better to use int64.

int32 and int64 are softfloat types and should not be used here.

Do you have an actual use case that breaks with int / int32_t?

> 
> Signed-off-by: Yang Zhang <address@hidden>

> diff --git a/vl.c b/vl.c
> index 640e3ca..01c5a9d 100644
> --- a/vl.c
> +++ b/vl.c

> @@ -454,7 +454,7 @@ void qemu_get_timedate(struct tm *tm, int offset)
>      memcpy(tm, ret, sizeof(struct tm));
>  }
> 
> -int qemu_timedate_diff(struct tm *tm)
> +int64_t qemu_timedate_diff(struct tm *tm)
>  {
>      time_t seconds;
> 
> @@ -476,7 +476,7 @@ void rtc_change_mon_event(struct tm *tm)
>  {
>      QObject *data;
> 
> -    data = qobject_from_jsonf("{ 'offset': %d }", qemu_timedate_diff(tm));
> +    data = qobject_from_jsonf("{ 'offset': %ld }", qemu_timedate_diff(tm));

That's wrong, %ld is for long. For int64_t you need to use PRId64.

Andreas

>      monitor_protocol_event(QEVENT_RTC_CHANGE, data);
>      qobject_decref(data);
>  }

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

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