X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmatch_hashed.c;h=c4983c2ed056a0a455dc38131a3174876c1fb085;hb=d0408cb0dbef15d739a6b1cd047e9c94d7643329;hp=994022e66f0f8dcd4238440c9a61ab2d622b87e1;hpb=4103105fb43cd72294f165b2541540b3a8a99532;p=collectd.git diff --git a/src/match_hashed.c b/src/match_hashed.c index 994022e6..c4983c2e 100644 --- a/src/match_hashed.c +++ b/src/match_hashed.c @@ -99,7 +99,6 @@ static int mh_config_match (const oconfig_item_t *ci, /* {{{ */ static int mh_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ { mh_match_t *m; - int i; m = calloc (1, sizeof (*m)); if (m == NULL) @@ -108,7 +107,7 @@ static int mh_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ return (-ENOMEM); } - for (i = 0; i < ci->children_num; i++) + for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; @@ -150,8 +149,6 @@ static int mh_match (const data_set_t __attribute__((unused)) *ds, /* {{{ */ { mh_match_t *m; uint32_t hash_val; - const char *host_ptr; - size_t i; if ((user_data == NULL) || (*user_data == NULL)) return (-1); @@ -160,14 +157,14 @@ static int mh_match (const data_set_t __attribute__((unused)) *ds, /* {{{ */ hash_val = 0; - for (host_ptr = vl->host; *host_ptr != 0; host_ptr++) + for (const char *host_ptr = vl->host; *host_ptr != 0; host_ptr++) { /* 2184401929 is some appropriately sized prime number. */ hash_val = (hash_val * UINT32_C (2184401929)) + ((uint32_t) *host_ptr); } DEBUG ("hashed match: host = %s; hash_val = %"PRIu32";", vl->host, hash_val); - for (i = 0; i < m->matches_num; i++) + for (size_t i = 0; i < m->matches_num; i++) if ((hash_val % m->matches[i].total) == m->matches[i].match) return (FC_MATCH_MATCHES);