[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <41DF7E1A-4CF0-44CF-AD8F-29176397B7EF@dilger.ca>
Date: Mon, 10 Jan 2011 00:45:17 -0700
From: Andreas Dilger <adilger.kernel@...ger.ca>
To: Ted Ts'o <tytso@....edu>
Cc: Rogier Wolff <R.E.Wolff@...wizard.nl>,
Amir Goldstein <amir73il@...il.com>,
Ric Wheeler <rwheeler@...hat.com>,
Con Kolivas <kernel@...ivas.org>, linux-ext4@...r.kernel.org
Subject: Re: Regular ext4 error warning with HD in USB dock
On 2011-01-09, at 07:58, Ted Ts'o wrote:
> Defensive programming would be something like
>
> BUG_ON(sizeof(struct ext4_super_block) != 1024);
>
> (unfortunately #error sizeof(struct ext4_super_block) != 1024 won't
> work since #error is handled by the preprocessor, and I don't think we
> can trigger a compile-time warning for a structure size issue).
We actually use a compile-time assertion in the Lustre code:
/*
* 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
* after conversion...
*/
#define CLASSERT(cond) ({ switch(42) { case (cond): case 0: break; } })
Of course, the "cond" expression must be resolvable at compile time, or
it will turn into a compile error because it is not legal to have a
variable "case".
Cheers, Andreas
--
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