fix(dlog): fix bug in handling of `%*`
The `dlog` function was not handling the `%*` format specifier
correctly.
The bug was caused by passing `va_list` by value instead of by
reference: In a call like `dlog("%*s", 10, "hello")`, the `va_list`
argument would be copied when passed to `parse_min_width`, and `10`
would be popped from the `va_list` to be used as the min_width. But then
`10` would be popped again and used as the `%s` argument, rather than
"hello".
Change-Id: I5c53465384196ee21d2a63167cf82e4f8ead9c3a
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/src/panic.c b/src/panic.c
index 7571d39..cfd9a37 100644
--- a/src/panic.c
+++ b/src/panic.c
@@ -20,13 +20,13 @@
*/
noreturn void panic(const char *fmt, ...)
{
- va_list args;
+ struct va_list_wrapper args;
dlog("Panic: ");
- va_start(args, fmt);
- vdlog(fmt, args);
- va_end(args);
+ va_start(args.va, fmt);
+ vdlog(fmt, &args);
+ va_end(args.va);
dlog("\n");