From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752422AbdKQJ4m (ORCPT ); Fri, 17 Nov 2017 04:56:42 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:41464 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752033AbdKQJ4g (ORCPT ); Fri, 17 Nov 2017 04:56:36 -0500 X-Google-Smtp-Source: AGs4zMboDzmP0V+AVthjsW/uzgmCVn/IDhngEd8wIUQ7jpBQqnCAU2OxDrrr3DlL3jfodZKjWRqu3aYqytq452KRq98= MIME-Version: 1.0 In-Reply-To: <20171117145320.714972ca@canb.auug.org.au> References: <20171113164206.187a790d@canb.auug.org.au> <20171113080955.zcdzx2p5kzoa4d7s@dhcp22.suse.cz> <20171117094439.5287c715@canb.auug.org.au> <20171117145320.714972ca@canb.auug.org.au> From: Arnd Bergmann Date: Fri, 17 Nov 2017 10:56:34 +0100 X-Google-Sender-Auth: Rg1hUiIQg3wykmxrsvzBBvmIM_k Message-ID: Subject: Re: linux-next: build warning after merge of the akpm-current tree To: Stephen Rothwell Cc: Michal Hocko , Andrew Morton , Linux-Next Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 17, 2017 at 4:53 AM, Stephen Rothwell wrote: > Hi all, > > On Fri, 17 Nov 2017 09:44:39 +1100 Stephen Rothwell wrote: >> >> On Mon, 13 Nov 2017 12:43:08 +0100 Arnd Bergmann wrote: >> > >> > On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko wrote: >> > > On Mon 13-11-17 16:42:06, Stephen Rothwell wrote: >> > >> >> > >> After merging the akpm-current tree, today's linux-next build (powerpc >> > >> ppc64_defconfig) produced this warning: >> > >> >> > >> In file included from include/linux/mmzone.h:17:0, >> > >> from include/linux/mempolicy.h:10, >> > >> from mm/mempolicy.c:70: >> > >> mm/mempolicy.c: In function 'mpol_to_str': >> > >> include/linux/nodemask.h:107:41: warning: the address of 'nodes' will always evaluate as 'true' [-Waddress] >> > >> #define nodemask_pr_args(maskp) (maskp) ? MAX_NUMNODES : 0, (maskp) ? (maskp)->bits : NULL >> > >> ^ >> > >> mm/mempolicy.c:2817:11: note: in expansion of macro 'nodemask_pr_args' >> > >> nodemask_pr_args(&nodes)); >> > >> ^ >> > > >> > > Hmm, this warning is quite surprising to me. Sure in this particular >> > > case maskp will always be non-NULL so we always expand to >> > > MAX_NUMNODES, maskp->bits >> > > which is what we want. But we have other users which may be NULL. Does >> > > anybody understan why this warns at all? >> > >> > As I understand it, the warning tries to address a common typo of accidentally >> > testing the pointer to a stack object for being non-NULL, rather than the object >> > pointed to for being non-zero. >> > >> > Adding an extra '!= NULL' comparison gets rid of the warning for me: >> > >> > #define nodemask_pr_args(maskp) \ >> > ((maskp) != NULL) ? MAX_NUMNODES : 0, \ >> > ((maskp) != NULL) ?(maskp)->bits : NULL >> > >> > Arnd >> >> This warning now exists in Linus' tree :-( > > Looking closer, it seems that the above workaround doesn't work for my > compiler (gcc v5.2.0): Right, I see now that all versions from gcc-4.6 to gcc-6 are affected by this, while 4.5 and earlier as well as 7 and 8 are not. I'll try to come up with an alternative workaround, it will probably be even uglier. Arnd