diff options
author | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2018-11-08 14:08:09 +0100 |
---|---|---|
committer | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2018-12-13 16:07:05 +0100 |
commit | 411a6b26f73dfb85143603cdad09588b8e159b04 (patch) | |
tree | 7180fb4a857cad8d75b1759e75910c68e3d8e84c /lib | |
parent | 6826138602bcdb8985bde0fa6295cb47f7174e3a (diff) |
Use vprintf() inside mp_printf()
This avoid making an extra copy of the string buffer.
Change-Id: Idd5d25741abed2a125669e0994f0a0f3e1f8ed4c
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/mp_printf.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/utils/mp_printf.c b/lib/utils/mp_printf.c index d1eb780..27a93ac 100644 --- a/lib/utils/mp_printf.c +++ b/lib/utils/mp_printf.c @@ -35,8 +35,6 @@ static spinlock_t printf_lock; void mp_printf(const char *fmt, ...) { - va_list ap; - char str[256]; /* * As part of testing Firmware Update feature on Cortex-A57 CPU, an * issue was discovered while printing in NS_BL1U stage. The issue @@ -53,20 +51,13 @@ void mp_printf(const char *fmt, ...) */ volatile unsigned int mpid = read_mpidr_el1() & 0xFFFF; - /* - * TODO: It would be simpler to use vprintf() instead of - * vsnprintf() + printf(), we wouldn't need to declare a static buffer - * for storing the product of vsnprintf(). Unfortunately our C library - * doesn't provide vprintf() at the moment. - * Import vprintf() code from FreeBSD C library to our local C library. - */ + va_list ap; va_start(ap, fmt); - vsnprintf(str, sizeof(str), fmt, ap); - str[sizeof(str) - 1] = 0; - va_end(ap); spin_lock(&printf_lock); PRINT_MPID_HDR(mpid); - printf("%s", str); + vprintf(fmt, ap); spin_unlock(&printf_lock); + + va_end(ap); } |