Merge branch 'collectd-5.5'
authorFlorian Forster <octo@collectd.org>
Thu, 18 Jun 2015 11:05:23 +0000 (13:05 +0200)
committerFlorian Forster <octo@collectd.org>
Thu, 18 Jun 2015 11:05:23 +0000 (13:05 +0200)
22 files changed:
src/amqp.c
src/battery.c
src/curl_json.c
src/daemon/filter_chain.c
src/daemon/utils_avltree.c
src/email.c
src/exec.c
src/gmond.c
src/libcollectdclient/client.c
src/modbus.c
src/network.c
src/nfs.c
src/ntpd.c
src/onewire.c
src/openvpn.c
src/ping.c
src/powerdns.c
src/snmp.c
src/tail.c
src/tail_csv.c
src/ted.c
src/threshold.c

index 97359cf..aba4f01 100644 (file)
@@ -716,7 +716,7 @@ static void *camqp_subscribe_thread (void *user_data) /* {{{ */
             continue;
         }
 
-        status = camqp_read_header (conf);
+        camqp_read_header (conf);
 
         amqp_maybe_release_buffers (conf->connection);
     } /* while (subscriber_threads_running) */
index 9b060dd..c4c050d 100644 (file)
@@ -556,7 +556,7 @@ static int read_acpi_full_capacity (char const *dir, /* {{{ */
 
        ssnprintf (filename, sizeof (filename), "%s/%s/info", dir, power_supply);
        fh = fopen (filename, "r");
-       if ((fh = fopen (filename, "r")) == NULL)
+       if (fh == NULL)
                return (errno);
 
        /* last full capacity:      40090 mWh */
@@ -615,7 +615,7 @@ static int read_acpi_callback (char const *dir, /* {{{ */
 
        ssnprintf (filename, sizeof (filename), "%s/%s/state", dir, power_supply);
        fh = fopen (filename, "r");
-       if ((fh = fopen (filename, "r")) == NULL)
+       if (fh == NULL)
        {
                if ((errno == EAGAIN) || (errno == EINTR) || (errno == ENOENT))
                        return (0);
index 937a237..c14e0f8 100644 (file)
@@ -552,7 +552,6 @@ static int cj_config_add_key (cj_t *db, /* {{{ */
       db->tree = cj_avl_create();
 
     tree = db->tree;
-    name = key->path;
     ptr = key->path;
     if (*ptr == '/')
       ++ptr;
index 0fd4a73..5042913 100644 (file)
@@ -392,7 +392,6 @@ static int fc_config_add_rule (fc_chain_t *chain, /* {{{ */
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Match", option->key) == 0)
       status = fc_config_add_match (&rule->matches, option);
@@ -486,7 +485,6 @@ static int fc_config_add_chain (const oconfig_item_t *ci) /* {{{ */
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Rule", option->key) == 0)
       status = fc_config_add_rule (chain, option);
index da793b3..e251975 100644 (file)
@@ -146,6 +146,9 @@ static c_avl_node_t *rotate_right (c_avl_tree_t *t, c_avl_node_t *x)
        c_avl_node_t *y;
        c_avl_node_t *b;
 
+       assert (x != NULL);
+       assert (x->left != NULL);
+
        p = x->parent;
        y = x->left;
        b = y->right;
@@ -170,7 +173,7 @@ static c_avl_node_t *rotate_right (c_avl_tree_t *t, c_avl_node_t *x)
        y->height = calc_height (y);
 
        return (y);
-} /* void rotate_left */
+} /* void rotate_right */
 
 /*
  *    (x)                   (y)
@@ -187,6 +190,9 @@ static c_avl_node_t *rotate_left (c_avl_tree_t *t, c_avl_node_t *x)
        c_avl_node_t *y;
        c_avl_node_t *b;
 
+       assert (x != NULL);
+       assert (x->right != NULL);
+
        p = x->parent;
        y = x->right;
        b = y->left;
index c2eab21..365af27 100644 (file)
@@ -256,8 +256,6 @@ static void *collect (void *arg)
        collector_t *this = (collector_t *)arg;
 
        while (1) {
-               int loop = 1;
-
                conn_t *connection;
 
                pthread_mutex_lock (&conns_mutex);
@@ -282,15 +280,13 @@ static void *collect (void *arg)
                log_debug ("collect: handling connection on fd #%i",
                                fileno (this->socket));
 
-               while (loop) {
+               while (42) {
                        /* 256 bytes ought to be enough for anybody ;-) */
                        char line[256 + 1]; /* line + '\0' */
                        int  len = 0;
 
                        errno = 0;
                        if (NULL == fgets (line, sizeof (line), this->socket)) {
-                               loop = 0;
-
                                if (0 != errno) {
                                        char errbuf[1024];
                                        log_err ("collect: reading from socket (fd #%i) "
@@ -363,7 +359,7 @@ static void *collect (void *arg)
                        else {
                                log_err ("collect: unknown type '%c'", line[0]);
                        }
-               } /* while (loop) */
+               } /* while (42) */
 
                log_debug ("Shutting down connection on fd #%i",
                                fileno (this->socket));
index 3f68e8b..8d737ce 100644 (file)
@@ -339,7 +339,7 @@ static void exec_child (program_list_t *pl, int uid, int gid, int egid) /* {{{ *
     exit (-1);
   }
 
-  status = execvp (pl->exec, pl->argv);
+  execvp (pl->exec, pl->argv);
 
   ERROR ("exec plugin: Failed to execute ``%s'': %s",
       pl->exec, sstrerror (errno, errbuf, sizeof (errbuf)));
index a00b26d..0811c2b 100644 (file)
@@ -665,7 +665,7 @@ static int mc_handle_value_msg (Ganglia_value_msg *msg) /* {{{ */
     if ((map->ds_type == DS_TYPE_COUNTER)
         || (map->ds_type == DS_TYPE_ABSOLUTE))
       val_copy = value_counter;
-    if (map->ds_type == DS_TYPE_GAUGE)
+    else if (map->ds_type == DS_TYPE_GAUGE)
       val_copy = value_gauge;
     else if (map->ds_type == DS_TYPE_DERIVE)
       val_copy = value_derive;
index 9ad61f6..a97dc50 100644 (file)
@@ -500,7 +500,6 @@ static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */
     if (fd < 0)
     {
       status = errno;
-      fd = -1;
       continue;
     }
 
@@ -509,7 +508,6 @@ static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */
     {
       status = errno;
       close (fd);
-      fd = -1;
       continue;
     }
 
@@ -518,7 +516,6 @@ static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */
     {
       status = errno;
       close (fd);
-      fd = -1;
       continue;
     }
 
index 97840fd..ae88f01 100644 (file)
@@ -463,7 +463,6 @@ static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */
   else
     values_num = 1;
 
-  status = 0;
   if (host->connection == NULL)
   {
     status = EBADF;
@@ -733,7 +732,6 @@ static int mb_config_add_data (oconfig_item_t *ci) /* {{{ */
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *child = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Type", child->key) == 0)
       status = cf_util_get_string_buffer (child,
@@ -894,7 +892,6 @@ static int mb_config_add_slave (mb_host_t *host, oconfig_item_t *ci) /* {{{ */
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *child = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Instance", child->key) == 0)
       status = cf_util_get_string_buffer (child,
index 4edc4f6..e90bb39 100644 (file)
@@ -2567,10 +2567,6 @@ static int network_receive (void) /* {{{ */
                receive_list_tail = private_list_tail;
                receive_list_length += private_list_length;
 
-               private_list_head = NULL;
-               private_list_tail = NULL;
-               private_list_length = 0;
-
                pthread_cond_signal (&receive_list_cond);
                pthread_mutex_unlock (&receive_list_lock);
        }
index 4285d76..be82372 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
@@ -506,6 +506,7 @@ static int nfs_submit_nfs4_client (const char *instance, char **fields,
                case 42:
                case 44:
                        proc40_names_num = 36;
+                       break;
                case 46:
                case 47:
                case 51:
index 15b12f9..5fdfef3 100644 (file)
@@ -670,7 +670,6 @@ static int ntpd_receive_response (int *res_items, int *res_size,
                                (items_num + pkt_item_num) * res_item_size);
                if (items == NULL)
                {
-                       items = *res_data;
                        ERROR ("ntpd plugin: realloc failed.");
                        continue;
                }
index 6cfea0e..58c35e1 100644 (file)
@@ -384,7 +384,6 @@ static int cow_read_values (const char *path, const char *name,
     if (endptr == NULL)
     {
       ERROR ("onewire plugin: Buffer is not a number: %s", buffer);
-      status = -1;
       continue;
     }
 
@@ -528,7 +527,6 @@ static int cow_simple_read (void)
       if (endptr == NULL)
       {
           ERROR ("onewire plugin: Buffer is not a number: %s", buffer);
-          status = -1;
           continue;
       }
 
index 0fd9405..4b154b7 100644 (file)
@@ -189,8 +189,6 @@ static int single_read (char *name, FILE *fh)
        post_compress = 0;
        pre_decompress = 0;
        post_decompress = 0;
-       overhead_rx = 0;
-       overhead_tx = 0;
 
        while (fgets (buffer, sizeof (buffer), fh) != NULL)
        {
index 216feda..d669aa9 100644 (file)
@@ -359,7 +359,7 @@ static void *ping_thread (void *arg) /* {{{ */
      * `ts_wait'. */
     time_calc (&ts_wait, &ts_int, &tv_begin, &tv_end);
 
-    status = pthread_cond_timedwait (&ping_cond, &ping_lock, &ts_wait);
+    pthread_cond_timedwait (&ping_cond, &ping_lock, &ts_wait);
     if (ping_thread_loop <= 0)
       break;
   } /* while (ping_thread_loop > 0) */
index ec337bf..99b4df6 100644 (file)
@@ -462,6 +462,12 @@ static int powerdns_get_data_stream (list_item_t *item, /* {{{ */
   timeout.tv_sec=5;
   timeout.tv_usec=0;
   status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof (timeout));
+  if (status != 0)
+  {
+    FUNC_ERROR ("setsockopt");
+    close (sd);
+    return (-1);
+  }
 
   status = connect (sd, (struct sockaddr *) &item->sockaddr,
       sizeof (item->sockaddr));
@@ -509,7 +515,6 @@ static int powerdns_get_data_stream (list_item_t *item, /* {{{ */
     buffer[buffer_size] = 0;
   } /* while (42) */
   close (sd);
-  sd = -1;
 
   if (status < 0)
   {
index 51afea1..5c81ca1 100644 (file)
@@ -402,7 +402,6 @@ static int csnmp_config_add_data (oconfig_item_t *ci)
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Type", option->key) == 0)
       status = cf_util_get_string(option, &dd->type);
@@ -1519,7 +1518,7 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
     for (vb = res->variables, i = 0; (vb != NULL); vb = vb->next_variable, i++)
     {
       /* Calculate value index from todo list */
-      while (!oid_list_todo[i] && (i < oid_list_len))
+      while ((i < oid_list_len) && !oid_list_todo[i])
         i++;
 
       /* An instance is configured and the res variable we process is the
index 480715f..8445bc5 100644 (file)
@@ -224,7 +224,6 @@ static int ctail_config_add_file (oconfig_item_t *ci)
   cdtime_t interval = 0;
   char *plugin_instance = NULL;
   int num_matches = 0;
-  int status;
   int i;
 
   if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
@@ -241,10 +240,10 @@ static int ctail_config_add_file (oconfig_item_t *ci)
     return (-1);
   }
 
-  status = 0;
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
+    int status;
 
     if (strcasecmp ("Instance", option->key) == 0)
       status = cf_util_get_string (option, &plugin_instance);
index 41ed980..a1ee249 100644 (file)
@@ -312,7 +312,6 @@ static int tcsv_config_add_metric(oconfig_item_t *ci){
 
     for (i = 0; i < ci->children_num; ++i){
         oconfig_item_t *option = ci->children + i;
-        status = 0;
 
         if (strcasecmp("Type", option->key) == 0)
             status = cf_util_get_string(option, &md->type);
index bf519bb..5dd75bc 100644 (file)
--- a/src/ted.c
+++ b/src/ted.c
@@ -104,7 +104,6 @@ static int ted_read_value(double *ret_power, double *ret_voltage)
 
     /* Loop until we find the end of the package */
     end_flag = 0;
-    escape_flag = 0;
     package_buffer_pos = 0;
     while (end_flag == 0)
     {
index 8815a00..882f955 100644 (file)
@@ -251,7 +251,6 @@ static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci)
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Instance", option->key) == 0)
       status = ut_config_type_instance (&th, option);
@@ -339,7 +338,6 @@ static int ut_config_plugin (const threshold_t *th_orig, oconfig_item_t *ci)
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Type", option->key) == 0)
       status = ut_config_type (&th, option);
@@ -386,7 +384,6 @@ static int ut_config_host (const threshold_t *th_orig, oconfig_item_t *ci)
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Type", option->key) == 0)
       status = ut_config_type (&th, option);
@@ -906,7 +903,6 @@ int ut_config (oconfig_item_t *ci)
   for (i = 0; i < ci->children_num; i++)
   {
     oconfig_item_t *option = ci->children + i;
-    status = 0;
 
     if (strcasecmp ("Type", option->key) == 0)
       status = ut_config_type (&th, option);