From: tiozhang Date: Sat, 6 May 2023 04:59:34 +0000 (+0800) Subject: processes: format array size def in read fork_rate & ctxt X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9197134e7cd99206900f86f660be2135d028a2ab;p=thirdparty%2Fcollectd.git processes: format array size def in read fork_rate & ctxt Signed-off-by: tiozhang Signed-off-by: luffysong --- diff --git a/src/processes.c b/src/processes.c index 0e38a420f..51b7bfd91 100644 --- a/src/processes.c +++ b/src/processes.c @@ -1577,6 +1577,7 @@ static int read_fork_rate(const char *buffer) { int status; char *fields[2]; int fields_num; + const int expected = STATIC_ARRAY_SIZE(fields); processes = strstr(buffer, id); if (!processes) { @@ -1584,7 +1585,6 @@ static int read_fork_rate(const char *buffer) { return -1; } - const int expected = STATIC_ARRAY_SIZE(fields); fields_num = strsplit(processes, fields, expected); if (fields_num != expected) return -1; @@ -1605,6 +1605,7 @@ static int read_sys_ctxt_switch(const char *buffer) { int status; char *fields[2]; int fields_num; + const int expected = STATIC_ARRAY_SIZE(fields); ctxt = strstr(buffer, id); if (!ctxt) { @@ -1612,7 +1613,6 @@ static int read_sys_ctxt_switch(const char *buffer) { return -1; } - const int expected = STATIC_ARRAY_SIZE(fields); fields_num = strsplit(ctxt, fields, expected); if (fields_num != expected) return -1;