lkml.org 
[lkml]   [2002]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
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"
#else
#define PFU64 "%Lu"
#define PFD64 "%Ld"
#define PFX64 "%Lx"
#endif

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"
#else
#define PFST "%Lu"
#endif

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
http://www-mddsp.enel.ucalgary.ca/People/adilger/
http://sourceforge.net/projects/ext2resize/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

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