2009-06-09 10:40:38

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: net tree build warning

Hi Dave,

Today's linux-next build (powerpc allyesconfig) produced these warnings:

drivers/net/can/sja1000/sja1000_of_platform.c: In function 'sja1000_ofp_probe':
drivers/net/can/sja1000/sja1000_of_platform.c:111: warning: format '%#x' expects type 'unsigned int', but argument 4 has type 'resource_size_t'
drivers/net/can/sja1000/sja1000_of_platform.c:111: warning: format '%#x' expects type 'unsigned int', but argument 5 has type 'resource_size_t'
drivers/net/can/sja1000/sja1000_of_platform.c:118: warning: format '%#x' expects type 'unsigned int', but argument 4 has type 'resource_size_t'
drivers/net/can/sja1000/sja1000_of_platform.c:118: warning: format '%#x' expects type 'unsigned int', but argument 5 has type 'resource_size_t'

Introduced by commit d1a277c584d0862dbf51991baea947ea5f2ce6bf ("can:
sja1000: generic OF platform bus driver").

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/


Attachments:
(No filename) (957.00 B)
(No filename) (197.00 B)
Download all attachments

2009-06-09 11:25:39

by Wolfgang Grandegger

[permalink] [raw]
Subject: Re: linux-next: net tree build warning

Hello,

Stephen Rothwell wrote:
> Hi Dave,
>
> Today's linux-next build (powerpc allyesconfig) produced these warnings:
>
> drivers/net/can/sja1000/sja1000_of_platform.c: In function 'sja1000_ofp_probe':
> drivers/net/can/sja1000/sja1000_of_platform.c:111: warning: format '%#x' expects type 'unsigned int', but argument 4 has type 'resource_size_t'
> drivers/net/can/sja1000/sja1000_of_platform.c:111: warning: format '%#x' expects type 'unsigned int', but argument 5 has type 'resource_size_t'
> drivers/net/can/sja1000/sja1000_of_platform.c:118: warning: format '%#x' expects type 'unsigned int', but argument 4 has type 'resource_size_t'
> drivers/net/can/sja1000/sja1000_of_platform.c:118: warning: format '%#x' expects type 'unsigned int', but argument 5 has type 'resource_size_t'
>
> Introduced by commit d1a277c584d0862dbf51991baea947ea5f2ce6bf ("can:
> sja1000: generic OF platform bus driver").

The patch below should fix the build problems (which I cannot
reproduce on my test systems).

Thanks,

Wolfgang.

-----------------------------------------------------------------------
[PATCH] can: sja1000_of_platform: fix build problems with printk format

Variables of type size_t should be printed with the format "%zx".

Signed-off-by: Wolfgang Grandegger <[email protected]>
---
drivers/net/can/sja1000/sja1000_of_platform.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Index: net-next-2.6/drivers/net/can/sja1000/sja1000_of_platform.c
===================================================================
--- net-next-2.6.orig/drivers/net/can/sja1000/sja1000_of_platform.c 2009-06-09 12:45:38.000000000 +0200
+++ net-next-2.6/drivers/net/can/sja1000/sja1000_of_platform.c 2009-06-09 13:06:56.495718952 +0200
@@ -108,14 +108,14 @@
res_size = resource_size(&res);

if (!request_mem_region(res.start, res_size, DRV_NAME)) {
- dev_err(&ofdev->dev, "couldn't request %#x..%#x\n",
+ dev_err(&ofdev->dev, "couldn't request %#zx..%#zx\n",
res.start, res.end);
return -EBUSY;
}

base = ioremap_nocache(res.start, res_size);
if (!base) {
- dev_err(&ofdev->dev, "couldn't ioremap %#x..%#x\n",
+ dev_err(&ofdev->dev, "couldn't ioremap %#zx..%#zx\n",
res.start, res.end);
err = -ENOMEM;
goto exit_release_mem;

2009-06-09 11:26:33

by David Miller

[permalink] [raw]
Subject: Re: linux-next: net tree build warning

From: Wolfgang Grandegger <[email protected]>
Date: Tue, 09 Jun 2009 13:25:27 +0200

> [PATCH] can: sja1000_of_platform: fix build problems with printk format
>
> Variables of type size_t should be printed with the format "%zx".
>
> Signed-off-by: Wolfgang Grandegger <[email protected]>

It's not a "size_t", it's a "resource_size_t" which can be
"unsigned long long" on some platforms.

2009-06-09 13:14:51

by Wolfgang Grandegger

[permalink] [raw]
Subject: Re: linux-next: net tree build warning

David Miller wrote:
> From: Wolfgang Grandegger <[email protected]>
> Date: Tue, 09 Jun 2009 13:25:27 +0200
>
>> [PATCH] can: sja1000_of_platform: fix build problems with printk format
>>
>> Variables of type size_t should be printed with the format "%zx".
>>
>> Signed-off-by: Wolfgang Grandegger <[email protected]>
>
> It's not a "size_t", it's a "resource_size_t" which can be
> "unsigned long long" on some platforms.

Right, but I assume that the %zx handles that type properly as well.
Should I send a patch with a corrected patch description?

Wolfgang.

2009-06-10 00:38:18

by David Miller

[permalink] [raw]
Subject: Re: linux-next: net tree build warning

From: Wolfgang Grandegger <[email protected]>
Date: Tue, 09 Jun 2009 15:14:38 +0200

> David Miller wrote:
>> From: Wolfgang Grandegger <[email protected]>
>> Date: Tue, 09 Jun 2009 13:25:27 +0200
>>
>>> [PATCH] can: sja1000_of_platform: fix build problems with printk format
>>>
>>> Variables of type size_t should be printed with the format "%zx".
>>>
>>> Signed-off-by: Wolfgang Grandegger <[email protected]>
>>
>> It's not a "size_t", it's a "resource_size_t" which can be
>> "unsigned long long" on some platforms.
>
> Right, but I assume that the %zx handles that type properly as well.

It absolutely does not.

resource_size_t is a arch specifically defined type that
could be anything, it does not conform to the definitions
of size_t.

2009-06-10 07:39:07

by Wolfgang Grandegger

[permalink] [raw]
Subject: Re: linux-next: net tree build warning

David Miller wrote:
> From: Wolfgang Grandegger <[email protected]>
> Date: Tue, 09 Jun 2009 15:14:38 +0200
>
>> David Miller wrote:
>>> From: Wolfgang Grandegger <[email protected]>
>>> Date: Tue, 09 Jun 2009 13:25:27 +0200
>>>
>>>> [PATCH] can: sja1000_of_platform: fix build problems with printk format
>>>>
>>>> Variables of type size_t should be printed with the format "%zx".
>>>>
>>>> Signed-off-by: Wolfgang Grandegger <[email protected]>
>>> It's not a "size_t", it's a "resource_size_t" which can be
>>> "unsigned long long" on some platforms.
>> Right, but I assume that the %zx handles that type properly as well.
>
> It absolutely does not.b
>
> resource_size_t is a arch specifically defined type that
> could be anything, it does not conform to the definitions
> of size_t.

Right, I'm now compiling on a x86_64 system and can reproduce the
warnings. Below is a revised patch.

Thanks for your patience.

Wolfgang.


[PATCH v2] can: sja1000_of_platform: fix build problems with printk format

According to "Documentation/printk-formats.txt", if the type is
dependent on a config option for its size, like resource_size_t,
we should use a format specifier of its largest possible type and
explicitly cast to it.

Signed-off-by: Wolfgang Grandegger <[email protected]>
---
drivers/net/can/sja1000/sja1000_of_platform.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

Index: net-next-2.6/drivers/net/can/sja1000/sja1000_of_platform.c
===================================================================
--- net-next-2.6.orig/drivers/net/can/sja1000/sja1000_of_platform.c 2009-06-09 12:45:38.000000000 +0200
+++ net-next-2.6/drivers/net/can/sja1000/sja1000_of_platform.c 2009-06-10 09:23:47.208720083 +0200
@@ -108,15 +108,17 @@
res_size = resource_size(&res);

if (!request_mem_region(res.start, res_size, DRV_NAME)) {
- dev_err(&ofdev->dev, "couldn't request %#x..%#x\n",
- res.start, res.end);
+ dev_err(&ofdev->dev, "couldn't request %#llx..%#llx\n",
+ (unsigned long long)res.start,
+ (unsigned long long)res.end);
return -EBUSY;
}

base = ioremap_nocache(res.start, res_size);
if (!base) {
- dev_err(&ofdev->dev, "couldn't ioremap %#x..%#x\n",
- res.start, res.end);
+ dev_err(&ofdev->dev, "couldn't ioremap %#llx..%#llx\n",
+ (unsigned long long)res.start,
+ (unsigned long long)res.end);
err = -ENOMEM;
goto exit_release_mem;
}

2009-06-10 08:13:06

by David Miller

[permalink] [raw]
Subject: Re: linux-next: net tree build warning

From: Wolfgang Grandegger <[email protected]>
Date: Wed, 10 Jun 2009 09:38:55 +0200

> [PATCH v2] can: sja1000_of_platform: fix build problems with printk format
>
> According to "Documentation/printk-formats.txt", if the type is
> dependent on a config option for its size, like resource_size_t,
> we should use a format specifier of its largest possible type and
> explicitly cast to it.
>
> Signed-off-by: Wolfgang Grandegger <[email protected]>

Applied, thank you!