diff mbox

[kvm-unit-tests,19/32] lib: added assert_msg macro

Message ID 20170421005004.137260-20-dmatlack@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Matlack April 21, 2017, 12:49 a.m. UTC
From: Peter Feiner <pfeiner@google.com>

Signed-off-by: Peter Feiner <pfeiner@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
---
 lib/libcflat.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Andrew Jones April 21, 2017, 7:18 a.m. UTC | #1
On Thu, Apr 20, 2017 at 05:49:51PM -0700, David Matlack wrote:
> From: Peter Feiner <pfeiner@google.com>
> 
> Signed-off-by: Peter Feiner <pfeiner@google.com>
> Signed-off-by: David Matlack <dmatlack@google.com>
> ---
>  lib/libcflat.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)

Reviewed-by: Andrew Jones <drjones@redhat.com>
diff mbox

Patch

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 1d2eba980e1a..5d356df75f1f 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -126,6 +126,16 @@  do {									\
 	}								\
 } while (0)
 
+#define assert_msg(cond, fmt, args...)					\
+do {									\
+	if (!(cond)) {							\
+		printf("%s:%d: assert failed: %s: " fmt,		\
+		       __FILE__, __LINE__, #cond, ## args);		\
+		dump_stack();						\
+		abort();						\
+	}								\
+} while (0)
+
 static inline bool is_power_of_2(unsigned long n)
 {
 	return n && !(n & (n - 1));