Subject: + compilerh-dont-use-temporary-variable-in-__compiletime_assert.patch added to -mm tree To: johannes.berg@xxxxxxxxx,daniel.santos@xxxxxxxxx,luciano.coelho@xxxxxxxxx,paulmck@xxxxxxxxxxxxxxxxxx,peterz@xxxxxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Thu, 08 May 2014 13:35:06 -0700 The patch titled Subject: compiler.h: don't use temporary variable in __compiletime_assert() has been added to the -mm tree. Its filename is compilerh-dont-use-temporary-variable-in-__compiletime_assert.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/compilerh-dont-use-temporary-variable-in-__compiletime_assert.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/compilerh-dont-use-temporary-variable-in-__compiletime_assert.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Johannes Berg <johannes.berg@xxxxxxxxx> Subject: compiler.h: don't use temporary variable in __compiletime_assert() 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. Since this is all about compile time and the condition should be side-effect free to start with, there's no downside (apart maybe from a slight compilation time penalty?) to just duplicating it, leaving sparse able to evaluate it at check time, getting rid of the warning and error. Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx> Cc: Daniel Santos <daniel.santos@xxxxxxxxx> Tested-by: Luciano Coelho <luciano.coelho@xxxxxxxxx> Acked-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Acked-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/compiler.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff -puN include/linux/compiler.h~compilerh-dont-use-temporary-variable-in-__compiletime_assert include/linux/compiler.h --- a/include/linux/compiler.h~compilerh-dont-use-temporary-variable-in-__compiletime_assert +++ a/include/linux/compiler.h @@ -331,11 +331,10 @@ void ftrace_likely_update(struct ftrace_ #define __compiletime_assert(condition, msg, prefix, suffix) \ do { \ - bool __cond = !(condition); \ extern void prefix ## suffix(void) __compiletime_error(msg); \ - if (__cond) \ + if (!(condition)) \ prefix ## suffix(); \ - __compiletime_error_fallback(__cond); \ + __compiletime_error_fallback(!(condition)); \ } while (0) #define _compiletime_assert(condition, msg, prefix, suffix) \ _ Patches currently in -mm which might be from johannes.berg@xxxxxxxxx are compilerh-dont-use-temporary-variable-in-__compiletime_assert.patch linux-next.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html