From: Florian Forster Date: Tue, 9 Jan 2024 12:06:31 +0000 (+0100) Subject: cpu plugin: Use the `cpu_num` field in `usage_t`. X-Git-Tag: 6.0.0-rc0~5^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=080d1f98d53d1222af465c71b0fbe83035c859f4;p=thirdparty%2Fcollectd.git cpu plugin: Use the `cpu_num` field in `usage_t`. --- diff --git a/src/cpu.c b/src/cpu.c index a044f25ad..23ef10ca5 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -215,10 +215,6 @@ static int pnumcpu; (sum) += (val); \ } while (0) -/* Highest CPU number in the current iteration. Used by the dispatch logic to - * determine how many CPUs there were. Reset to 0 by cpu_reset(). */ -static size_t global_cpu_num; - static bool report_by_cpu = true; static bool report_by_state = true; static bool report_usage = true; @@ -659,8 +655,8 @@ static void commit_usage(usage_t *u) { return; } - for (size_t cpu_num = 0; cpu_num < global_cpu_num; cpu_num++) { - commit_cpu_usage(u, cpu_num); + for (size_t cpu = 0; cpu < u->cpu_num; cpu++) { + commit_cpu_usage(u, cpu); } } @@ -714,8 +710,8 @@ static void commit_utilization(usage_t *u) { return; } - for (size_t cpu_num = 0; cpu_num < global_cpu_num; cpu_num++) { - commit_cpu_utilization(u, cpu_num); + for (size_t cpu = 0; cpu < u->cpu_num; cpu++) { + commit_cpu_utilization(u, cpu); } } @@ -723,7 +719,7 @@ static void commit_utilization(usage_t *u) { static void cpu_commit(usage_t *u) /* {{{ */ { if (report_num_cpu) { - cpu_commit_num_cpu((gauge_t)global_cpu_num); + cpu_commit_num_cpu((gauge_t)u->cpu_num); } if (report_usage) {