* [PATCH] lib: Fix some sparse warnings in devres.c
@ 2014-02-06 16:13 Steven Rostedt
2014-02-06 16:28 ` [PATCH] sched/wait: suppress sparse 'variable shadowing' warning Johannes Berg
2014-02-15 19:41 ` [PATCH] lib: Fix some sparse warnings in devres.c Greg Kroah-Hartman
0 siblings, 2 replies; 7+ messages in thread
From: Steven Rostedt @ 2014-02-06 16:13 UTC (permalink / raw)
To: LKML, Greg Kroah-Hartman, Andrew Morton, H. Peter Anvin, Johannes Berg
Having a discussion about sparse warnings in the kernel, and that we
should clean them up, I decided to pick a random file to do so. This
happened to be devres.c which gives the following warnings:
CHECK lib/devres.c
lib/devres.c:83:9: warning: cast removes address space of expression
lib/devres.c:117:31: warning: incorrect type in return expression (different address spaces)
lib/devres.c:117:31: expected void [noderef] <asn:2>*
lib/devres.c:117:31: got void *
lib/devres.c:125:31: warning: incorrect type in return expression (different address spaces)
lib/devres.c:125:31: expected void [noderef] <asn:2>*
lib/devres.c:125:31: got void *
lib/devres.c:136:26: warning: incorrect type in assignment (different address spaces)
lib/devres.c:136:26: expected void [noderef] <asn:2>*[assigned] dest_ptr
lib/devres.c:136:26: got void *
lib/devres.c:226:9: warning: cast removes address space of expression
Mostly it's just the use of typecasting to void * without adding
__force, or returning ERR_PTR(-ESOMEERR) without typecasting to a
__iomem type.
I added a helper macro IOMEM_ERR_PTR() that does the typecast to make
the code a little nicer than adding ugly typecasts to the code.
This is applied against linux-next.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/lib/devres.c b/lib/devres.c
index 8235331..48cb3c7 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -81,11 +81,13 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
void devm_iounmap(struct device *dev, void __iomem *addr)
{
WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
- (void *)addr));
+ (__force void *)addr));
iounmap(addr);
}
EXPORT_SYMBOL(devm_iounmap);
+#define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
+
/**
* devm_ioremap_resource() - check, request region, and ioremap resource
* @dev: generic device to handle the resource for
@@ -114,7 +116,7 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
if (!res || resource_type(res) != IORESOURCE_MEM) {
dev_err(dev, "invalid resource\n");
- return ERR_PTR(-EINVAL);
+ return IOMEM_ERR_PTR(-EINVAL);
}
size = resource_size(res);
@@ -122,7 +124,7 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
if (!devm_request_mem_region(dev, res->start, size, name)) {
dev_err(dev, "can't request region for resource %pR\n", res);
- return ERR_PTR(-EBUSY);
+ return IOMEM_ERR_PTR(-EBUSY);
}
if (res->flags & IORESOURCE_CACHEABLE)
@@ -133,7 +135,7 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
if (!dest_ptr) {
dev_err(dev, "ioremap failed for resource %pR\n", res);
devm_release_mem_region(dev, res->start, size);
- dest_ptr = ERR_PTR(-ENOMEM);
+ dest_ptr = IOMEM_ERR_PTR(-ENOMEM);
}
return dest_ptr;
@@ -224,7 +226,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
{
ioport_unmap(addr);
WARN_ON(devres_destroy(dev, devm_ioport_map_release,
- devm_ioport_map_match, (void *)addr));
+ devm_ioport_map_match, (__force void *)addr));
}
EXPORT_SYMBOL(devm_ioport_unmap);
#endif /* CONFIG_HAS_IOPORT */
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] sched/wait: suppress sparse 'variable shadowing' warning
2014-02-06 16:13 [PATCH] lib: Fix some sparse warnings in devres.c Steven Rostedt
@ 2014-02-06 16:28 ` Johannes Berg
2014-02-06 16:45 ` Peter Zijlstra
2014-02-10 13:28 ` [tip:core/locking] sched/wait: Suppress Sparse ' variable " tip-bot for Johannes Berg
2014-02-15 19:41 ` [PATCH] lib: Fix some sparse warnings in devres.c Greg Kroah-Hartman
1 sibling, 2 replies; 7+ messages in thread
From: Johannes Berg @ 2014-02-06 16:28 UTC (permalink / raw)
To: LKML
Cc: Andrew Morton, H. Peter Anvin, Steven Rostedt, Ingo Molnar,
Peter Zijlstra
From: Johannes Berg <johannes.berg@intel.com>
This warning seems to show up a lot now, since ___wait_event()
is (indirectly) used inside wait_event_timeout(), which also
has a variable called __ret. Rename the one in ___wait_event()
to ___ret (another leading underscore) to suppress the warning.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/linux/wait.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 559044c..c55ea5c 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -195,7 +195,7 @@ wait_queue_head_t *bit_waitqueue(void *, int);
({ \
__label__ __out; \
wait_queue_t __wait; \
- long __ret = ret; \
+ long ___ret = ret; \
\
INIT_LIST_HEAD(&__wait.task_list); \
if (exclusive) \
@@ -210,7 +210,7 @@ wait_queue_head_t *bit_waitqueue(void *, int);
break; \
\
if (___wait_is_interruptible(state) && __int) { \
- __ret = __int; \
+ ___ret = __int; \
if (exclusive) { \
abort_exclusive_wait(&wq, &__wait, \
state, NULL); \
@@ -222,7 +222,7 @@ wait_queue_head_t *bit_waitqueue(void *, int);
cmd; \
} \
finish_wait(&wq, &__wait); \
-__out: __ret; \
+__out: ___ret; \
})
#define __wait_event(wq, condition) \
--
1.8.5.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] sched/wait: suppress sparse 'variable shadowing' warning
2014-02-06 16:28 ` [PATCH] sched/wait: suppress sparse 'variable shadowing' warning Johannes Berg
@ 2014-02-06 16:45 ` Peter Zijlstra
2014-02-06 16:52 ` Steven Rostedt
2014-02-10 13:28 ` [tip:core/locking] sched/wait: Suppress Sparse ' variable " tip-bot for Johannes Berg
1 sibling, 1 reply; 7+ messages in thread
From: Peter Zijlstra @ 2014-02-06 16:45 UTC (permalink / raw)
To: Johannes Berg
Cc: LKML, Andrew Morton, H. Peter Anvin, Steven Rostedt, Ingo Molnar
On Thu, Feb 06, 2014 at 05:28:41PM +0100, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> This warning seems to show up a lot now, since ___wait_event()
> is (indirectly) used inside wait_event_timeout(), which also
> has a variable called __ret. Rename the one in ___wait_event()
> to ___ret (another leading underscore) to suppress the warning.
>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sched/wait: suppress sparse 'variable shadowing' warning
2014-02-06 16:45 ` Peter Zijlstra
@ 2014-02-06 16:52 ` Steven Rostedt
2014-02-09 12:44 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2014-02-06 16:52 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Johannes Berg, LKML, Andrew Morton, H. Peter Anvin, Ingo Molnar
On Thu, 6 Feb 2014 17:45:58 +0100
Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, Feb 06, 2014 at 05:28:41PM +0100, Johannes Berg wrote:
> > From: Johannes Berg <johannes.berg@intel.com>
> >
> > This warning seems to show up a lot now, since ___wait_event()
> > is (indirectly) used inside wait_event_timeout(), which also
> > has a variable called __ret. Rename the one in ___wait_event()
> > to ___ret (another leading underscore) to suppress the warning.
> >
> > Signed-off-by: Johannes Berg <johannes.berg@intel.com>
>
> Thanks!
Tag, you're it!
Now you need to submit a patch to fix one sparse warning this week ;-)
Yeah, yeah, I know. Like you have time.
This could be a cool drinking game. Every time you fix someone else's
sparse error, they have to drink a pint :-)
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sched/wait: suppress sparse 'variable shadowing' warning
2014-02-06 16:52 ` Steven Rostedt
@ 2014-02-09 12:44 ` Ingo Molnar
0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2014-02-09 12:44 UTC (permalink / raw)
To: Steven Rostedt
Cc: Peter Zijlstra, Johannes Berg, LKML, Andrew Morton,
H. Peter Anvin, Ingo Molnar
* Steven Rostedt <rostedt@goodmis.org> wrote:
> On Thu, 6 Feb 2014 17:45:58 +0100
> Peter Zijlstra <peterz@infradead.org> wrote:
>
> > On Thu, Feb 06, 2014 at 05:28:41PM +0100, Johannes Berg wrote:
> > > From: Johannes Berg <johannes.berg@intel.com>
> > >
> > > This warning seems to show up a lot now, since ___wait_event()
> > > is (indirectly) used inside wait_event_timeout(), which also
> > > has a variable called __ret. Rename the one in ___wait_event()
> > > to ___ret (another leading underscore) to suppress the warning.
> > >
> > > Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> >
> > Thanks!
>
> Tag, you're it!
>
> Now you need to submit a patch to fix one sparse warning this week ;-)
>
> Yeah, yeah, I know. Like you have time.
>
> This could be a cool drinking game. Every time you fix someone else's
> sparse error, they have to drink a pint :-)
... which game would result in a heightened mood amongst developers
and even more Sparse errors, resulting in more fixes from PeterZ and
more pints downed, creating a nice feedback loop. Sounds like fun for
everyone, except Peter? ;-)
Thanks,
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:core/locking] sched/wait: Suppress Sparse ' variable shadowing' warning
2014-02-06 16:28 ` [PATCH] sched/wait: suppress sparse 'variable shadowing' warning Johannes Berg
2014-02-06 16:45 ` Peter Zijlstra
@ 2014-02-10 13:28 ` tip-bot for Johannes Berg
1 sibling, 0 replies; 7+ messages in thread
From: tip-bot for Johannes Berg @ 2014-02-10 13:28 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, peterz, rostedt, akpm, johannes.berg, tglx
Commit-ID: 980f88e414418bf65569a3b62b08b07e6fc2f4c6
Gitweb: http://git.kernel.org/tip/980f88e414418bf65569a3b62b08b07e6fc2f4c6
Author: Johannes Berg <johannes.berg@intel.com>
AuthorDate: Thu, 6 Feb 2014 17:28:41 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 9 Feb 2014 13:11:49 +0100
sched/wait: Suppress Sparse 'variable shadowing' warning
This warning seems to show up a lot now, since ___wait_event()
is (indirectly) used inside wait_event_timeout(), which also
has a variable called __ret. Rename the one in ___wait_event()
to ___ret (another leading underscore) to suppress the warning.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/1391704121.12789.20.camel@jlt4.sipsolutions.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/wait.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 559044c..c55ea5c 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -195,7 +195,7 @@ wait_queue_head_t *bit_waitqueue(void *, int);
({ \
__label__ __out; \
wait_queue_t __wait; \
- long __ret = ret; \
+ long ___ret = ret; \
\
INIT_LIST_HEAD(&__wait.task_list); \
if (exclusive) \
@@ -210,7 +210,7 @@ wait_queue_head_t *bit_waitqueue(void *, int);
break; \
\
if (___wait_is_interruptible(state) && __int) { \
- __ret = __int; \
+ ___ret = __int; \
if (exclusive) { \
abort_exclusive_wait(&wq, &__wait, \
state, NULL); \
@@ -222,7 +222,7 @@ wait_queue_head_t *bit_waitqueue(void *, int);
cmd; \
} \
finish_wait(&wq, &__wait); \
-__out: __ret; \
+__out: ___ret; \
})
#define __wait_event(wq, condition) \
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] lib: Fix some sparse warnings in devres.c
2014-02-06 16:13 [PATCH] lib: Fix some sparse warnings in devres.c Steven Rostedt
2014-02-06 16:28 ` [PATCH] sched/wait: suppress sparse 'variable shadowing' warning Johannes Berg
@ 2014-02-15 19:41 ` Greg Kroah-Hartman
1 sibling, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2014-02-15 19:41 UTC (permalink / raw)
To: Steven Rostedt; +Cc: LKML, Andrew Morton, H. Peter Anvin, Johannes Berg
On Thu, Feb 06, 2014 at 11:13:46AM -0500, Steven Rostedt wrote:
> Having a discussion about sparse warnings in the kernel, and that we
> should clean them up, I decided to pick a random file to do so. This
> happened to be devres.c which gives the following warnings:
>
> CHECK lib/devres.c
> lib/devres.c:83:9: warning: cast removes address space of expression
> lib/devres.c:117:31: warning: incorrect type in return expression (different address spaces)
> lib/devres.c:117:31: expected void [noderef] <asn:2>*
> lib/devres.c:117:31: got void *
> lib/devres.c:125:31: warning: incorrect type in return expression (different address spaces)
> lib/devres.c:125:31: expected void [noderef] <asn:2>*
> lib/devres.c:125:31: got void *
> lib/devres.c:136:26: warning: incorrect type in assignment (different address spaces)
> lib/devres.c:136:26: expected void [noderef] <asn:2>*[assigned] dest_ptr
> lib/devres.c:136:26: got void *
> lib/devres.c:226:9: warning: cast removes address space of expression
>
> Mostly it's just the use of typecasting to void * without adding
> __force, or returning ERR_PTR(-ESOMEERR) without typecasting to a
> __iomem type.
>
> I added a helper macro IOMEM_ERR_PTR() that does the typecast to make
> the code a little nicer than adding ugly typecasts to the code.
>
> This is applied against linux-next.
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-02-15 19:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-06 16:13 [PATCH] lib: Fix some sparse warnings in devres.c Steven Rostedt
2014-02-06 16:28 ` [PATCH] sched/wait: suppress sparse 'variable shadowing' warning Johannes Berg
2014-02-06 16:45 ` Peter Zijlstra
2014-02-06 16:52 ` Steven Rostedt
2014-02-09 12:44 ` Ingo Molnar
2014-02-10 13:28 ` [tip:core/locking] sched/wait: Suppress Sparse ' variable " tip-bot for Johannes Berg
2014-02-15 19:41 ` [PATCH] lib: Fix some sparse warnings in devres.c Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).