From c68a61a08267319ebfeddd372ab16124c592b288 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 20 Nov 2015 11:01:38 +0100 Subject: [PATCH] apache plugin: DRY: use macro to determine number of fields. --- src/apache.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/apache.c b/src/apache.c index 864dfcf8..13c8db66 100644 --- a/src/apache.c +++ b/src/apache.c @@ -630,18 +630,14 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */ while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL) { ptr = NULL; - fields_num = strsplit (line, fields, 4); + fields_num = strsplit (line, fields, STATIC_ARRAY_SIZE (fields)); if (fields_num == 3) { - if ((strcmp (fields[0], "Total") == 0) - && (strcmp (fields[1], "Accesses:") == 0)) - submit_derive ("apache_requests", "", - atoll (fields[2]), st); - else if ((strcmp (fields[0], "Total") == 0) - && (strcmp (fields[1], "kBytes:") == 0)) - submit_derive ("apache_bytes", "", - 1024LL * atoll (fields[2]), st); + if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "Accesses:") == 0)) + submit_derive ("apache_requests", "", atoll (fields[2]), st); + else if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "kBytes:") == 0)) + submit_derive ("apache_bytes", "", 1024LL * atoll (fields[2]), st); } else if (fields_num == 2) { -- 2.30.2