X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fpowerdns.c;h=eb541800363b2f67a47b6f11812a752bf8b1af3b;hb=d8429bfff10deb14bb48c248e3589a2916501ffd;hp=958a3410075788378ac0015d17974a6bebd255d7;hpb=4103105fb43cd72294f165b2541540b3a8a99532;p=collectd.git diff --git a/src/powerdns.c b/src/powerdns.c index 958a3410..eb541800 100644 --- a/src/powerdns.c +++ b/src/powerdns.c @@ -28,7 +28,6 @@ #include "common.h" #include "plugin.h" -#include "configfile.h" #include "utils_llist.h" #include @@ -301,10 +300,10 @@ static char *local_sockpath = NULL; /* */ static void submit (const char *plugin_instance, /* {{{ */ - const char *pdns_type, const char *value) + const char *pdns_type, const char *value_str) { value_list_t vl = VALUE_LIST_INIT; - value_t values[1]; + value_t value; const char *type = NULL; const char *type_instance = NULL; @@ -319,7 +318,7 @@ static void submit (const char *plugin_instance, /* {{{ */ if (i >= lookup_table_length) { INFO ("powerdns plugin: submit: Not found in lookup table: %s = %s;", - pdns_type, value); + pdns_type, value_str); return; } @@ -346,14 +345,14 @@ static void submit (const char *plugin_instance, /* {{{ */ return; } - if (0 != parse_value (value, &values[0], ds->ds[0].type)) + if (0 != parse_value (value_str, &value, ds->ds[0].type)) { ERROR ("powerdns plugin: Cannot convert `%s' " - "to a number.", value); + "to a number.", value_str); return; } - vl.values = values; + vl.values = &value; vl.values_len = 1; sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "powerdns", sizeof (vl.plugin)); @@ -631,8 +630,6 @@ static int powerdns_read_server (list_item_t *item) /* {{{ */ saveptr = NULL; while ((key = strtok_r (dummy, ",", &saveptr)) != NULL) { - int i; - dummy = NULL; value = strchr (key, '='); @@ -646,6 +643,7 @@ static int powerdns_read_server (list_item_t *item) /* {{{ */ continue; /* Check if this item was requested. */ + int i; for (i = 0; i < fields_num; i++) if (strcasecmp (key, fields[i]) == 0) break; @@ -781,7 +779,6 @@ static int powerdns_read_recursor (list_item_t *item) /* {{{ */ static int powerdns_config_add_collect (list_item_t *li, /* {{{ */ oconfig_item_t *ci) { - int i; char **temp; if (ci->values_num < 1) @@ -791,7 +788,7 @@ static int powerdns_config_add_collect (list_item_t *li, /* {{{ */ return (-1); } - for (i = 0; i < ci->values_num; i++) + for (int i = 0; i < ci->values_num; i++) if (ci->values[i].type != OCONFIG_TYPE_STRING) { WARNING ("powerdns plugin: Only string arguments are allowed to " @@ -808,7 +805,7 @@ static int powerdns_config_add_collect (list_item_t *li, /* {{{ */ } li->fields = temp; - for (i = 0; i < ci->values_num; i++) + for (int i = 0; i < ci->values_num; i++) { li->fields[li->fields_num] = strdup (ci->values[i].value.string); if (li->fields[li->fields_num] == NULL) @@ -831,7 +828,6 @@ static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */ list_item_t *item; int status; - int i; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { @@ -880,7 +876,7 @@ static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */ } status = 0; - for (i = 0; i < ci->children_num; i++) + for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; @@ -940,8 +936,6 @@ static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */ static int powerdns_config (oconfig_item_t *ci) /* {{{ */ { - int i; - DEBUG ("powerdns plugin: powerdns_config (ci = %p);", (void *) ci); if (list == NULL) @@ -955,7 +949,7 @@ static int powerdns_config (oconfig_item_t *ci) /* {{{ */ } } - for (i = 0; i < ci->children_num; i++) + for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; @@ -988,9 +982,7 @@ static int powerdns_config (oconfig_item_t *ci) /* {{{ */ static int powerdns_read (void) { - llentry_t *e; - - for (e = llist_head (list); e != NULL; e = e->next) + for (llentry_t *e = llist_head (list); e != NULL; e = e->next) { list_item_t *item = e->value; item->func (item); @@ -1001,12 +993,10 @@ static int powerdns_read (void) static int powerdns_shutdown (void) { - llentry_t *e; - if (list == NULL) return (0); - for (e = llist_head (list); e != NULL; e = e->next) + for (llentry_t *e = llist_head (list); e != NULL; e = e->next) { list_item_t *item = (list_item_t *) e->value; e->value = NULL;