Re: Large block device patch, part 1 of 9

From: Andreas Dilger (
Date: Fri Aug 23 2002 - 02:07:59 EST

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

This archive was generated by hypermail 2b29 : Fri Aug 23 2002 - 22:00:26 EST