[PATCH] Pass a correct pointer type to localtime_r(3).

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

 



>From b53dc971cc50b5ac397e4568449d25041477c8d6 Mon Sep 17 00:00:00 2001
From: Jasper Lievisse Adriaanse <jasper@xxxxxxxxx>
Date: Tue, 4 Sep 2012 16:47:26 +0200
Subject: [PATCH] Pass a correct pointer type to localtime_r(3).

Fixes a warning:
warning: passing argument 1 of 'localtime_r' from incompatible pointer type
---
 tools/virsh-domain.c |    3 ++-
 tools/virsh.c        |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f0ec742..535779c 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3711,6 +3711,7 @@ vshGenFileName(vshControl *ctl, virDomainPtr dom, const char *mime)
     struct tm time_info;
     const char *ext = NULL;
     char *ret = NULL;
+    time_t sec = (time_t) cur_time.tv_sec;
 
     if (!dom) {
         vshError(ctl, "%s", _("Invalid domain supplied"));
@@ -3724,7 +3725,7 @@ vshGenFileName(vshControl *ctl, virDomainPtr dom, const char *mime)
     /* add mime type here */
 
     gettimeofday(&cur_time, NULL);
-    localtime_r(&cur_time.tv_sec, &time_info);
+    localtime_r(&sec, &time_info);
     strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
 
     if (virAsprintf(&ret, "%s-%s%s", virDomainGetName(dom),
diff --git a/tools/virsh.c b/tools/virsh.c
index 5cf3237..5be2a3c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2189,6 +2189,7 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
     const char *lvl = "";
     struct timeval stTimeval;
     struct tm *stTm;
+    time_t sec = stTimeval.tv_sec;
 
     if (ctl->log_fd == -1)
         return;
@@ -2199,7 +2200,7 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
      * [YYYY.MM.DD HH:MM:SS SIGNATURE PID] LOG_LEVEL message
     */
     gettimeofday(&stTimeval, NULL);
-    stTm = localtime(&stTimeval.tv_sec);
+    stTm = localtime(&sec);
     virBufferAsprintf(&buf, "[%d.%02d.%02d %02d:%02d:%02d %s %d] ",
                       (1900 + stTm->tm_year),
                       (1 + stTm->tm_mon),
-- 
1.7.6


-- 
Cheers,
Jasper

"Stay Hungry. Stay Foolish"

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]