X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fiptables.c;h=8fad588e85120c9bf78d86e0ccf29b3b3ec6092b;hb=06a86a60a7dabc685bdbd81ce3d36ea5f7e2c2d4;hp=8969cf74a60d88ed09774f2e9e6057586c39b02b;hpb=be126043c2be20399d7670fe194645292018bde0;p=collectd.git diff --git a/src/iptables.c b/src/iptables.c index 8969cf74..8fad588e 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -86,8 +86,8 @@ typedef struct { char name[64]; } ip_chain_t; -static ip_chain_t **chain_list = NULL; -static int chain_num = 0; +static ip_chain_t **chain_list; +static int chain_num; static int iptables_config(const char *key, const char *value) { /* int ip_value; */ @@ -101,7 +101,7 @@ static int iptables_config(const char *key, const char *value) { return 1; ip_chain_t temp = {0}; - ip_chain_t * final, **list; + ip_chain_t *final, **list; char *table; int table_len; char *chain; @@ -113,8 +113,7 @@ static int iptables_config(const char *key, const char *value) { value_copy = strdup(value); if (value_copy == NULL) { - char errbuf[1024]; - ERROR("strdup failed: %s", sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("strdup failed: %s", STRERRNO); return 1; } @@ -182,17 +181,15 @@ static int iptables_config(const char *key, const char *value) { list = realloc(chain_list, (chain_num + 1) * sizeof(ip_chain_t *)); if (list == NULL) { - char errbuf[1024]; - ERROR("realloc failed: %s", sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("realloc failed: %s", STRERRNO); sfree(temp.rule.comment); return 1; } chain_list = list; - final = malloc(sizeof(* final)); + final = malloc(sizeof(*final)); if (final == NULL) { - char errbuf[1024]; - ERROR("malloc failed: %s", sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("malloc failed: %s", STRERRNO); sfree(temp.rule.comment); return 1; } @@ -227,7 +224,7 @@ static int submit6_match(const struct ip6t_entry_match *match, sstrncpy(vl.plugin, "ip6tables", sizeof(vl.plugin)); status = snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s", - chain->table, chain->chain); + chain->table, chain->chain); if ((status < 1) || ((unsigned int)status >= sizeof(vl.plugin_instance))) return 0; @@ -236,7 +233,7 @@ static int submit6_match(const struct ip6t_entry_match *match, } else { if (chain->rule_type == RTYPE_NUM) snprintf(vl.type_instance, sizeof(vl.type_instance), "%i", - chain->rule.num); + chain->rule.num); else sstrncpy(vl.type_instance, (char *)match->data, sizeof(vl.type_instance)); } @@ -275,7 +272,7 @@ static int submit_match(const struct ipt_entry_match *match, sstrncpy(vl.plugin, "iptables", sizeof(vl.plugin)); status = snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s", - chain->table, chain->chain); + chain->table, chain->chain); if ((status < 1) || ((unsigned int)status >= sizeof(vl.plugin_instance))) return 0; @@ -284,7 +281,7 @@ static int submit_match(const struct ipt_entry_match *match, } else { if (chain->rule_type == RTYPE_NUM) snprintf(vl.type_instance, sizeof(vl.type_instance), "%i", - chain->rule.num); + chain->rule.num); else sstrncpy(vl.type_instance, (char *)match->data, sizeof(vl.type_instance)); }