* [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression
@ 2014-06-10 21:38 Jeff Layton
2014-06-11 5:45 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2014-06-10 21:38 UTC (permalink / raw)
To: linux-kernel; +Cc: dan.carpenter, linux-sparse, Jeff Layton
From: Jeff Layton <jlayton@primarydata.com>
Lately, when I do a make with C=1, I get *tons* of these warnings:
include/linux/err.h:35:16: warning: dereference of noderef expression
include/linux/err.h:30:23: warning: dereference of noderef expression
...so many that it's really driven down the signal to noise ratio. I've
taken a look at what's driving these warnings and I really just don't
get it. The pointers being passed in aren't being dereferenced as far
as I can tell, so what is sparse complaining about?
Even odder, just in playing around I've noticed that removing the
__force directives seems to silence these warnings. This is really
strange since all of the docs I see indicate that __force is supposed to
help silence sparse warnings, not cause them.
This patch just removes the __force directives on the err.h inlines and
that silences the warnings for me. Dan originally added those in commit
e7152b97f38f1 (err.h: IS_ERR() can accept __user pointers).
I don't really consider this a serious proposal for inclusion, but
rather just a starting point for discussion. What's the right way to fix
this problem? Is this a bug in sparse?
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
---
include/linux/err.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/err.h b/include/linux/err.h
index a729120644d5..284897f403b3 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -25,17 +25,17 @@ static inline void * __must_check ERR_PTR(long error)
return (void *) error;
}
-static inline long __must_check PTR_ERR(__force const void *ptr)
+static inline long __must_check PTR_ERR(const void *ptr)
{
return (long) ptr;
}
-static inline bool __must_check IS_ERR(__force const void *ptr)
+static inline bool __must_check IS_ERR(const void *ptr)
{
return IS_ERR_VALUE((unsigned long)ptr);
}
-static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
+static inline bool __must_check IS_ERR_OR_NULL(const void *ptr)
{
return !ptr || IS_ERR_VALUE((unsigned long)ptr);
}
@@ -47,13 +47,13 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
* Explicitly cast an error-valued pointer to another pointer type in such a
* way as to make it clear that's what's going on.
*/
-static inline void * __must_check ERR_CAST(__force const void *ptr)
+static inline void * __must_check ERR_CAST(const void *ptr)
{
/* cast away the const */
return (void *) ptr;
}
-static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+static inline int __must_check PTR_ERR_OR_ZERO(const void *ptr)
{
if (IS_ERR(ptr))
return PTR_ERR(ptr);
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression
2014-06-10 21:38 [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression Jeff Layton
@ 2014-06-11 5:45 ` Dan Carpenter
2014-06-11 11:06 ` Jeff Layton
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-06-11 5:45 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-kernel, linux-sparse, Jeff Layton
On Tue, Jun 10, 2014 at 05:38:49PM -0400, Jeff Layton wrote:
> From: Jeff Layton <jlayton@primarydata.com>
>
> Lately, when I do a make with C=1, I get *tons* of these warnings:
>
> include/linux/err.h:35:16: warning: dereference of noderef expression
> include/linux/err.h:30:23: warning: dereference of noderef expression
Which version of Sparse, which version of the kernel and which .c file
can I compile to reproduce this?
I built fs/cifs/ and I didn't see the sparse warning.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression
2014-06-11 5:45 ` Dan Carpenter
@ 2014-06-11 11:06 ` Jeff Layton
2014-06-11 13:11 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2014-06-11 11:06 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-kernel, linux-sparse, Jeff Layton
On Wed, 11 Jun 2014 08:45:18 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Jun 10, 2014 at 05:38:49PM -0400, Jeff Layton wrote:
> > From: Jeff Layton <jlayton@primarydata.com>
> >
> > Lately, when I do a make with C=1, I get *tons* of these warnings:
> >
> > include/linux/err.h:35:16: warning: dereference of noderef expression
> > include/linux/err.h:30:23: warning: dereference of noderef expression
>
> Which version of Sparse, which version of the kernel and which .c file
> can I compile to reproduce this?
>
> I built fs/cifs/ and I didn't see the sparse warning.
>
> regards,
> dan carpenter
>
$ rpm -q sparse
sparse-0.5.0-1.fc20.x86_64
I see it all over the tree, but an easy example is fs/locks.c:
$ make fs/locks.o C=1
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CALL scripts/checksyscalls.sh
CHECK fs/locks.c
include/linux/err.h:35:16: warning: dereference of noderef expression
include/linux/err.h:30:23: warning: dereference of noderef expression
include/linux/err.h:35:16: warning: dereference of noderef expression
include/linux/err.h:30:23: warning: dereference of noderef expression
CC fs/locks.o
It has two IS_ERR calls and two PTR_ERR calls, and each generates the
warning.
--
Jeff Layton <jlayton@poochiereds.net>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression
2014-06-11 11:06 ` Jeff Layton
@ 2014-06-11 13:11 ` Dan Carpenter
2014-06-11 13:51 ` Jeff Layton
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-06-11 13:11 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-kernel, linux-sparse, Jeff Layton
On Wed, Jun 11, 2014 at 07:06:32AM -0400, Jeff Layton wrote:
> $ rpm -q sparse
> sparse-0.5.0-1.fc20.x86_64
>
> I see it all over the tree, but an easy example is fs/locks.c:
>
> $ make fs/locks.o C=1
> make[1]: Nothing to be done for `all'.
> make[1]: Nothing to be done for `relocs'.
> CHK include/config/kernel.release
> CHK include/generated/uapi/linux/version.h
> CHK include/generated/utsrelease.h
> CALL scripts/checksyscalls.sh
> CHECK fs/locks.c
> include/linux/err.h:35:16: warning: dereference of noderef expression
> include/linux/err.h:30:23: warning: dereference of noderef expression
> include/linux/err.h:35:16: warning: dereference of noderef expression
> include/linux/err.h:30:23: warning: dereference of noderef expression
> CC fs/locks.o
>
> It has two IS_ERR calls and two PTR_ERR calls, and each generates the
> warning.
>
I downloaded the Fedora SRPM and built the binary but I still wasn't
able to reproduce the bug.
dcarpenter@speke:~/progs/kernel/devel$ /tmp/sparse/sparse-0.5.0/sparse --version
0.5.0
dcarpenter@speke:~/progs/kernel/devel$ make C=2 CHECK=/tmp/sparse/sparse-0.5.0/sparse fs/locks.o
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CALL scripts/checksyscalls.sh
<stdin>:1226:2: warning: #warning syscall finit_module not implemented [-Wcpp]
<stdin>:1229:2: warning: #warning syscall sched_setattr not implemented [-Wcpp]
<stdin>:1232:2: warning: #warning syscall sched_getattr not implemented [-Wcpp]
<stdin>:1235:2: warning: #warning syscall renameat2 not implemented [-Wcpp]
CHECK scripts/mod/empty.c
CHECK fs/locks.c
dcarpenter@speke:~/progs/kernel/devel$
I'm on today's linux-next. I can't think of a kernel configuration
issue which would cause this...
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression
2014-06-11 13:11 ` Dan Carpenter
@ 2014-06-11 13:51 ` Jeff Layton
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2014-06-11 13:51 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-kernel, linux-sparse, Jeff Layton
On Wed, 11 Jun 2014 16:11:46 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Wed, Jun 11, 2014 at 07:06:32AM -0400, Jeff Layton wrote:
> > $ rpm -q sparse
> > sparse-0.5.0-1.fc20.x86_64
> >
> > I see it all over the tree, but an easy example is fs/locks.c:
> >
> > $ make fs/locks.o C=1
> > make[1]: Nothing to be done for `all'.
> > make[1]: Nothing to be done for `relocs'.
> > CHK include/config/kernel.release
> > CHK include/generated/uapi/linux/version.h
> > CHK include/generated/utsrelease.h
> > CALL scripts/checksyscalls.sh
> > CHECK fs/locks.c
> > include/linux/err.h:35:16: warning: dereference of noderef expression
> > include/linux/err.h:30:23: warning: dereference of noderef expression
> > include/linux/err.h:35:16: warning: dereference of noderef expression
> > include/linux/err.h:30:23: warning: dereference of noderef expression
> > CC fs/locks.o
> >
> > It has two IS_ERR calls and two PTR_ERR calls, and each generates the
> > warning.
> >
>
> I downloaded the Fedora SRPM and built the binary but I still wasn't
> able to reproduce the bug.
>
> dcarpenter@speke:~/progs/kernel/devel$ /tmp/sparse/sparse-0.5.0/sparse --version
> 0.5.0
> dcarpenter@speke:~/progs/kernel/devel$ make C=2 CHECK=/tmp/sparse/sparse-0.5.0/sparse fs/locks.o
> CHK include/config/kernel.release
> CHK include/generated/uapi/linux/version.h
> CHK include/generated/utsrelease.h
> CALL scripts/checksyscalls.sh
> <stdin>:1226:2: warning: #warning syscall finit_module not implemented [-Wcpp]
> <stdin>:1229:2: warning: #warning syscall sched_setattr not implemented [-Wcpp]
> <stdin>:1232:2: warning: #warning syscall sched_getattr not implemented [-Wcpp]
> <stdin>:1235:2: warning: #warning syscall renameat2 not implemented [-Wcpp]
> CHECK scripts/mod/empty.c
> CHECK fs/locks.c
> dcarpenter@speke:~/progs/kernel/devel$
>
> I'm on today's linux-next. I can't think of a kernel configuration
> issue which would cause this...
>
> regards,
> dan carpenter
Could it be arch-specific then? What arch are you using? I'm on x86_64.
I know that quite a few other people have mentioned seeing these
warnings as well, so I'm pretty sure it's not just me.
--
Jeff Layton <jlayton@poochiereds.net>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-11 13:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10 21:38 [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression Jeff Layton
2014-06-11 5:45 ` Dan Carpenter
2014-06-11 11:06 ` Jeff Layton
2014-06-11 13:11 ` Dan Carpenter
2014-06-11 13:51 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox