[U-Boot] [PATCH v3 33/62] tiny-printf: Support assert()

Simon Glass sjg at chromium.org
Mon Jul 4 19:58:13 CEST 2016


At present assert() is not supported with tiny-printf, so when DEBUG is
enabled a build error is generated for each assert().

Add an __assert_fail() function to correct this. It prints a message and
then hangs.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v3: None
Changes in v2: None

 lib/tiny-printf.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 451f4f7..2f32950 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -180,3 +180,12 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
 
 	return ret;
 }
+
+void __assert_fail(const char *assertion, const char *file, unsigned line,
+		   const char *function)
+{
+	/* This will not return */
+	printf("%s:%u: %s: Assertion `%s' failed.", file, line, function,
+	       assertion);
+	hang();
+}
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list