[PATCH 1/3]use int64 when compare two time

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

 



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

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);
 }
--
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