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]
Date:	Mon, 01 Sep 2008 18:00:15 +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>,
	Alexey Dobriyan <adobriyan@...il.com>,
	Ivo van Doorn <IvDoorn@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Theodore Tso <tytso@....edu>,
	Rusty Russell <rusty@...tcorp.com.au>,
	"John W. Linville" <linville@...driver.com>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/5] debug: BUILD_BUG_ON: error on non-const		 expressions

Jan Beulich wrote:
>>>> Boaz Harrosh <bharrosh@...asas.com> 01.09.08 16:21 >>>
>>> I have to admit that I'm surprise this compiles: You replace an expression
>>> with a statement, and hence you reduce the places where BUILD_BUG_ON()
>>> can validly be used. 
>> it is only an expression because of the (void)() cast, which is what
>> I'm trying to avoid.
> 
> No, sizeof() alone is an expression, too. 

Using only sizeof() produces tons of "expression has no effect" warning
all over the place.

> Also, by using a statement you'll
> have more problems with fixing BUILD_BUG_ON_ZERO(), which must be
> an expression.
> 

What is broken with my BUILD_BUG_ON_ZERO(). I tried all tests and
it works fine. Do you have a test with unwanted results?
(Actually it's the original one I have not touched it).

>>> Of course you could wrap the whole thing in ({}),
>> "do{}while(0)" is effectively an "{}" plus the added bonus
>> of demanding an ";" ;-)
> 
> An expression likewise demands a terminating ; (or a continuation of the
> expression, i.e. by using an operator)
> 

I was not criticizing your approach, I was commenting on:
"{}" vs. do{}while(0) 

>>> Also, are you sure the compiler will eliminate the dead variable in all
>>> cases?
>>>
>>> Finally, using as common a variable as 'x' here seems dangerous, too:
>>> What if somewhere x is #define-d to something more complex than a
>>> simple identifier?
>> No it is scoped in a dead do{}while(0). What gets optimized out most
>> is the do nothing do{}while(0). The inside is just ignored.
> 
> I don't think compilers in general and gcc in particular work this way
> (i.e. automatically throwing away everything included in a dead block).
> 

I've tested and nothing is produced, even without any optimization.
But I'm not an expert.

> Jan
> 

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