[lkml]   [2002]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Large block device patch, part 1 of 9
On Aug 23, 2002  15:47 +1000, Peter Chubb wrote:
> This part just fixes printk() formats to allow sector_t to be either
> 32 or 64 bit.

> @@ -175,8 +175,8 @@
> drv = &h->drv[i];
> if (drv->block_size == 0)
> continue;
> - size = sprintf(buffer+len, "cciss/c%dd%d: blksz=%d nr_blocks=%d\n",
> - ctlr, i, drv->block_size, drv->nr_blocks);
> + size = sprintf(buffer+len, "cciss/c%dd%d: blksz=%d nr_blocks=%llu\n",
> + ctlr, i, drv->block_size, (unsigned long long)drv->nr_blocks);

Ugh. My personal preference would be to have two things:

1) A kernel-wide definition like the following, maybe in asm/types where
the __u64 types are defined in the first place, to fix printing of __u64
(granted, this isn't exactly your problem, but it is related):

#if BITS_PER_LONG > 32
#define PFU64 "%lu"
#define PFD64 "%ld"
#define PFX64 "%lx"
#define PFU64 "%Lu"
#define PFD64 "%Ld"
#define PFX64 "%Lx"

Then the following works properly without ugly casts or warnings:

__u64 val = 1;

printk("at least "PFU64" of your u64s are belong to us\n", val);

2) Define the sector_t printing similarly so it works without casting:

#if SECTOR_T_BITS == 64 // or whatever
#define PFST "%lu"
#define PFST "%Lu"

size = sprintf(buffer+len, "cciss/c%dd%d: blksz=%d nr_blocks="PFST"\n",
ctlr, i, drv->block_size, drv->nr_blocks);

Cheers, Andreas
Andreas Dilger

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:28    [W:0.102 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site