|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] xen: Rework WARN_ON() to return whether a warning was triggered
From: Julien Grall <jgrall@xxxxxxxxxx>
So far, our implementation of WARN_ON() cannot be used in the following
situation:
if ( WARN_ON() )
...
This is because the WARN_ON() doesn't return whether a warning. Such
construction can be handy to have if you have to print more information
and now the stack track.
Rework the WARN_ON() implementation to return whether a warning was
triggered. The idea was borrowed from Linux.
Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
---
This will be used in the SMMUv3 driver (see [1]).
---
xen/include/xen/lib.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index a9679c913d5c..d10c68aa3c07 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -23,7 +23,13 @@
#include <asm/bug.h>
#define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0)
-#define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0)
+#define WARN_ON(p) ({ \
+ bool __ret_warn_on = (p); \
+ \
+ if ( unlikely(__ret_warn_on) ) \
+ WARN(); \
+ unlikely(__ret_warn_on); \
+})
/* All clang versions supported by Xen have _Static_assert. */
#if defined(__clang__) || \
--
2.17.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |