mm: fix nodemask printing
authorArnd Bergmann <[email protected]>
Fri, 17 Nov 2017 23:26:12 +0000 (15:26 -0800)
committerLinus Torvalds <[email protected]>
Sat, 18 Nov 2017 00:10:00 +0000 (16:10 -0800)
The cleanup caused build warnings for constant mask pointers:

  mm/mempolicy.c: In function `mpol_to_str':
  ./include/linux/nodemask.h:108:11: warning: the comparison will always evaluate as `true' for the address of `nodes' will never be NULL [-Waddress]

An earlier workaround I suggested was incorporated in the version that
got merged, but that only solved the problem for gcc-7 and higher, while
gcc-4.6 through gcc-6.x still warn.

This changes the printing again to use inline functions that make it
clear to the compiler that the line that does the NULL check has no idea
whether the argument is a constant NULL.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 0205f75571e3 ("mm: simplify nodemask printing")
Signed-off-by: Arnd Bergmann <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: Zhangshaokun <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/nodemask.h

index 15cab3967d6dfe435be2bbbe63c83cf06ee7042a..1fbde8a880d9a08b43cf57373f134b306c136dd3 100644 (file)
@@ -104,9 +104,16 @@ extern nodemask_t _unused_nodemask_arg_;
  *
  * Can be used to provide arguments for '%*pb[l]' when printing a nodemask.
  */
-#define nodemask_pr_args(maskp)                                \
-       ((maskp) != NULL) ? MAX_NUMNODES : 0,           \
-       ((maskp) != NULL) ? (maskp)->bits : NULL
+#define nodemask_pr_args(maskp)        __nodemask_pr_numnodes(maskp), \
+                               __nodemask_pr_bits(maskp)
+static inline unsigned int __nodemask_pr_numnodes(const nodemask_t *m)
+{
+       return m ? MAX_NUMNODES : 0;
+}
+static inline const unsigned long *__nodemask_pr_bits(const nodemask_t *m)
+{
+       return m ? m->bits : NULL;
+}
 
 /*
  * The inline keyword gives the compiler room to decide to inline, or