]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
processes: format array size def in read fork_rate & ctxt
authortiozhang <zyhtheonly@yeah.net>
Sat, 6 May 2023 04:59:34 +0000 (12:59 +0800)
committerMatthias Runge <mrunge@matthias-runge.de>
Mon, 22 May 2023 16:49:12 +0000 (18:49 +0200)
Signed-off-by: tiozhang <zyhtheonly@yeah.net>
Signed-off-by: luffysong <zsfz_one@163.com>
src/processes.c

index 0e38a420f53c2471bd992aa0fc64024cb87b4227..51b7bfd9143e8a5f88e016509d73bbb1dda8683b 100644 (file)
@@ -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;