2011-03-22 20:39:21

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH] percpu: cast away printk format warning

On 32-bit systems which don't happen to implicitly define or cast
VMALLOC_START and/or VMALLOC_END to long in their arch headers, the
printk in the percpu code will cause a warning to be emitted:

mm/percpu.c: In function 'pcpu_embed_first_chunk':
mm/percpu.c:1648: warning: format '%lx' expects type 'long unsigned int',
but argument 3 has type 'unsigned int'

So add an explicit cast to unsigned long here.

Signed-off-by: Mike Frysinger <[email protected]>
---
mm/percpu.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 3f93001..6897e02 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1647,7 +1647,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
if (max_distance > (VMALLOC_END - VMALLOC_START) * 3 / 4) {
pr_warning("PERCPU: max_distance=0x%zx too large for vmalloc "
"space 0x%lx\n",
- max_distance, VMALLOC_END - VMALLOC_START);
+ max_distance, (unsigned long)(VMALLOC_END - VMALLOC_START));
#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
/* and fail if we have fallback */
rc = -EINVAL;
--
1.7.4.1


Subject: Re: [PATCH] percpu: cast away printk format warning

On Tue, 22 Mar 2011, Mike Frysinger wrote:

> So add an explicit cast to unsigned long here.

I believe we have a format character %t to avoid the cast.

2011-03-22 21:18:35

by Mike Frysinger

[permalink] [raw]
Subject: Re: [PATCH] percpu: cast away printk format warning

On Tue, Mar 22, 2011 at 17:03, Christoph Lameter <wrote:
> On Tue, 22 Mar 2011, Mike Frysinger wrote:
>> So add an explicit cast to unsigned long here.
>
> I believe we have a format character %t to avoid the cast.

thanks, i wasnt aware of the ptrdiff_t extension. i'll send out an update.
-mike

2011-03-22 22:20:05

by Mike Frysinger

[permalink] [raw]
Subject: Re: [PATCH] percpu: cast away printk format warning

On Tue, Mar 22, 2011 at 17:17, Mike Frysinger wrote:
> On Tue, Mar 22, 2011 at 17:03, Christoph Lameter <wrote:
>> On Tue, 22 Mar 2011, Mike Frysinger wrote:
>>> So add an explicit cast to unsigned long here.
>>
>> I believe we have a format character %t to avoid the cast.
>
> thanks, i wasnt aware of the ptrdiff_t extension.  i'll send out an update.

actually, that doesnt work. ptrdiff_t is a type unto itself. in
order for this to work, every arch would need to cast/type
VMALLOC_{START,END} to a pointer type so that they could then be
subtracted. or, add a ptrdiff_t cast to this file ;).
-mike

2011-03-23 07:25:30

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH] percpu: cast away printk format warning

On Tue, Mar 22, 2011 at 04:39:48PM -0400, Mike Frysinger wrote:
> On 32-bit systems which don't happen to implicitly define or cast
> VMALLOC_START and/or VMALLOC_END to long in their arch headers, the
> printk in the percpu code will cause a warning to be emitted:
>
> mm/percpu.c: In function 'pcpu_embed_first_chunk':
> mm/percpu.c:1648: warning: format '%lx' expects type 'long unsigned int',
> but argument 3 has type 'unsigned int'
>
> So add an explicit cast to unsigned long here.
>
> Signed-off-by: Mike Frysinger <[email protected]>

Applied to percpu:fixes-2.6.39 with slight reformatting to avoid going
over 80 column.

Thanks.

--
tejun