X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fmatch_regex.c;h=99f0709bdfa8c494213e5a928c481c23f126f403;hp=ed1e3295902f9297e90f917712b74cbebb1b28b1;hb=54619dc85fd308b21ed09a0271e5c7383c7921b9;hpb=b9b5e5d573d0011c4f3276e9b84b73ba4dd2e870 diff --git a/src/match_regex.c b/src/match_regex.c index ed1e3295..99f0709b 100644 --- a/src/match_regex.c +++ b/src/match_regex.c @@ -33,9 +33,9 @@ #include "collectd.h" -#include "common.h" #include "filter_chain.h" -#include "meta_data.h" +#include "utils/common/common.h" +#include "utils/metadata/meta_data.h" #include "utils_llist.h" #include @@ -151,7 +151,7 @@ static int mr_add_regex(mr_regex_t **re_head, const char *re_str, /* {{{ */ if (status != 0) { char errmsg[1024]; regerror(status, &re->re, errmsg, sizeof(errmsg)); - errmsg[sizeof(errmsg) - 1] = 0; + errmsg[sizeof(errmsg) - 1] = '\0'; log_err("Compiling regex `%s' for `%s' failed: %s.", re->re_str, option, errmsg); sfree(re->re_str); @@ -336,21 +336,22 @@ static int mr_match(const data_set_t __attribute__((unused)) * ds, /* {{{ */ if (mr_match_regexen(m->type_instance, vl->type_instance) == FC_MATCH_NO_MATCH) return nomatch_value; - if (vl->meta != NULL) { - for (llentry_t *e = llist_head(m->meta); e != NULL; e = e->next) { - mr_regex_t *meta_re = (mr_regex_t *)e->value; - char *value; - int status = meta_data_get_string(vl->meta, e->key, &value); - if (status == (-ENOENT)) /* key is not present */ - return nomatch_value; - if (status != 0) /* some other problem */ - continue; /* error will have already been printed. */ - if (mr_match_regexen(meta_re, value) == FC_MATCH_NO_MATCH) { - sfree(value); - return nomatch_value; - } + for (llentry_t *e = llist_head(m->meta); e != NULL; e = e->next) { + mr_regex_t *meta_re = (mr_regex_t *)e->value; + char *value; + int status; + if (vl->meta == NULL) + return nomatch_value; + status = meta_data_get_string(vl->meta, e->key, &value); + if (status == (-ENOENT)) /* key is not present */ + return nomatch_value; + if (status != 0) /* some other problem */ + continue; /* error will have already been printed. */ + if (mr_match_regexen(meta_re, value) == FC_MATCH_NO_MATCH) { sfree(value); + return nomatch_value; } + sfree(value); } return match_value;