src/daemon/utils_time.h: Return structs from CDTIME_T_TO_TIME{VAL,SPEC}.
[collectd.git] / src / daemon / collectd.c
index 8573579..4843fc6 100644 (file)
@@ -101,7 +101,7 @@ static int init_hostname (void)
        int status;
 
        str = global_option_get ("Hostname");
-       if (str != NULL)
+       if ((str != NULL) && (str[0] != 0))
        {
                sstrncpy (hostname_g, str, sizeof (hostname_g));
                return (0);
@@ -341,7 +341,6 @@ static int do_loop (void)
 
        while (loop == 0)
        {
-               struct timespec ts_wait = { 0, 0 };
                cdtime_t now;
 
 #if HAVE_LIBKSTAT
@@ -361,7 +360,7 @@ static int do_loop (void)
                        continue;
                }
 
-               CDTIME_T_TO_TIMESPEC (wait_until - now, &ts_wait);
+               struct timespec ts_wait = CDTIME_T_TO_TIMESPEC (wait_until - now);
                wait_until = wait_until + interval;
 
                while ((loop == 0) && (nanosleep (&ts_wait, &ts_wait) != 0))
@@ -602,7 +601,7 @@ int main (int argc, char **argv)
         * something wrong.
         */
        if (init_global_variables () != 0)
-               return (1);
+               exit (EXIT_FAILURE);
 
        if (test_config)
                return (0);