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

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

 



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 <yang.z.zhang@xxxxxxxxx>

> 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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux