mm/sparse: fix a bad comparison
Subsystems (2)
PATCH 1/1 mm/sparse: fix a bad comparison
next_present_section_nr() could only return an unsigned number -1, so just check it specifically where compilers will convert -1 to unsigned if needed.
mm/sparse.c: In function 'sparse_init_nid':mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
((section_nr >= 0) && \
^~mm/sparse.c:478:2: note: in expansion of macro 'for_each_present_section_nr'
for_each_present_section_nr(pnum_begin, pnum) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
((section_nr >= 0) && \
^~mm/sparse.c:497:2: note: in expansion of macro 'for_each_present_section_nr'
for_each_present_section_nr(pnum_begin, pnum) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~mm/sparse.c: In function 'sparse_init':mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
((section_nr >= 0) && \
^~mm/sparse.c:520:2: note: in expansion of macro 'for_each_present_section_nr'
for_each_present_section_nr(pnum_begin + 1, pnum_end) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~
--- mm/sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse.c +1 -1
@@ -197,7 +197,7 @@ static inline int next_present_section_nr(int section_nr) }#define for_each_present_section_nr (start, section_nr) \ for (section_nr = next_present_section_nr(start-1); \ - ((section_nr >= 0) && \ + ((section_nr != -1) && \ (section_nr <= __highest_present_section_nr)); \ section_nr = next_present_section_nr(section_nr))
Signature · 1 line
2.17.2 (Apple Git-113)