powerpc: Avoid comparison of unsigned long >= 0 in pfn_valid()
authorMathieu Malaterre <malat@debian.org>
Wed, 7 Mar 2018 20:34:35 +0000 (21:34 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 13 Mar 2018 04:50:41 +0000 (15:50 +1100)
commit603b892200e653dd7e86a0e4a315561534d97441
tree11be6d7b2f7a58b0d71a61ba31cecdbfa48580a7
parent4f1f40f7b2b4487f582ecafec64076e430c72b22
powerpc: Avoid comparison of unsigned long >= 0 in pfn_valid()

Rewrite comparison since all values compared are of type `unsigned long`.

Instead of using unsigned properties and rewriting the original code as:
(originally suggested by Segher Boessenkool <segher@kernel.crashing.org>)

  #define pfn_valid(pfn) \
               (((pfn) - ARCH_PFN_OFFSET) < (max_mapnr - ARCH_PFN_OFFSET))

Prefer a static inline function to make code as readable as possible.

Fix a warning (treated as error in W=1):
  arch/powerpc/include/asm/page.h:129:32: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
  #define pfn_valid(pfn)  ((pfn) >= ARCH_PFN_OFFSET && (pfn) < max_mapnr)
                                  ^

Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/page.h