]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
tools: Provide a definition of WARN_ON
authorMatthew Wilcox <mawilcox@microsoft.com>
Mon, 19 Dec 2016 16:07:17 +0000 (11:07 -0500)
committerMatthew Wilcox <mawilcox@microsoft.com>
Sat, 28 Jan 2017 02:29:39 +0000 (21:29 -0500)
The definition of WARN_ON being used by the radix tree test suite was
deficient in two ways: it did not provide a return value, and it stopped
execution instead of continuing.  This version of WARN_ON tells you
which file & line the assertion was triggered in.

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
tools/include/asm/bug.h
tools/testing/radix-tree/linux/kernel.h

index beda1a884b50f0465ace7e3f01ca6014e5d3e755..4790f047a89c476624975d51514698f210900a19 100644 (file)
        unlikely(__ret_warn_on);                \
 })
 
+#define WARN_ON(condition) ({                                  \
+       int __ret_warn_on = !!(condition);                      \
+       if (unlikely(__ret_warn_on))                            \
+               __WARN_printf("assertion failed at %s:%d\n",    \
+                               __FILE__, __LINE__);            \
+       unlikely(__ret_warn_on);                                \
+})
+
 #define WARN_ON_ONCE(condition) ({                     \
        static int __warned;                            \
        int __ret_warn_once = !!(condition);            \
index 1cd72a84a089fad259d78c81376953cd71678fb1..9681463c91e218f6836f58268ca37ab6d76507fa 100644 (file)
@@ -24,7 +24,6 @@
 #endif
 
 #define BUG_ON(expr)   assert(!(expr))
-#define WARN_ON(expr)  assert(!(expr))
 #define __init
 #define __must_check
 #define panic(expr)