[PATCH 13/19] include: <asm-generic/bug.h>: implement ASSERT()

Sascha Hauer s.hauer at pengutronix.de
Thu Jan 4 06:17:40 PST 2024


ASSERT() is a statement commonly used by other projects. This patch adds
an implementation for it.

It is normally compiled away and can be enabled with
CONFIG_BUG_ON_DATA_CORRUPTION.

While ASSERT() is usually written in lowercase letters, use uppercase
letters for barebox as we have a function hook in the reset controller
core that uses lowercase letters.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 include/asm-generic/bug.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 5d0a458eae..18a1b419ff 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -62,4 +62,9 @@
 	unlikely(__ret_warn_once);			\
 })
 
+#define ASSERT(expr)  do {				\
+	if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION))	\
+		BUG_ON(!(expr));			\
+} while (0)
+
 #endif
-- 
2.39.2




More information about the barebox mailing list