]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: time_t is not a long on FreeBSD
authorMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 13 May 2011 06:31:03 +0000 (08:31 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 25 May 2011 16:47:50 +0000 (18:47 +0200)
localtime_r expects time_t.

tools/virsh.c

index de4948932f99be8d99b19ef0b76be631c86eaa03..b43c167cfbc39aa0530f7df1a3b5948442426dc7 100644 (file)
@@ -10442,7 +10442,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
     char *doc = NULL;
     virDomainSnapshotPtr snapshot = NULL;
     char *state = NULL;
-    long creation;
+    long long creation_longlong;
+    time_t creation_time_t;
     char timestr[100];
     struct tm time_info;
 
@@ -10501,10 +10502,15 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
             state = virXPathString("string(/domainsnapshot/state)", ctxt);
             if (state == NULL)
                 continue;
-            if (virXPathLong("string(/domainsnapshot/creationTime)", ctxt,
-                             &creation) < 0)
+            if (virXPathLongLong("string(/domainsnapshot/creationTime)", ctxt,
+                                 &creation_longlong) < 0)
                 continue;
-            localtime_r(&creation, &time_info);
+            creation_time_t = creation_longlong;
+            if (creation_time_t != creation_longlong) {
+                vshError(ctl, "%s", _("time_t overflow"));
+                continue;
+            }
+            localtime_r(&creation_time_t, &time_info);
             strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %z", &time_info);
 
             vshPrint(ctl, " %-20s %-25s %s\n", names[i], timestr, state);