@@ -130,15 +130,15 @@ static inline enum bug_trap_type report_bug(unsigned long bug_addr,
static inline __must_check bool check_data_corruption(bool v) { return v; }
#define CHECK_DATA_CORRUPTION(condition, fmt, ...) \
check_data_corruption(({ \
- bool corruption = unlikely(condition); \
- if (corruption) { \
+ bool corruption = !!(condition); \
+ if (unlikely(corruption)) { \
if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
pr_err(fmt, ##__VA_ARGS__); \
BUG(); \
} else \
WARN(1, fmt, ##__VA_ARGS__); \
} \
- corruption; \
+ unlikely(corruption); \
}))
#endif /* _LINUX_BUG_H */
This improves the compiler branch-hinting used in CHECK_DATA_CORRUPTION(), similar to how it is done in WARN_ON() and friends. Signed-off-by: Kees Cook <keescook@chromium.org> --- include/linux/bug.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)