Re: [PATCH 01/16] GFS: headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 10, 2005 at 11:05:37PM +0400, Alexey Dobriyan wrote:
> Please, mark on-disk structures with __le{16,32,64}. It would help
> typechecking with sparse.

Yes, that's something we're working on.

> > +#define CPIN_08(s1, s2, member, count) {memcpy((s1->member), (s2->member), (count));}
> > +#define CPOUT_08(s1, s2, member, count) {memcpy((s2->member), (s1->member), (count));}
> > +#define CPIN_16(s1, s2, member) {(s1->member) = le16_to_cpu((s2->member));}
> > +#define CPOUT_16(s1, s2, member) {(s2->member) = cpu_to_le16((s1->member));}
> > +#define CPIN_32(s1, s2, member) {(s1->member) = le32_to_cpu((s2->member));}
> > +#define CPOUT_32(s1, s2, member) {(s2->member) = cpu_to_le32((s1->member));}
> > +#define CPIN_64(s1, s2, member) {(s1->member) = le64_to_cpu((s2->member));}
> > +#define CPOUT_64(s1, s2, member) {(s2->member) = cpu_to_le64((s1->member));}
> 
> Confusing names and implementation. CP{IN,OUT}_08 do memcpy, the rest
> doesn't. "08" doesn't make sense in CPIN_08, while "16", ... do.
> CPIN_64() expect fixed-endian value or host-endian? Answer is not
> obvious until you look at a header. Fingers really want to type CPU
> every time. I ask you to write a simple script and drop these macros
> completely.

I find this to be an ideal situation for macros, actually, cutting out a
lot of tedious repetition.  I think it clarifies the code considerably in
the end.  The macros are defined immediately above their use in
gfs2_ondisk.h and there's this comment explaining what's going on:

/*
 * gfs2_xxx_in - read in an xxx struct
 * first arg: the cpu-order structure
 * buf: the disk-order buffer
 *
 * gfs2_xxx_out - write out an xxx struct
 * first arg: the cpu-order structure
 * buf: the disk-order buffer
 *
 * gfs2_xxx_print - print out an xxx struct
 * first arg: the cpu-order structure
 */

If others said the same thing as you I wouldn't hesitate to admit I'm
wrong, but several other picky style reviewers haven't said anything...

Thanks,
Dave

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux