2022-04-27 10:52:35

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build warning after merge of the akpm-current tree

Hi all,

After merging the akpm-current tree, today's linux-next build (htmldocs)
produced this warning:

lib/maple_tree.c:5578: warning: Function parameter or member 'gfp' not described in 'mas_preallocate'

Introduced by commit

00d332902d28 ("Maple Tree: add new data structure")

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2022-04-27 14:43:57

by Liam R. Howlett

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

* Stephen Rothwell <[email protected]> [220427 02:41]:
> Hi all,
>
> After merging the akpm-current tree, today's linux-next build (htmldocs)
> produced this warning:
>
> lib/maple_tree.c:5578: warning: Function parameter or member 'gfp' not described in 'mas_preallocate'
>
> Introduced by commit
>
> 00d332902d28 ("Maple Tree: add new data structure")

Hi Stephen,

Here is a patch to add the missing parameter to the documentation.

Thanks,
Liam


Attachments:
0001-maple_tree-Fix-mas_store_prealloc-documentation.patch (892.00 B)
0001-maple_tree-Fix-mas_store_prealloc-documentation.patch

2017-11-17 18:18:20

by Arnd Bergmann

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Fri, Nov 17, 2017 at 4:53 AM, Stephen Rothwell <[email protected]> wrote:
> Hi all,
>
> On Fri, 17 Nov 2017 09:44:39 +1100 Stephen Rothwell <[email protected]> wrote:
>>
>> On Mon, 13 Nov 2017 12:43:08 +0100 Arnd Bergmann <[email protected]> wrote:
>> >
>> > On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko <[email protected]> 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

From 1584334275927656646@xxx Fri Nov 17 17:15:07 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-17 17:15:07

by Zhangshaokun

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

Hi,

On 2017/11/17 11:53, Stephen Rothwell wrote:
> Hi all,
>
> On Fri, 17 Nov 2017 09:44:39 +1100 Stephen Rothwell <[email protected]> wrote:
>>
>> On Mon, 13 Nov 2017 12:43:08 +0100 Arnd Bergmann <[email protected]> wrote:
>>>
>>> On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko <[email protected]> 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):
>

I also came across this issue using Linus' tree and my gcc is gcc version 5.4.0 20160609
(Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.5).

CC drivers/clk/renesas/rcar-gen3-cpg.o
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:108:11: warning: the comparison will always evaluate as �true� for the address of �nodes� will never be NULL [-Waddress]
((maskp) != NULL) ? MAX_NUMNODES : 0, \
^
mm/mempolicy.c:2817:11: note: in expansion of macro �nodemask_pr_args�
nodemask_pr_args(&nodes));
^
./include/linux/nodemask.h:109:11: warning: the comparison will always evaluate as �true� for the address of �nodes� will never be NULL [-Waddress]
((maskp) != NULL) ? (maskp)->bits : NULL
^
mm/mempolicy.c:2817:11: note: in expansion of macro �nodemask_pr_args�
nodemask_pr_args(&nodes));
^
CC drivers/clk/renesas/renesas-cpg-mssr.o

Thanks,
Shaokun

> 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:108:11: warning: the comparison will always evaluate as 'true' for the address of 'nodes' will never be NULL [-Waddress]
> ((maskp) != NULL) ? MAX_NUMNODES : 0, \
> ^
> mm/mempolicy.c:2817:11: note: in expansion of macro 'nodemask_pr_args'
> nodemask_pr_args(&nodes));
> ^
> include/linux/nodemask.h:109:11: warning: the comparison will always evaluate as 'true' for the address of 'nodes' will never be NULL [-Waddress]
> ((maskp) != NULL) ? (maskp)->bits : NULL
> ^
> mm/mempolicy.c:2817:11: note: in expansion of macro 'nodemask_pr_args'
> nodemask_pr_args(&nodes));
> ^
>


From 1584307922850336279@xxx Fri Nov 17 10:16:15 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-17 10:16:15

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

Hi all,

On Fri, 17 Nov 2017 09:44:39 +1100 Stephen Rothwell <[email protected]> wrote:
>
> On Mon, 13 Nov 2017 12:43:08 +0100 Arnd Bergmann <[email protected]> wrote:
> >
> > On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko <[email protected]> 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):

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:108:11: warning: the comparison will always evaluate as 'true' for the address of 'nodes' will never be NULL [-Waddress]
((maskp) != NULL) ? MAX_NUMNODES : 0, \
^
mm/mempolicy.c:2817:11: note: in expansion of macro 'nodemask_pr_args'
nodemask_pr_args(&nodes));
^
include/linux/nodemask.h:109:11: warning: the comparison will always evaluate as 'true' for the address of 'nodes' will never be NULL [-Waddress]
((maskp) != NULL) ? (maskp)->bits : NULL
^
mm/mempolicy.c:2817:11: note: in expansion of macro 'nodemask_pr_args'
nodemask_pr_args(&nodes));
^

--
Cheers,
Stephen Rothwell

From 1584299254537368356@xxx Fri Nov 17 07:58:28 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-17 07:58:28

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

Hi all,

On Mon, 13 Nov 2017 12:43:08 +0100 Arnd Bergmann <[email protected]> wrote:
>
> On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko <[email protected]> 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 :-(

--
Cheers,
Stephen Rothwell

From 1583953997591070220@xxx Mon Nov 13 12:30:45 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-13 12:30:46

by Michal Hocko

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Mon 13-11-17 12:54:30, Michal Hocko wrote:
> On Mon 13-11-17 12:43:08, Arnd Bergmann wrote:
> > On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko <[email protected]> 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?
> >
> > 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
>
> OK, that is a reasonable workaround. I was talking to our gcc guy and
> he suggested to report a bug for this.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82963

--
Michal Hocko
SUSE Labs

From 1583953643703881617@xxx Mon Nov 13 12:25:08 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-13 12:25:08

by Arnd Bergmann

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Mon, Nov 13, 2017 at 12:54 PM, Michal Hocko <[email protected]> wrote:
> On Mon 13-11-17 12:43:08, Arnd Bergmann wrote:
>> On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko <[email protected]> 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?
>>
>> 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
>
> OK, that is a reasonable workaround. I was talking to our gcc guy and
> he suggested to report a bug for this.

That might also be useful. Some warnings in gcc get disabled when
they show up inside of a macro, and that could presumably be done
here too.

Arnd

From 1583951860249308784@xxx Mon Nov 13 11:56:47 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-13 11:56:47

by Michal Hocko

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Mon 13-11-17 12:43:08, Arnd Bergmann wrote:
> On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko <[email protected]> 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?
>
> 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

OK, that is a reasonable workaround. I was talking to our gcc guy and
he suggested to report a bug for this. Andrew, could you fold the
explicit != NULL check into the patch please?

--
Michal Hocko
SUSE Labs

From 1583951143469544429@xxx Mon Nov 13 11:45:23 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-13 11:45:24

by Arnd Bergmann

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Mon, Nov 13, 2017 at 9:09 AM, Michal Hocko <[email protected]> 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?

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

From 1583938526808388545@xxx Mon Nov 13 08:24:51 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-13 08:24:52

by Michal Hocko

[permalink] [raw]
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

From 1583937705832797595@xxx Mon Nov 13 08:11:48 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-13 08:11:49

by Michal Hocko

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

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?
--
Michal Hocko
SUSE Labs

From 1583929171297324573@xxx Mon Nov 13 05:56:09 +0000 2017
X-GM-THRID: 1583928351761700407
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread