From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751106AbdKTIWn (ORCPT ); Mon, 20 Nov 2017 03:22:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:50431 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbdKTIWm (ORCPT ); Mon, 20 Nov 2017 03:22:42 -0500 Date: Mon, 20 Nov 2017 09:22:39 +0100 From: Michal Hocko To: Arnd Bergmann Cc: Andrew Morton , Stephen Rothwell , linux-next@vger.kernel.org, linux-kernel@vger.kernel.org, Zhangshaokun Subject: Re: [PATCH] mm: fix nodemask printing Message-ID: <20171120082239.irwzcrxkfu3qggbh@dhcp22.suse.cz> References: <20171117101545.119689-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171117101545.119689-1-arnd@arndb.de> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 17-11-17 11:15:45, Arnd Bergmann wrote: > 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. > > Fixes: 0205f75571e3 ("mm: simplify nodemask printing") > Signed-off-by: Arnd Bergmann Thanks for the fixup. It is sad how a questionable warning makes the code worse... Does it make sense to have the warning enabled? Gcc bug [1] suggests there is no great interest into fixing it. Anyway to the patch Acked-by: Michal Hocko [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82963 > --- > I've done only minimal build testing on this, but did check it with > all compiler versions this time. > --- > include/linux/nodemask.h | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h > index 15cab3967d6d..1fbde8a880d9 100644 > --- a/include/linux/nodemask.h > +++ b/include/linux/nodemask.h > @@ -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 > -- > 2.9.0 -- Michal Hocko SUSE Labs