2009-03-07 23:37:28

by Adrian McMenamin

[permalink] [raw]
Subject: printk issue - bug?

I wonder if anyone can reproduce this behaviour on other architectures
(this was SH4)?

code is:

printk("PAGE_SIZE is 0x%X\n", PAGE_SIZE);
printk("Offset is 0x%X, PAGE_SIZE is 0x%X, readlen is 0x%X\n", offset,
PAGE_SIZE, readlen)

Output is:

[ 162.603348] PAGE_SIZE is 0x1000
[ 162.607473] Offset is 0x0, PAGE_SIZE is 0x0, readlen is 0x1000


ie PAGE_SIZE is incorrectly reported in the second printk (these are
consecutive lines of code)

offset is loff_t and readlen is unsigned long.

Adrian


2009-03-07 23:52:36

by Roland Dreier

[permalink] [raw]
Subject: Re: printk issue - bug?

> printk("PAGE_SIZE is 0x%X\n", PAGE_SIZE);
> printk("Offset is 0x%X, PAGE_SIZE is 0x%X, readlen is 0x%X\n", offset,
> PAGE_SIZE, readlen)
>
> Output is:
>
> [ 162.603348] PAGE_SIZE is 0x1000
> [ 162.607473] Offset is 0x0, PAGE_SIZE is 0x0, readlen is 0x1000
>
> ie PAGE_SIZE is incorrectly reported in the second printk (these are
> consecutive lines of code)
>
> offset is loff_t and readlen is unsigned long.

ie offset is a 64-bit type but the printk format for it is %x, which
presumably only consumes 32 bits on SH4? Seems like your code is buggy
and you ignored a compiler warning about printk format mismatch?

- R.

2009-03-08 01:04:19

by Adrian McMenamin

[permalink] [raw]
Subject: Re: printk issue - bug?

2009/3/7 Roland Dreier <[email protected]>:

>
> ie offset is a 64-bit type but the printk format for it is %x, which
> presumably only consumes 32 bits on SH4? ?Seems like your code is buggy
> and you ignored a compiler warning about printk format mismatch?
>
> ?- R.
>

Yes, loff_t is a long long but why did it work in the first line and
not the second?

2009-03-08 02:20:33

by Robert Hancock

[permalink] [raw]
Subject: Re: printk issue - bug?

Adrian McMenamin wrote:
> 2009/3/7 Roland Dreier <[email protected]>:
>
>> ie offset is a 64-bit type but the printk format for it is %x, which
>> presumably only consumes 32 bits on SH4? Seems like your code is buggy
>> and you ignored a compiler warning about printk format mismatch?
>>
>> - R.
>>
>
> Yes, loff_t is a long long but why did it work in the first line and
> not the second?

It didn't. You didn't print loff_t in the first printk, and the variable
size mismatch corrupted the next value being printed in the second one.