From: Florian Forster Date: Mon, 4 Dec 2017 07:23:26 +0000 (+0100) Subject: Merge branch 'collectd-5.7' into collectd-5.8 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ba1015262cdc912f9d01ab5a76037e65033c54c5;p=collectd.git Merge branch 'collectd-5.7' into collectd-5.8 --- ba1015262cdc912f9d01ab5a76037e65033c54c5 diff --cc src/powerdns.c index 0b08b298,da72ec8d..c7158070 --- a/src/powerdns.c +++ b/src/powerdns.c @@@ -478,14 -478,11 +478,11 @@@ static int powerdns_get_data_dgram(list buffer[buffer_size - 1] = 0; *ret_buffer = buffer; - *ret_buffer_size = buffer_size; - - return (0); + return 0; } /* }}} int powerdns_get_data_dgram */ - static int powerdns_get_data_stream(list_item_t *item, /* {{{ */ - char **ret_buffer, - size_t *ret_buffer_size) { + static int powerdns_get_data_stream(list_item_t *item, char **ret_buffer) { + /* {{{ */ int sd; int status; @@@ -550,26 -548,23 +548,23 @@@ } /* while (42) */ close(sd); - if (status < 0) { + if (status != 0) { sfree(buffer); - } else { - assert(status == 0); - *ret_buffer = buffer; - *ret_buffer_size = buffer_size; + return status; } - return status; + *ret_buffer = buffer; + return 0; } /* }}} int powerdns_get_data_stream */ - static int powerdns_get_data(list_item_t *item, char **ret_buffer, - size_t *ret_buffer_size) { + static int powerdns_get_data(list_item_t *item, char **ret_buffer) { if (item->socktype == SOCK_DGRAM) - return powerdns_get_data_dgram(item, ret_buffer, ret_buffer_size); - return (powerdns_get_data_dgram(item, ret_buffer)); ++ return powerdns_get_data_dgram(item, ret_buffer); else if (item->socktype == SOCK_STREAM) - return powerdns_get_data_stream(item, ret_buffer, ret_buffer_size); - return (powerdns_get_data_stream(item, ret_buffer)); ++ return powerdns_get_data_stream(item, ret_buffer); else { ERROR("powerdns plugin: Unknown socket type: %i", (int)item->socktype); - return (-1); + return -1; } } /* int powerdns_get_data */ @@@ -592,13 -574,21 +574,21 @@@ static int powerdns_read_server(list_it item->command = strdup(SERVER_COMMAND); if (item->command == NULL) { ERROR("powerdns plugin: strdup failed."); - return (-1); + return -1; } - status = powerdns_get_data(item, &buffer, &buffer_size); - if (status != 0) - return -1; + char *buffer = NULL; + int status = powerdns_get_data(item, &buffer); + if (status != 0) { + ERROR("powerdns plugin: powerdns_get_data failed."); - return (status); ++ return status; + } + if (buffer == NULL) { + return EINVAL; + } + const char *const *fields = default_server_fields; + int fields_num = default_server_fields_num; if (item->fields_num != 0) { fields = (const char *const *)item->fields; fields_num = item->fields_num; @@@ -714,10 -701,10 +701,10 @@@ static int powerdns_read_recursor(list_ } assert(item->command != NULL); - status = powerdns_get_data(item, &buffer, &buffer_size); + status = powerdns_get_data(item, &buffer); if (status != 0) { ERROR("powerdns plugin: powerdns_get_data failed."); - return (-1); + return -1; } keys_list = strdup(item->command); diff --cc src/rrdtool.c index 558b8005,4fcbad40..cd275dad --- a/src/rrdtool.c +++ b/src/rrdtool.c @@@ -620,12 -624,11 +620,11 @@@ static int rrd_cache_insert(const char if (cache == NULL) { pthread_mutex_unlock(&cache_lock); WARNING("rrdtool plugin: cache == NULL."); - return (-1); + return -1; } - c_avl_get(cache, filename, (void *)&rc); - - if (rc == NULL) { + int status = c_avl_get(cache, filename, (void *)&rc); + if ((status != 0) || (rc == NULL)) { rc = malloc(sizeof(*rc)); if (rc == NULL) { pthread_mutex_unlock(&cache_lock); diff --cc src/table.c index 7cae3f79,eb18660c..d7988207 --- a/src/table.c +++ b/src/table.c @@@ -103,11 -105,16 +107,17 @@@ static void tbl_setup(tbl_t *tbl, char } /* tbl_setup */ static void tbl_clear(tbl_t *tbl) { + if (tbl == NULL) { + return; + } + sfree(tbl->file); sfree(tbl->sep); + sfree(tbl->plugin_name); sfree(tbl->instance); + /* (tbl->results == NULL) -> (tbl->results_num == 0) */ + assert((tbl->results != NULL) || (tbl->results_num == 0)); for (size_t i = 0; i < tbl->results_num; ++i) tbl_result_clear(tbl->results + i); sfree(tbl->results);