public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem *
@ 2013-06-12 21:31 Marc Kleine-Budde
  2013-06-13  5:25 ` Sachin Kamat
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Kleine-Budde @ 2013-06-12 21:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, kernel, Marc Kleine-Budde

Commit 75096579c3ac ("lib: devres: Introduce devm_ioremap_resource()")
introduced devm_ioremap_resource() and encourage to check its return value with
IS_ERR(). This however leads to the following sparse warnings, as
devm_ioremap_resource() returns a void __iomem pointer:

drivers/net/can/c_can/c_can_platform.c:205:32: warning: incorrect type in argument 1 (different address spaces)
drivers/net/can/c_can/c_can_platform.c:205:32:    expected void const *ptr
drivers/net/can/c_can/c_can_platform.c:205:32:    got unsigned int [noderef] [usertype] <asn:2>*raminit_ctrlreg

This patch silences the warning by introducing a macro to force cast the
pointer to a plain const void *.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Hello,

I think this macro is a bit ugly, is there a better way to make sparse happy?
If we agree on a solution other functions in this file have to be wrapped.

regards,
Marc

 include/linux/err.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/err.h b/include/linux/err.h
index f2edce2..1a5a57b 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -29,11 +29,13 @@ static inline long __must_check PTR_ERR(const void *ptr)
 	return (long) ptr;
 }
 
-static inline long __must_check IS_ERR(const void *ptr)
+static inline long __must_check __IS_ERR(const void *ptr)
 {
 	return IS_ERR_VALUE((unsigned long)ptr);
 }
 
+#define IS_ERR(__ptr)	__IS_ERR((const void __force *)__ptr)
+
 static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
 {
 	return !ptr || IS_ERR_VALUE((unsigned long)ptr);
-- 
1.8.2.rc2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem *
  2013-06-12 21:31 [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem * Marc Kleine-Budde
@ 2013-06-13  5:25 ` Sachin Kamat
  2013-06-13 18:24   ` Thierry Reding
  0 siblings, 1 reply; 8+ messages in thread
From: Sachin Kamat @ 2013-06-13  5:25 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Andrew Morton, linux-kernel, kernel, Thierry Reding

On 13 June 2013 03:01, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> Commit 75096579c3ac ("lib: devres: Introduce devm_ioremap_resource()")
> introduced devm_ioremap_resource() and encourage to check its return value with
> IS_ERR(). This however leads to the following sparse warnings, as
> devm_ioremap_resource() returns a void __iomem pointer:
>
> drivers/net/can/c_can/c_can_platform.c:205:32: warning: incorrect type in argument 1 (different address spaces)
> drivers/net/can/c_can/c_can_platform.c:205:32:    expected void const *ptr
> drivers/net/can/c_can/c_can_platform.c:205:32:    got unsigned int [noderef] [usertype] <asn:2>*raminit_ctrlreg

CC ing Thierry who has solved this issue some time back.

-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem *
  2013-06-13  5:25 ` Sachin Kamat
@ 2013-06-13 18:24   ` Thierry Reding
  2013-06-13 19:19     ` Marc Kleine-Budde
  2013-06-13 20:14     ` Andrew Morton
  0 siblings, 2 replies; 8+ messages in thread
From: Thierry Reding @ 2013-06-13 18:24 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: Marc Kleine-Budde, Andrew Morton, linux-kernel, kernel

[-- Attachment #1: Type: text/plain, Size: 929 bytes --]

On Thu, Jun 13, 2013 at 10:55:17AM +0530, Sachin Kamat wrote:
> On 13 June 2013 03:01, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> > Commit 75096579c3ac ("lib: devres: Introduce devm_ioremap_resource()")
> > introduced devm_ioremap_resource() and encourage to check its return value with
> > IS_ERR(). This however leads to the following sparse warnings, as
> > devm_ioremap_resource() returns a void __iomem pointer:
> >
> > drivers/net/can/c_can/c_can_platform.c:205:32: warning: incorrect type in argument 1 (different address spaces)
> > drivers/net/can/c_can/c_can_platform.c:205:32:    expected void const *ptr
> > drivers/net/can/c_can/c_can_platform.c:205:32:    got unsigned int [noderef] [usertype] <asn:2>*raminit_ctrlreg
> 
> CC ing Thierry who has solved this issue some time back.

I had sent two patches, one against sparse, the other against the
kernel, but none were picked up yet.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem *
  2013-06-13 18:24   ` Thierry Reding
@ 2013-06-13 19:19     ` Marc Kleine-Budde
  2013-06-13 20:14     ` Andrew Morton
  1 sibling, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2013-06-13 19:19 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Sachin Kamat, Andrew Morton, linux-kernel, kernel

