linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: Jan Beulich <jbeulich@novell.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Ingo Molnar <mingo@elte.hu>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Ivo van Doorn <IvDoorn@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Theodore Tso <tytso@mit.edu>,
	Rusty Russell <rusty@rustcorp.com.au>,
	"John W. Linville" <linville@tuxdriver.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 5/5] debug: BUILD_BUG_ON: error on non-const	 expressions
Date: Tue, 02 Sep 2008 18:19:47 +0300	[thread overview]
Message-ID: <48BD5993.60707@panasas.com> (raw)
In-Reply-To: <48BD0BB5.76E4.0078.0@novell.com>

Jan Beulich wrote:
>>>> Boaz Harrosh <bharrosh@panasas.com> 01.09.08 18:41 >>>
>> Jan Beulich wrote:
>>>>>> Boaz Harrosh <bharrosh@panasas.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
> 

I was able to reproduce your problem now. 

I have made new patchset the final BUILD_BUG_ON_ZERO() I took from you.
But in BUILD_BUG_ON I use a slight variation that satisfies my wishes
and makes BUILD_BUG_ON more like BUG_ON in syntax.

I had to change virtio_has_feature() semantics, though, but I believe it's
not that bad.

Jan maybe you want to put your Signed-off-by: on the last patch?
Please review?

[ I'll post new version of patches that change as reply to the original
 patches ]

Boaz

  reply	other threads:[~2008-09-02 15:21 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-01 13:00 [PATCHSET 0/5] BUILD_BUG_ON: error on none-const expressions Boaz Harrosh
2008-09-01 13:07 ` [PATCH] debug, x86: move BUILD_BUG_ON() ARRAY_SIZE and __FUNCTION__ Boaz Harrosh
2008-09-01 13:11 ` [PATCH 2/5] net/niu: Fix none-const BUILD_BUG_ON usage Boaz Harrosh
2008-09-01 13:13 ` [PATCH 3/5] virtio: " Boaz Harrosh
2008-09-02 15:53   ` [PATCH 3/5 ver2] virtio: Fix non-const " Boaz Harrosh
2008-09-01 13:21 ` [PATCH 4/5] rt2x00: Compiler warning unmasked by fix of BUILD_BUG_ON Boaz Harrosh
2008-09-01 13:27   ` Ivo Van Doorn
2008-09-01 13:27   ` Benny Halevy
2008-09-01 13:44   ` [PATCH 4/5 ver2] " Boaz Harrosh
2008-09-01 14:01     ` Ivo Van Doorn
2008-09-01 15:17       ` Boaz Harrosh
2008-09-01 16:34         ` Ivo van Doorn
2008-09-02 14:20           ` Boaz Harrosh
2008-09-02 14:27             ` Ivo van Doorn
2008-09-02 15:55   ` Boaz Harrosh
2008-09-01 13:28 ` [PATCH 5/5] debug: BUILD_BUG_ON: error on non-const expressions Boaz Harrosh
2008-09-01 13:55   ` Jan Beulich
2008-09-01 14:21     ` Boaz Harrosh
2008-09-01 14:36       ` Jan Beulich
2008-09-01 15:00         ` Boaz Harrosh
2008-09-01 15:29           ` Jan Beulich
2008-09-01 16:41             ` Boaz Harrosh
2008-09-02  7:47               ` Jan Beulich
2008-09-02 15:19                 ` Boaz Harrosh [this message]
2008-09-02 15:57   ` [PATCH 5/5 ver2] " Boaz Harrosh
2008-09-02 16:06     ` Boaz Harrosh
2008-09-02 16:11     ` Jan Beulich
2008-09-03  8:57       ` Boaz Harrosh
2008-09-03 10:19         ` Jan Beulich
2008-09-03 10:52           ` Boaz Harrosh
2008-10-02  5:35     ` Rusty Russell
2008-10-05  9:34       ` Boaz Harrosh
2008-09-02 16:07   ` [PATCH 5/5 ver3] " Boaz Harrosh
2008-09-06 16:01 ` [PATCHSET 0/5] BUILD_BUG_ON: error on none-const expressions Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48BD5993.60707@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=IvDoorn@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).