public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* printk issue - bug?
@ 2009-03-07 23:37 Adrian McMenamin
  2009-03-07 23:52 ` Roland Dreier
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian McMenamin @ 2009-03-07 23:37 UTC (permalink / raw)
  To: LKML

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

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

* Re: printk issue - bug?
  2009-03-07 23:37 printk issue - bug? Adrian McMenamin
@ 2009-03-07 23:52 ` Roland Dreier
  2009-03-08  1:04   ` Adrian McMenamin
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Dreier @ 2009-03-07 23:52 UTC (permalink / raw)
  To: Adrian McMenamin; +Cc: LKML

 > 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.

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

* Re: printk issue - bug?
  2009-03-07 23:52 ` Roland Dreier
@ 2009-03-08  1:04   ` Adrian McMenamin
  2009-03-08  2:20     ` Robert Hancock
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian McMenamin @ 2009-03-08  1:04 UTC (permalink / raw)
  To: Roland Dreier; +Cc: LKML

2009/3/7 Roland Dreier <rdreier@cisco.com>:

>
> 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?

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

* Re: printk issue - bug?
  2009-03-08  1:04   ` Adrian McMenamin
@ 2009-03-08  2:20     ` Robert Hancock
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Hancock @ 2009-03-08  2:20 UTC (permalink / raw)
  To: Adrian McMenamin; +Cc: Roland Dreier, LKML

Adrian McMenamin wrote:
> 2009/3/7 Roland Dreier <rdreier@cisco.com>:
> 
>> 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.

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

end of thread, other threads:[~2009-03-08  2:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-07 23:37 printk issue - bug? Adrian McMenamin
2009-03-07 23:52 ` Roland Dreier
2009-03-08  1:04   ` Adrian McMenamin
2009-03-08  2:20     ` Robert Hancock

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