2017-06-13 09:55:29

by Charlemagne Lasse

[permalink] [raw]
Subject: ./include/linux/err.h:35:16: warning: dereference of noderef expression

Hi,

I have following code which generates a warning when compiling with "make C=1".

~~~~~~~
struct task_struct *kthread;
kthread = kthread_create(xxxxx, yyyyy, "zzzzz");
if (IS_ERR(kthread)) {
~~~~~~~

The warning is

./include/linux/err.h:35:16: warning: dereference of noderef expression

And disappears when I remove the IS_ERR. How do I correctly work
around this incorrect warning?

Btw. I am using Debian stretch amd64. It seems like this is related to
the __force used in the parameter list of IS_ERR. Removing it also
removes the warning.

If it is fixed in sparse's git then when will there be a new release of it?

Greetings,
Charlemagne Lasse


2017-06-13 10:44:19

by Luc Van Oostenryck

[permalink] [raw]
Subject: Re: ./include/linux/err.h:35:16: warning: dereference of noderef expression

On Tue, Jun 13, 2017 at 11:55:26AM +0200, Charlemagne Lasse wrote:
> Hi,
>
> I have following code which generates a warning when compiling with "make C=1".
>
> ~~~~~~~
> struct task_struct *kthread;
> kthread = kthread_create(xxxxx, yyyyy, "zzzzz");
> if (IS_ERR(kthread)) {
> ~~~~~~~
>
> The warning is
>
> ./include/linux/err.h:35:16: warning: dereference of noderef expression
>
> And disappears when I remove the IS_ERR. How do I correctly work
> around this incorrect warning?
>
> Btw. I am using Debian stretch amd64. It seems like this is related to
> the __force used in the parameter list of IS_ERR. Removing it also
> removes the warning.

The warning is indeed related to '__force' but it should be
the other way around.
Anyway, by just reading your three lines of code, you shouldn't
receive this warning, with or without the __force.

> If it is fixed in sparse's git then when will there be a new release of it?

I can't reproduce your problem even on a three years old version
of sparse (more exactly git version d917662d5 of sparse, anything
older has build problems with half-recent kernels).

The pre-processed version of your file could be interesting
as well as the output of the make command but with the 'V=1'
option added.


Regards,
-- Luc Van Oostenryck