[RFC PATCH bitmap-for-next 2/4] lib/cpumask: Fix cpumask_check() warning in cpumask_next_wrap*()

From: Valentin Schneider
Date: Thu Oct 06 2022 - 08:22:25 EST


Invoking cpumask_next*() with n==nr_cpu_ids-1 triggers a warning as there
are (obviously) no more valid CPU ids after that. This is however undesired
for the cpumask_next_wrap*() family which needs to wrap around reaching
this condition.

Don't invoke cpumask_next*() when n==nr_cpu_ids, go for the wrapping (if
any) instead.

NOTE: this only fixes the NR_CPUS>1 variants.

Signed-off-by: Valentin Schneider <vschneid@xxxxxxxxxx>
---
lib/cpumask.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/cpumask.c b/lib/cpumask.c
index 6e576485c84f..f8174fa3d752 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -12,11 +12,11 @@
unsigned int next; \
\
again: \
- next = (FETCH_NEXT); \
+ next = n == nr_cpu_ids - 1 ? nr_cpu_ids : (FETCH_NEXT); \
\
if (wrap && n < start && next >= start) { \
- next = nr_cpumask_bits; \
- } else if (next >= nr_cpumask_bits) { \
+ next = nr_cpu_ids; \
+ } else if (next >= nr_cpu_ids) { \
wrap = true; \
n = -1; \
goto again; \
--
2.31.1