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: <48BD0BB5.76E4.0078.0@novell.com>
Date:	Tue, 02 Sep 2008 08:47:33 +0100
From:	"Jan Beulich" <jbeulich@...ell.com>
To:	"Boaz Harrosh" <bharrosh@...asas.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

>>> Boaz Harrosh <bharrosh@...asas.com> 01.09.08 18:41 >>>
>Jan Beulich wrote:
>>>>> Boaz Harrosh <bharrosh@...asas.com> 01.09.08 17:00 >>>
>>> 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).
>> 
>> That's the problem - it uses the same sizeof(char[]) approach, and hence
>> has the same problems that you just try to fix for BUILD_BUG_ON().
>> 
>
>No it does not have this problem. Have you tested it? 
>I have! It works fine. (Complains on non-const expressions)

For static variables, yes. But not for automatic variables and the like:

#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)

int test(int i) {
	int x = BUILD_BUG_ON_ZERO(i);

	return x;
}

You could argue that I could place a simple BUILD_BUG_ON() later in
the code, but that easily defeats the documentation purposes the
construct also has (my general position on this is that the check should
be in or immediately before the statement that depends on the
enforced restriction).

Jan

--
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