aboutsummaryrefslogtreecommitdiff
path: root/lib/test_fortify/write_overflow-strlcpy-src.c
diff options
context:
space:
mode:
authorChristophe de Dinechin <[email protected]>2022-04-14 17:08:54 +0200
committerakpm <[email protected]>2022-05-19 14:08:55 -0700
commit37462a920392cb86541650a6f4121155f11f1199 (patch)
tree39bac8593084280cbc10d6cfe61a987aede241fb /lib/test_fortify/write_overflow-strlcpy-src.c
parent3f913fc5f9745613088d3c569778c9813ab9c129 (diff)
nodemask.h: fix compilation error with GCC12
With gcc version 12.0.1 20220401 (Red Hat 12.0.1-0), building with defconfig results in the following compilation error: | CC mm/swapfile.o | mm/swapfile.c: In function `setup_swap_info': | mm/swapfile.c:2291:47: error: array subscript -1 is below array bounds | of `struct plist_node[]' [-Werror=array-bounds] | 2291 | p->avail_lists[i].prio = 1; | | ~~~~~~~~~~~~~~^~~ | In file included from mm/swapfile.c:16: | ./include/linux/swap.h:292:27: note: while referencing `avail_lists' | 292 | struct plist_node avail_lists[]; /* | | ^~~~~~~~~~~ This is due to the compiler detecting that the mask in node_states[__state] could theoretically be zero, which would lead to first_node() returning -1 through find_first_bit. I believe that the warning/error is legitimate. I first tried adding a test to check that the node mask is not emtpy, since a similar test exists in the case where MAX_NUMNODES == 1. However, adding the if statement causes other warnings to appear in for_each_cpu_node_but, because it introduces a dangling else ambiguity. And unfortunately, GCC is not smart enough to detect that the added test makes the case where (node) == -1 impossible, so it still complains with the same message. This is why I settled on replacing that with a harmless, but relatively useless (node) >= 0 test. Based on the warning for the dangling else, I also decided to fix the case where MAX_NUMNODES == 1 by moving the condition inside the for loop. It will still only be tested once. This ensures that the meaning of an else following for_each_node_mask or derivatives would not silently have a different meaning depending on the configuration. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Christophe de Dinechin <[email protected]> Signed-off-by: Christophe de Dinechin <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Ben Segall <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Dietmar Eggemann <[email protected]> Cc: Vincent Guittot <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Daniel Bristot de Oliveira <[email protected]> Cc: Jason Wang <[email protected]> Cc: Zhen Lei <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'lib/test_fortify/write_overflow-strlcpy-src.c')
0 files changed, 0 insertions, 0 deletions