Skip to content

Commit cacf2a5

Browse files
guidosarduccianakryiko
authored andcommitted
selftests/bpf: Fix error compiling test_lru_map.c
Although the post-increment in macro 'CPU_SET(next++, &cpuset)' seems safe, the sequencing can raise compile errors, so move the increment outside the macro. This avoids an error seen using gcc 12.3.0 for mips64el/musl-libc: In file included from test_lru_map.c:11: test_lru_map.c: In function 'sched_next_online': test_lru_map.c:129:29: error: operation on 'next' may be undefined [-Werror=sequence-point] 129 | CPU_SET(next++, &cpuset); | ^ cc1: all warnings being treated as errors Fixes: 3fbfadc ("bpf: Fix test_lru_sanity5() in test_lru_map.c") Signed-off-by: Tony Ambardar <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/22993dfb11ccf27925a626b32672fd3324cb76c4.1722244708.git.tony.ambardar@gmail.com
1 parent 03bfcda commit cacf2a5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/testing/selftests/bpf/test_lru_map.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ static int sched_next_online(int pid, int *next_to_try)
126126

127127
while (next < nr_cpus) {
128128
CPU_ZERO(&cpuset);
129-
CPU_SET(next++, &cpuset);
129+
CPU_SET(next, &cpuset);
130+
next++;
130131
if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) {
131132
ret = 0;
132133
break;

0 commit comments

Comments
 (0)