[lkml]   [2018]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[RFC 18/60] sched: Fix return value of SCHED_WARN_ON()
SCHED_WARN_ON() is conditionally compiled depending on CONFIG_SCHED_DEBUG.
WARN_ON() and variants can be used in if() statements to take an action
in the unlikely case that the WARN_ON condition is true. This is supposed
to work independently of whether the warning is actually printed. However,
without CONFIG_SCHED_DEBUG, SCHED_WARN_ON() evaluates to false

Change SCHED_WARN_ON() to not discard the WARN_ON condition, even without
CONFIG_SCHED_DEBUG, so that it can be used within if() statements as

Signed-off-by: Jan H. Schönherr <>
kernel/sched/sched.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 9ecbb57049a2..3e0ad36938fb 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -76,7 +76,7 @@
# define SCHED_WARN_ON(x) WARN_ONCE(x, #x)
-# define SCHED_WARN_ON(x) ({ (void)(x), 0; })
+# define SCHED_WARN_ON(x) ({ unlikely(!!(x)); })

struct rq;
 \ /
  Last update: 2018-09-07 23:47    [W:0.382 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site