[tip: locking/kcsan] compiler.h: Avoid nested statement expression in data_race()
From: tip-bot2 for Marco Elver
Date: Fri May 22 2020 - 12:09:05 EST
The following commit has been merged into the locking/kcsan branch of tip:
Commit-ID: aa7d8a2ee1e9b80e36ce2aa0d817c14ab3e23157
Gitweb: https://git.kernel.org/tip/aa7d8a2ee1e9b80e36ce2aa0d817c14ab3e23157
Author: Marco Elver <elver@xxxxxxxxxx>
AuthorDate: Thu, 21 May 2020 16:20:45 +02:00
Committer: Borislav Petkov <bp@xxxxxxx>
CommitterDate: Fri, 22 May 2020 15:24:21 +02:00
compiler.h: Avoid nested statement expression in data_race()
It appears that compilers have trouble with nested statement
expressions. Therefore, remove one level of statement expression nesting
from the data_race() macro. This will help avoiding potential problems
in the future as its usage increases.
Reported-by: Borislav Petkov <bp@xxxxxxx>
Reported-by: Nathan Chancellor <natechancellor@xxxxxxxxx>
Signed-off-by: Marco Elver <elver@xxxxxxxxxx>
Signed-off-by: Borislav Petkov <bp@xxxxxxx>
Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Acked-by: Will Deacon <will@xxxxxxxxxx>
Tested-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
Link: https://lkml.kernel.org/r/20200520221712.GA21166@xxxxxxx
Link: https://lkml.kernel.org/r/20200521142047.169334-10-elver@xxxxxxxxxx
---
include/linux/compiler.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 7444f02..379a507 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -211,12 +211,12 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
*/
#define data_race(expr) \
({ \
- __kcsan_disable_current(); \
- ({ \
- __unqual_scalar_typeof(({ expr; })) __v = ({ expr; }); \
- __kcsan_enable_current(); \
- __v; \
+ __unqual_scalar_typeof(({ expr; })) __v = ({ \
+ __kcsan_disable_current(); \
+ expr; \
}); \
+ __kcsan_enable_current(); \
+ __v; \
})
/*