@@ -33,7 +33,7 @@ static int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpuma
m = thread_num % num_cpus;
/* there are num_cpus bits set, we want position of m'th one */
- for (i = 0, cpu = 0; i < max_cpus; i++) {
+ for (i = 0, cpu = 0; i < cpumask->size; i++) {
if (numa_bitmask_isbitset(cpumask, i)) {
if (cpu == m)
return i;
@@ -97,7 +97,7 @@ static void use_current_cpuset(int max_cpus, struct bitmask *cpumask)
* Clear bits that are not set in both the cpuset from the
* environment, and in the user specified affinity.
*/
- for (i = 0; i < max_cpus; i++) {
+ for (i = 0; i < cpumask->size; i++) {
if ((!numa_bitmask_isbitset(cpumask, i)) ||
(!numa_bitmask_isbitset(curmask, i)))
numa_bitmask_clearbit(cpumask, i);
The bitmask structure knows its size use, thus use it as upper limit in the loop. Signed-off-by: Daniel Wagner <dwagner@suse.de> --- src/lib/rt-numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)