From patchwork Fri Jan 6 07:37:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yang Z" X-Patchwork-Id: 134614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2E3E4B6FA4 for ; Fri, 6 Jan 2012 18:37:42 +1100 (EST) Received: from localhost ([::1]:49400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rj4Mt-0004LA-B0 for incoming@patchwork.ozlabs.org; Fri, 06 Jan 2012 02:37:39 -0500 Received: from eggs.gnu.org ([140.186.70.92]:38045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rj4Mm-0004Kt-Pd for qemu-devel@nongnu.org; Fri, 06 Jan 2012 02:37:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rj4Ml-0004n4-GT for qemu-devel@nongnu.org; Fri, 06 Jan 2012 02:37:32 -0500 Received: from mga14.intel.com ([143.182.124.37]:9194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rj4Ml-0004mp-7n for qemu-devel@nongnu.org; Fri, 06 Jan 2012 02:37:31 -0500 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 05 Jan 2012 23:37:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="53836180" Received: from pgsmsx603.gar.corp.intel.com ([10.221.43.87]) by AZSMGA002.ch.intel.com with ESMTP; 05 Jan 2012 23:37:27 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by pgsmsx603.gar.corp.intel.com (10.221.43.87) with Microsoft SMTP Server (TLS) id 8.2.255.0; Fri, 6 Jan 2012 15:37:27 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.38]) by SHSMSX102.ccr.corp.intel.com ([169.254.2.199]) with mapi id 14.01.0355.002; Fri, 6 Jan 2012 15:37:24 +0800 From: "Zhang, Yang Z" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH 1/3]use int64 when compare two time Thread-Index: AczMRgVWCc8WuH0DShemhq0xQhEKVw== Date: Fri, 6 Jan 2012 07:37:24 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 143.182.124.37 Cc: "aliguori@us.ibm.com" , "Shan, Haitao" , "avi@redhat.com" , "kvm@vger.kernel.org" Subject: [Qemu-devel] [PATCH 1/3]use int64 when compare two time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Yang Zhang diff --git a/qemu-common.h b/qemu-common.h index b2de015..c14f506 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -116,8 +116,8 @@ extern int use_icount; int qemu_main(int argc, char **argv, char **envp); #endif -void qemu_get_timedate(struct tm *tm, int offset); -int qemu_timedate_diff(struct tm *tm); +void qemu_get_timedate(struct tm *tm, int64_t offset); +int64_t qemu_timedate_diff(struct tm *tm); /* cutils.c */ void pstrcpy(char *buf, int buf_size, const char *str); diff --git a/vl.c b/vl.c index 640e3ca..01c5a9d 100644 --- a/vl.c +++ b/vl.c @@ -189,7 +189,7 @@ int nb_nics; NICInfo nd_table[MAX_NICS]; int autostart; static int rtc_utc = 1; -static int rtc_date_offset = -1; /* -1 means no change */ +static int64_t rtc_date_offset = -1; /* -1 means no change */ QEMUClock *rtc_clock; int vga_interface_type = VGA_NONE; static int full_screen = 0; @@ -434,7 +434,7 @@ StatusInfo *qmp_query_status(Error **errp) /***********************************************************/ /* host time/date access */ -void qemu_get_timedate(struct tm *tm, int offset) +void qemu_get_timedate(struct tm *tm, int64_t offset) { time_t ti; struct tm *ret; @@ -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)); monitor_protocol_event(QEVENT_RTC_CHANGE, data); qobject_decref(data); }