src/daemon/utils_time.h: Return structs from CDTIME_T_TO_TIME{VAL,SPEC}.
[collectd.git] / src / daemon / utils_time.c
index a3a9c33..b24ceac 100644 (file)
@@ -86,15 +86,12 @@ cdtime_t cdtime (void) /* {{{ */
 
 static int get_utc_time (cdtime_t t, struct tm *t_tm, long *nsec) /* {{{ */
 {
-  struct timespec t_spec;
-  int status;
-
-  CDTIME_T_TO_TIMESPEC (t, &t_spec);
+  struct timespec t_spec = CDTIME_T_TO_TIMESPEC (t);
   NORMALIZE_TIMESPEC (t_spec);
 
   if (gmtime_r (&t_spec.tv_sec, t_tm) == NULL) {
     char errbuf[1024];
-    status = errno;
+    int status = errno;
     ERROR ("get_utc_time: gmtime_r failed: %s",
         sstrerror (status, errbuf, sizeof (errbuf)));
     return status;
@@ -106,15 +103,12 @@ static int get_utc_time (cdtime_t t, struct tm *t_tm, long *nsec) /* {{{ */
 
 static int get_local_time (cdtime_t t, struct tm *t_tm, long *nsec) /* {{{ */
 {
-  struct timespec t_spec;
-  int status;
-
-  CDTIME_T_TO_TIMESPEC (t, &t_spec);
+  struct timespec t_spec = CDTIME_T_TO_TIMESPEC (t);
   NORMALIZE_TIMESPEC (t_spec);
 
   if (localtime_r (&t_spec.tv_sec, t_tm) == NULL) {
     char errbuf[1024];
-    status = errno;
+    int status = errno;
     ERROR ("get_local_time: localtime_r failed: %s",
         sstrerror (status, errbuf, sizeof (errbuf)));
     return status;