[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <20080318002616.GG3542@webber.adilger.int>
Date: Tue, 18 Mar 2008 08:26:16 +0800
From: Andreas Dilger <adilger@....com>
To: Theodore Tso <tytso@....edu>
Cc: linux-ext4@...r.kernel.org, "Jose R. Santos" <jrs@...ibm.com>
Subject: Re: [PATCH, REWORKED 01/11] Add initial checksum support for the
gdt_checksum/uninit_group feature
On Mar 17, 2008 14:05 -0400, Theodore Ts'o wrote:
> On Tue, Mar 18, 2008 at 01:22:54AM +0800, Andreas Dilger wrote:
> > On Mar 17, 2008 09:28 -0400, Theodore Ts'o wrote:
> > > +STATIC __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
> ....
> > > + if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
> > > + int offset = offsetof(struct ext2_group_desc, bg_checksum);
> > > +
> ...
> > > + offset += sizeof(desc->bg_checksum); /* skip checksum */
> > > + assert(offset == sizeof(*desc));
> >
> > Note that this assertion needs to be removed when the group descriptor
> > becomes larger, unless ext2_group_desc never changes in the future..
>
> Yeah, I looked at this, and was half tempted to remove it.
>
> Indeed ext2_group_desc will never change in the future. Too many
> things would break if we change it. That's why there is an
> ext4_group_desc which looks exactly like ext2_group_desc for the first
> 32 bytes, and adds the high 32-bits for the various fields in the
> second 32-bytes.
>
> But if ext2_group_desc is never going to change, then there's no real
> good reason to use a run-time check here. Better to turn it into a
> compile time check, using #error. The tricky part is doing it in a
> way which is ANSI-C compliant (or maybe we just wrap it in a #ifdef
> GCC and only do the sanity check if you are compiling with GCC).
We have a compile-time assertion like:
/*
* compile-time assertions. @cond has to be constant expression.
* ISO C Standard:
*
* 6.8.4.2 The switch statement
*
* ....
*
* [#3] The expression of each case label shall be an integer
* constant expression and no two of the case constant
* expressions in the same switch statement shall have the same
* value after conversion...
* *
*/
#define CLASSERT(cond) ({ switch(42) { case (cond): case 0: break; } })
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists