Re: Large block device patch, part 1 of 9

From: Neil Brown (neilb@cse.unsw.edu.au)
Date: Tue Sep 03 2002 - 05:01:21 EST


On Tuesday August 27, bcrl@redhat.com wrote:
> On Tue, Aug 27, 2002 at 03:23:04PM +0000, Pavel Machek wrote:
> > Hi!
> >
> > > 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);
> >
> > Casts are ugly but this looks even worse. I'd go for casts.
>
> Casts override the few type checking abilities the compiler gives us. At
> least with the PFU64 style, we'll get warnings when someone changes a variable
> into a pointer without remembering to update the printk.
>

You could have the best of both worlds with:

static inline long long llsect(sector_t sector) { return (long long)sector;}

and then
   printk("The sector number is %Lu.", llsect(sect_num));

Effectively, this is a type-safe cast. You still get the warning, but
it looks more like the C that we are used to.

NeilBrown

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



This archive was generated by hypermail 2b29 : Sat Sep 07 2002 - 22:00:17 EST