X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_tail_match.c;h=99d5decbec4dd069150c0cd8a576fc78f6e6f6ad;hb=e81567f2a645fd15f4384ca9569119bc66c1412a;hp=1e5da95e181550b3b54e21df6773be0805e5482d;hpb=43aca8ed8b22a7a5a14f8c740948d6ce06efbc95;p=collectd.git diff --git a/src/daemon/utils_tail_match.c b/src/daemon/utils_tail_match.c index 1e5da95e..99d5decb 100644 --- a/src/daemon/utils_tail_match.c +++ b/src/daemon/utils_tail_match.c @@ -30,6 +30,7 @@ */ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "utils_match.h" @@ -87,7 +88,6 @@ static int simple_submit_match (cu_match_t *match, void *user_data) vl.values = values; vl.values_len = 1; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, data->plugin, sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, data->plugin_instance, sizeof (vl.plugin_instance)); @@ -98,12 +98,7 @@ static int simple_submit_match (cu_match_t *match, void *user_data) vl.interval = data->interval; plugin_dispatch_values (&vl); - if (match_value->ds_type & UTILS_MATCH_DS_TYPE_GAUGE) - { - match_value->value.gauge = NAN; - match_value->values_num = 0; - } - + match_value_reset (match_value); return (0); } /* int simple_submit_match */ @@ -111,9 +106,8 @@ static int tail_callback (void *data, char *buf, int __attribute__((unused)) buflen) { cu_tail_match_t *obj = (cu_tail_match_t *) data; - size_t i; - for (i = 0; i < obj->matches_num; i++) + for (size_t i = 0; i < obj->matches_num; i++) match_apply (obj->matches[i].match, buf); return (0); @@ -142,8 +136,6 @@ cu_tail_match_t *tail_match_create (const char *filename) void tail_match_destroy (cu_tail_match_t *obj) { - size_t i; - if (obj == NULL) return; @@ -153,7 +145,7 @@ void tail_match_destroy (cu_tail_match_t *obj) obj->tail = NULL; } - for (i = 0; i < obj->matches_num; i++) + for (size_t i = 0; i < obj->matches_num; i++) { cu_tail_match_match_t *match = obj->matches + i; if (match->match != NULL) @@ -179,7 +171,7 @@ int tail_match_add_match (cu_tail_match_t *obj, cu_match_t *match, { cu_tail_match_match_t *temp; - temp = (cu_tail_match_match_t *) realloc (obj->matches, + temp = realloc (obj->matches, sizeof (cu_tail_match_match_t) * (obj->matches_num + 1)); if (temp == NULL) return (-1); @@ -246,7 +238,6 @@ int tail_match_read (cu_tail_match_t *obj) { char buffer[4096]; int status; - size_t i; status = cu_tail_read (obj->tail, buffer, sizeof (buffer), tail_callback, (void *) obj); @@ -256,7 +247,7 @@ int tail_match_read (cu_tail_match_t *obj) return (status); } - for (i = 0; i < obj->matches_num; i++) + for (size_t i = 0; i < obj->matches_num; i++) { cu_tail_match_match_t *lt_match = obj->matches + i;