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;
} /* 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 */
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;
}
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);
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);