All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] compiler.h: introduce unused_expression() macro
@ 2012-04-25 11:26 Konstantin Khlebnikov
  2012-04-25 11:26 ` [PATCH 2/4] bug: completely remove code of disabled VM_BUG_ON() Konstantin Khlebnikov
                   ` (8 more replies)
  0 siblings, 9 replies; 24+ messages in thread
From: Konstantin Khlebnikov @ 2012-04-25 11:26 UTC (permalink / raw)
  To: Linus Torvalds, linux-kernel; +Cc: linux-arch, Andrew Morton

Sometimes we want to check some expressions correctness in compile-time without
generating extra code. "(void)(e)" does not work if expression has side-effects.
This patch introduces macro unused_expression() which helps in this situation.

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

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
 include/linux/compiler.h |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 923d093..46fbda3 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -310,4 +310,6 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
  */
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
+#define unused_expression(e) ((void)(sizeof((__force long)(e))))
+
 #endif /* __LINUX_COMPILER_H */


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-04-28  7:08 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-25 11:26 [PATCH 1/4] compiler.h: introduce unused_expression() macro Konstantin Khlebnikov
2012-04-25 11:26 ` [PATCH 2/4] bug: completely remove code of disabled VM_BUG_ON() Konstantin Khlebnikov
2012-04-25 14:40   ` Geert Uytterhoeven
2012-04-26 22:32     ` Andrew Morton
2012-04-27  5:17       ` Geert Uytterhoeven
2012-04-27  7:07         ` Andrew Morton
2012-04-25 11:26 ` [PATCH 3/4] bug: completely remove code of disabled BUG_ON() Konstantin Khlebnikov
2012-04-25 11:26 ` [PATCH 4/4] bug: mark disabled BUG() as unreachable() code Konstantin Khlebnikov
2012-04-28  5:10   ` Konstantin Khlebnikov
2012-04-28  5:21     ` Linus Torvalds
2012-04-28  6:14     ` Andrew Morton
2012-04-25 11:51 ` [PATCH 1/4] compiler.h: introduce unused_expression() macro Cong Wang
2012-04-25 11:54   ` Konstantin Khlebnikov
2012-04-26 22:29 ` Andrew Morton
2012-04-27  9:55   ` Konstantin Khlebnikov
2012-04-27 21:53     ` Andrew Morton
2012-04-26 22:34 ` Andrew Morton
2012-04-27  7:54   ` Konstantin Khlebnikov
2012-04-27  8:16 ` H. Peter Anvin
2012-04-28  3:50   ` Konstantin Khlebnikov
2012-04-28  7:06 ` [PATCH v2 1/2] bug: introduce BUILD_BUG_ON_INVALID() macro Konstantin Khlebnikov
2012-04-28  7:06   ` Konstantin Khlebnikov
2012-04-28  7:06 ` [PATCH v2 2/2] bug: completely remove code of disabled VM_BUG_ON() Konstantin Khlebnikov
2012-04-28  7:06   ` Konstantin Khlebnikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.