]> git.karo-electronics.de Git - karo-tx-linux.git/commit
bug: introduce BUILD_BUG_ON_INVALID() macro
authorKonstantin Khlebnikov <khlebnikov@openvz.org>
Thu, 3 May 2012 05:43:51 +0000 (15:43 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 3 May 2012 05:46:30 +0000 (15:46 +1000)
commitb2fdf6527d1a9fb2bb78c6c8e9a64ecc70e4fb65
tree6586e1031a145fca9e4c7b87207bc4235cdc3513
parent2e3ac565a75b6fa433678e726a93ab6eac8a3a55
bug: introduce BUILD_BUG_ON_INVALID() macro

Sometimes we want to check some expressions correctness at compile time.
"(void)(e);" or "if (e);" can be dangerous if the expression has
side-effects, and gcc sometimes generates a lot of code, even if the
expression has no effect.

This patch introduces macro BUILD_BUG_ON_INVALID() for such checks, it
forces a compilation error if expression is invalid without any extra
code.

[Cast to "long" required because sizeof does not work for bit-fields.]

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/bug.h