summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMatthias Bolte <matthias.bolte@googlemail.com>2011-05-13 08:31:03 +0200
committerMatthias Bolte <matthias.bolte@googlemail.com>2011-05-25 18:47:50 +0200
commit6df05081cb5724e519ebeb48ca71e8be20fa26d2 (patch)
tree694e815fd5e479254537901f7a18d27a01286b9f /tools
parenttime_t is not a long on FreeBSD, switch internal type to long long (diff)
downloadlibvirt-6df05081cb5724e519ebeb48ca71e8be20fa26d2.tar.gz
libvirt-6df05081cb5724e519ebeb48ca71e8be20fa26d2.tar.bz2
libvirt-6df05081cb5724e519ebeb48ca71e8be20fa26d2.zip
virsh: time_t is not a long on FreeBSD
localtime_r expects time_t.
Diffstat (limited to 'tools')
-rw-r--r--tools/virsh.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/virsh.c b/tools/virsh.c
index de4948932..b43c167cf 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -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);