From: "Andreas Färber" <afaerber@suse.de>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>
Cc: "aliguori@us.ibm.com" <aliguori@us.ibm.com>,
"Shan, Haitao" <haitao.shan@intel.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"avi@redhat.com" <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/3]use int64 when compare two time
Date: Fri, 06 Jan 2012 18:44:06 +0100 [thread overview]
Message-ID: <4F0732E6.6000707@suse.de> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E018CCB@SHSMSX101.ccr.corp.intel.com>
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@intel.com>
> 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
next prev parent reply other threads:[~2012-01-06 17:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-06 7:37 [Qemu-devel] [PATCH 1/3]use int64 when compare two time Zhang, Yang Z
2012-01-06 13:20 ` Peter Maydell
2012-01-10 16:51 ` Marcelo Tosatti
2012-01-06 17:44 ` Andreas Färber [this message]
2012-01-10 5:18 ` Zhang, Yang Z
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F0732E6.6000707@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=haitao.shan@intel.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=yang.z.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).