summaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-02-27 22:06:32 -0700
committerSimon Glass <sjg@chromium.org>2015-04-23 09:05:52 -0600
commit66312374dca86e77fc9b08f774546e62b6cd1aa7 (patch)
tree2a26f0695511a13329ca8469fcadfcf417003f79 /lib/vsprintf.c
parent7f9875e733b79556ade508b88f88ac1f8a2c7e3c (diff)
downloadu-boot-66312374dca86e77fc9b08f774546e62b6cd1aa7.tar.gz
dm: Add a panic_str() function to reduce code size
The printf() in panic() adds about 1.5KB of code size to SPL when compiled with Thumb-2. Provide a smaller version that does not support printf()-style arguments and use it in two commonly compiled places. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index e0f264850f..bedc865240 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -842,13 +842,11 @@ int sprintf(char *buf, const char *fmt, ...)
return i;
}
-void panic(const char *fmt, ...)
+static void panic_finish(void) __attribute__ ((noreturn));
+
+static void panic_finish(void)
{
- va_list args;
- va_start(args, fmt);
- vprintf(fmt, args);
putc('\n');
- va_end(args);
#if defined(CONFIG_PANIC_HANG)
hang();
#else
@@ -859,6 +857,21 @@ void panic(const char *fmt, ...)
;
}
+void panic_str(const char *str)
+{
+ puts(str);
+ panic_finish();
+}
+
+void panic(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+ panic_finish();
+}
+
void __assert_fail(const char *assertion, const char *file, unsigned line,
const char *function)
{