lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48BE5163.2090101@panasas.com>
Date:	Wed, 03 Sep 2008 11:57:07 +0300
From:	Boaz Harrosh <bharrosh@...asas.com>
To:	Jan Beulich <jbeulich@...ell.com>
CC:	"David S. Miller" <davem@...emloft.net>,
	Ingo Molnar <mingo@...e.hu>, Ivo van Doorn <IvDoorn@...il.com>,
	Rusty Russell <rusty@...tcorp.com.au>,
	"John W. Linville" <linville@...driver.com>,
	Alexey Dobriyan <adobriyan@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Theodore Tso <tytso@....edu>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/5 ver2] debug: BUILD_BUG_ON: error on non-const	 expressions

Jan Beulich wrote:
>>>> Boaz Harrosh <bharrosh@...asas.com> 02.09.08 17:57 >>>
>> -#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
>> +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
>> +
>> +/* Force a compilation error if condition is true */
>> +#define BUILD_BUG_ON(e) \
>> +	do { struct {int:-!!(e); } x __maybe_unused;} while(0)
>  
> As indicated before, you should at the very least use __x as the variable
> name.
> 

The name does not matter. The scope of x is confined to the do {} while()
and will not interfere with any local or global name.  

> But didn't you have reservations against using a bitfield here? Or was it
> really just the void cast on the sizeof() that you disliked?
> 

I like it it's fine. Also an added bonus is that on the good case it compiles
to a size-less structure in a code-less block so even the most stupid 
non-optimizing compiler will get it right. OK that could be done with 0-length
array too. But for consistency's sake I like it that both macros are the same.

> Jan
> 

I would like it if you sent your Signed-off-by: (or something) on this patch.
Thanks for your help
Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