lkml.org 
[lkml]   [2014]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC] Easier printing of unknown-size quantities
From
Date
On Thu, 2014-01-09 at 06:42 -0700, Matthew Wilcox wrote:
> We have a number of types whose sizes are architecture- or
> config-dependent such as pgoff_t or sector_t. The recommendation for
> printing them is to cast them to (unsigned long long) and print them with
> %Lu/%llx/... That's entirely reasonable except that it's so verbose.
[]
> diff --git a/fs/buffer.c b/fs/buffer.c
[]
> @@ -148,7 +148,7 @@ static void buffer_io_error(struct buffer_head *bh)
> {
> char b[BDEVNAME_SIZE];
> printk(KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n",
> - bdevname(bh->b_bdev, b),
> - (unsigned long long)bh->b_blocknr);
> + bdevname(bh->b_bdev, b), ULL(bh->b_blocknr));
> }

casting to u64 works and is also simpler

printk(KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n",
bdevname(bh->b_bdev, b), (u64)bh->b_blocknr);




\
 
 \ /
  Last update: 2014-01-09 19:41    [W:0.629 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site