[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171113082358.w34pdipoeels47xc@dhcp22.suse.cz>
Date: Mon, 13 Nov 2017 09:23:58 +0100
From: Michal Hocko <mhocko@...nel.org>
To: Stephen Rothwell <sfr@...b.auug.org.au>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Linux-Next Mailing List <linux-next@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: linux-next: build warning after merge of the akpm-current tree
On Mon 13-11-17 09:09:55, Michal Hocko wrote:
> On Mon 13-11-17 16:42:06, Stephen Rothwell wrote:
> > Hi Andrew,
> >
> > 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?
Strange I played with the following minimal test case and it warns only
for the explicit &m use while n is clearly never null as well. This all
smells like -Waddress is just confused (at least with my gcc 7.2.0-12
#include <stdio.h>
#define MAX_NUMNODES 10
struct mask {
void *bits;
};
#define nodemask_pr_args(maskp) (maskp) ? MAX_NUMNODES : 0, (maskp) ? (maskp)->bits : NULL
int foo(void)
{
struct mask m;
struct mask *n = &m;
printf("%*p\n", nodemask_pr_args(&m));
printf("%*p\n", nodemask_pr_args(n));
return 0;
}
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists