Code

src/daemon/utils_tail_match.c: Use match_value_reset().
[collectd.git] / src / daemon / collectd.c
index 3a6fe1e962abb033a06ce00d7e78399efa6462b1..4843fc659bd46d5c14191a26dc5b70f78b815645 100644 (file)
@@ -26,8 +26,8 @@
  **/
 
 #include "collectd.h"
-#include "common.h"
 
+#include "common.h"
 #include "plugin.h"
 #include "configfile.h"
 
@@ -98,11 +98,10 @@ static int init_hostname (void)
        const char *str;
 
        struct addrinfo *ai_list;
-       struct addrinfo *ai_ptr;
        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);
@@ -134,7 +133,7 @@ static int init_hostname (void)
                return (-1);
        }
 
-       for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
+       for (struct addrinfo *ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
        {
                if (ai_ptr->ai_canonname == NULL)
                        continue;
@@ -342,7 +341,6 @@ static int do_loop (void)
 
        while (loop == 0)
        {
-               struct timespec ts_wait = { 0, 0 };
                cdtime_t now;
 
 #if HAVE_LIBKSTAT
@@ -362,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))
@@ -603,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);