Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1593618
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/6] bug: Improve unlikely() in data corruption check |
| Date | 2017-03-06 20:20 +0100 |
| Message-ID | <ti6kN-4hd-17@gated-at.bofh.it> (permalink) |
| References | <ti6kN-4hd-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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(-)
diff --git a/include/linux/bug.h b/include/linux/bug.h
index 5828489309bb..5ef65dc2ed8b 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -129,15 +129,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 */
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/6] bug: further enhance use of BUG_ON_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100 [PATCH 4/6] bug: Enable DEBUG_SG under BUG_ON_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100 [PATCH 5/6] notifiers: Use CHECK_DATA_CORRUPTION() on checks Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100 [PATCH 3/6] bug: Enable DEBUG_CREDENTIALS under BUG_ON_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100 [PATCH 1/6] bug: Clarify help text for BUG_ON_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100 [PATCH 2/6] bug: Improve unlikely() in data corruption check Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100 [PATCH 6/6] refcount: Check bad states with CHECK_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100
csiph-web