aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/compiler.h
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2014-06-04 19:11:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:54:14 -0400
commit2c0d259e0e580dd95dd5d2d5aa4926169228d4a0 (patch)
tree485207a39d1ac910eb07567205bede64c28d8316 /include/linux/compiler.h
parent00f01791e159ba7fb9d397c27d34377206157c6a (diff)
compiler.h: avoid sparse errors in __compiletime_error_fallback()
Usually, BUG_ON and friends aren't even evaluated in sparse, but recently compiletime_assert_atomic_type() was added, and that now results in a sparse warning every time it is used. The reason turns out to be the temporary variable, after it sparse no longer considers the value to be a constant, and results in a warning and an error. The error is the more annoying part of this as it suppresses any further warnings in the same file, hiding other problems. Unfortunately the condition cannot be simply expanded out to avoid the temporary variable since it breaks compiletime_assert on old versions of GCC such as GCC 4.2.4 which the latest metag compiler is based on. Therefore #ifndef __CHECKER__ out the __compiletime_error_fallback which uses the potentially negative size array to trigger a conditional compiler error, so that sparse doesn't see it. Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Johannes Berg <johannes.berg@intel.com> Cc: Daniel Santos <daniel.santos@pobox.com> Cc: Luciano Coelho <luciano.coelho@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r--include/linux/compiler.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index ee7239ea1583..64fdfe1cfcf0 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -323,9 +323,18 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
323#endif 323#endif
324#ifndef __compiletime_error 324#ifndef __compiletime_error
325# define __compiletime_error(message) 325# define __compiletime_error(message)
326# define __compiletime_error_fallback(condition) \ 326/*
327 * Sparse complains of variable sized arrays due to the temporary variable in
328 * __compiletime_assert. Unfortunately we can't just expand it out to make
329 * sparse see a constant array size without breaking compiletime_assert on old
330 * versions of GCC (e.g. 4.2.4), so hide the array from sparse altogether.
331 */
332# ifndef __CHECKER__
333# define __compiletime_error_fallback(condition) \
327 do { ((void)sizeof(char[1 - 2 * condition])); } while (0) 334 do { ((void)sizeof(char[1 - 2 * condition])); } while (0)
328#else 335# endif
336#endif
337#ifndef __compiletime_error_fallback
329# define __compiletime_error_fallback(condition) do { } while (0) 338# define __compiletime_error_fallback(condition) do { } while (0)
330#endif 339#endif
331 340