[-- Attachment #1: Type: text/plain, Size: 1316 bytes --]

On 06/13/2013 08:24 PM, Thierry Reding wrote:
> On Thu, Jun 13, 2013 at 10:55:17AM +0530, Sachin Kamat wrote:
>> On 13 June 2013 03:01, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>>> Commit 75096579c3ac ("lib: devres: Introduce devm_ioremap_resource()")
>>> introduced devm_ioremap_resource() and encourage to check its return value with
>>> IS_ERR(). This however leads to the following sparse warnings, as
>>> devm_ioremap_resource() returns a void __iomem pointer:
>>>
>>> drivers/net/can/c_can/c_can_platform.c:205:32: warning: incorrect type in argument 1 (different address spaces)
>>> drivers/net/can/c_can/c_can_platform.c:205:32:    expected void const *ptr
>>> drivers/net/can/c_can/c_can_platform.c:205:32:    got unsigned int [noderef] [usertype] <asn:2>*raminit_ctrlreg
>>
>> CC ing Thierry who has solved this issue some time back.
> 
> I had sent two patches, one against sparse, the other against the
> kernel, but none were picked up yet.

Can you repost them? Hope someone will pick them up.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem *
  2013-06-13 18:24   ` Thierry Reding
  2013-06-13 19:19     ` Marc Kleine-Budde
@ 2013-06-13 20:14     ` Andrew Morton
  2013-06-13 21:39       ` Thierry Reding
  1 sibling, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2013-06-13 20:14 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Sachin Kamat, Marc Kleine-Budde, linux-kernel, kernel,
	Dan Carpenter

On Thu, 13 Jun 2013 20:24:48 +0200 Thierry Reding <thierry.reding@gmail.com> wrote:

> On Thu, Jun 13, 2013 at 10:55:17AM +0530, Sachin Kamat wrote:
> > On 13 June 2013 03:01, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> > > Commit 75096579c3ac ("lib: devres: Introduce devm_ioremap_resource()")
> > > introduced devm_ioremap_resource() and encourage to check its return value with
> > > IS_ERR(). This however leads to the following sparse warnings, as
> > > devm_ioremap_resource() returns a void __iomem pointer:
> > >
> > > drivers/net/can/c_can/c_can_platform.c:205:32: warning: incorrect type in argument 1 (different address spaces)
> > > drivers/net/can/c_can/c_can_platform.c:205:32:    expected void const *ptr
> > > drivers/net/can/c_can/c_can_platform.c:205:32:    got unsigned int [noderef] [usertype] <asn:2>*raminit_ctrlreg
> > 
> > CC ing Thierry who has solved this issue some time back.
> 
> I had sent two patches, one against sparse, the other against the
> kernel, but none were picked up yet.

I didn't know that.

On May 8 I queued
http://ozlabs.org/~akpm/mmots/broken-out/errh-is_err-can-accept-__user-pointers.patch.
Dan says that sparse v0.4.5-rc1 or later is also required.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem *
  2013-06-13 20:14     ` Andrew Morton
@ 2013-06-13 21:39       ` Thierry Reding
  2013-06-17  7:59         ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: Thierry Reding @ 2013-06-13 21:39 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Sachin Kamat, Marc Kleine-Budde, linux-kernel, kernel,
	Dan Carpenter

[-- Attachment #1: Type: text/plain, Size: 1680 bytes --]

On Thu, Jun 13, 2013 at 01:14:15PM -0700, Andrew Morton wrote:
> On Thu, 13 Jun 2013 20:24:48 +0200 Thierry Reding <thierry.reding@gmail.com> wrote:
> 
> > On Thu, Jun 13, 2013 at 10:55:17AM +0530, Sachin Kamat wrote:
> > > On 13 June 2013 03:01, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> > > > Commit 75096579c3ac ("lib: devres: Introduce devm_ioremap_resource()")
> > > > introduced devm_ioremap_resource() and encourage to check its return value with
> > > > IS_ERR(). This however leads to the following sparse warnings, as
> > > > devm_ioremap_resource() returns a void __iomem pointer:
> > > >
> > > > drivers/net/can/c_can/c_can_platform.c:205:32: warning: incorrect type in argument 1 (different address spaces)
> > > > drivers/net/can/c_can/c_can_platform.c:205:32:    expected void const *ptr
> > > > drivers/net/can/c_can/c_can_platform.c:205:32:    got unsigned int [noderef] [usertype] <asn:2>*raminit_ctrlreg
> > > 
> > > CC ing Thierry who has solved this issue some time back.
> > 
> > I had sent two patches, one against sparse, the other against the
> > kernel, but none were picked up yet.
> 
> I didn't know that.
> 
> On May 8 I queued
> http://ozlabs.org/~akpm/mmots/broken-out/errh-is_err-can-accept-__user-pointers.patch.
> Dan says that sparse v0.4.5-rc1 or later is also required.

So maybe latest sparse does have the patch. I didn't find it looking at
the logs. But looking again it seems like an equivalent patch made it in
recently. Also the above patch looks very much like what I posted back
at the time. Shame that work was duplicated, maybe I should have pushed
harder when I didn't get a response.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem *
  2013-06-13 21:39       ` Thierry Reding
@ 2013-06-17  7:59         ` Dan Carpenter
  2013-06-17 10:11           ` Thierry Reding
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2013-06-17  7:59 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Andrew Morton, Sachin Kamat, Marc Kleine-Budde, linux-kernel,
	kernel

On Thu, Jun 13, 2013 at 11:39:25PM +0200, Thierry Reding wrote:
> On Thu, Jun 13, 2013 at 01:14:15PM -0700, Andrew Morton wrote:
> > On Thu, 13 Jun 2013 20:24:48 +0200 Thierry Reding <thierry.reding@gmail.com> wrote:
> > 
> > > On Thu, Jun 13, 2013 at 10:55:17AM +0530, Sachin Kamat wrote:
> > > > On 13 June 2013 03:01, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> > > > > Commit 75096579c3ac ("lib: devres: Introduce devm_ioremap_resource()")
> > > > > introduced devm_ioremap_resource() and encourage to check its return value with
> > > > > IS_ERR(). This however leads to the following sparse warnings, as
> > > > > devm_ioremap_resource() returns a void __iomem pointer:
> > > > >
> > > > > drivers/net/can/c_can/c_can_platform.c:205:32: warning: incorrect type in argument 1 (different address spaces)
> > > > > drivers/net/can/c_can/c_can_platform.c:205:32:    expected void const *ptr
> > > > > drivers/net/can/c_can/c_can_platform.c:205:32:    got unsigned int [noderef] [usertype] <asn:2>*raminit_ctrlreg
> > > > 
> > > > CC ing Thierry who has solved this issue some time back.
> > > 
> > > I had sent two patches, one against sparse, the other against the
> > > kernel, but none were picked up yet.
> > 
> > I didn't know that.
> > 
> > On May 8 I queued
> > http://ozlabs.org/~akpm/mmots/broken-out/errh-is_err-can-accept-__user-pointers.patch.
> > Dan says that sparse v0.4.5-rc1 or later is also required.
> 
> So maybe latest sparse does have the patch. I didn't find it looking at
> the logs. But looking again it seems like an equivalent patch made it in
> recently. Also the above patch looks very much like what I posted back
> at the time. Shame that work was duplicated, maybe I should have pushed
> harder when I didn't get a response.
> 
> Thierry

Sorry about that.  I didn't mean to steal anyone's patch.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem *
  2013-06-17  7:59         ` Dan Carpenter
@ 2013-06-17 10:11           ` Thierry Reding
  0 siblings, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2013-06-17 10:11 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andrew Morton, Sachin Kamat, Marc Kleine-Budde, linux-kernel,
	kernel

[-- Attachment #1: Type: text/plain, Size: 2102 bytes --]

On Mon, Jun 17, 2013 at 10:59:25AM +0300, Dan Carpenter wrote:
> On Thu, Jun 13, 2013 at 11:39:25PM +0200, Thierry Reding wrote:
> > On Thu, Jun 13, 2013 at 01:14:15PM -0700, Andrew Morton wrote:
> > > On Thu, 13 Jun 2013 20:24:48 +0200 Thierry Reding <thierry.reding@gmail.com> wrote:
> > > 
> > > > On Thu, Jun 13, 2013 at 10:55:17AM +0530, Sachin Kamat wrote:
> > > > > On 13 June 2013 03:01, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> > > > > > Commit 75096579c3ac ("lib: devres: Introduce devm_ioremap_resource()")
> > > > > > introduced devm_ioremap_resource() and encourage to check its return value with
> > > > > > IS_ERR(). This however leads to the following sparse warnings, as
> > > > > > devm_ioremap_resource() returns a void __iomem pointer:
> > > > > >
> > > > > > drivers/net/can/c_can/c_can_platform.c:205:32: warning: incorrect type in argument 1 (different address spaces)
> > > > > > drivers/net/can/c_can/c_can_platform.c:205:32:    expected void const *ptr
> > > > > > drivers/net/can/c_can/c_can_platform.c:205:32:    got unsigned int [noderef] [usertype] <asn:2>*raminit_ctrlreg
> > > > > 
> > > > > CC ing Thierry who has solved this issue some time back.
> > > > 
> > > > I had sent two patches, one against sparse, the other against the
> > > > kernel, but none were picked up yet.
> > > 
> > > I didn't know that.
> > > 
> > > On May 8 I queued
> > > http://ozlabs.org/~akpm/mmots/broken-out/errh-is_err-can-accept-__user-pointers.patch.
> > > Dan says that sparse v0.4.5-rc1 or later is also required.
> > 
> > So maybe latest sparse does have the patch. I didn't find it looking at
> > the logs. But looking again it seems like an equivalent patch made it in
> > recently. Also the above patch looks very much like what I posted back
> > at the time. Shame that work was duplicated, maybe I should have pushed
> > harder when I didn't get a response.
> > 
> > Thierry
> 
> Sorry about that.  I didn't mean to steal anyone's patch.

No worries. If the issue can finally be closed up with sparse 0.4.5 it's
all good.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-17 10:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-12 21:31 [RFC: PATCH] err.h: silence warning when using IS_ERR on void __iomem * Marc Kleine-Budde
2013-06-13  5:25 ` Sachin Kamat
2013-06-13 18:24   ` Thierry Reding
2013-06-13 19:19     ` Marc Kleine-Budde
2013-06-13 20:14     ` Andrew Morton
2013-06-13 21:39       ` Thierry Reding
2013-06-17  7:59         ` Dan Carpenter
2013-06-17 10:11           ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox