diff options
author | Heyi Guo <guoheyi@linux.alibaba.com> | 2020-10-27 08:36:40 +0800 |
---|---|---|
committer | Heyi Guo <guoheyi@linux.alibaba.com> | 2021-01-20 14:15:55 +0800 |
commit | c654615466465526290ea0b0ba909b5a010b8bef (patch) | |
tree | de248c54cb97b5c83bdfb101ff7a130bf78bca73 /lib | |
parent | 128c5f02859579ce15df18c5d443565778b2d3bf (diff) | |
download | arm-trusted-firmware-c654615466465526290ea0b0ba909b5a010b8bef.tar.gz |
libc/snprintf: add support to print "%" character
Enable snprintf()/vsnprintf() in TF-A to print "%" character as C
standard, which may be used in platform porting to print percentage
information.
Signed-off-by: Heyi Guo <guoheyi@linux.alibaba.com>
Change-Id: I9b296372a1002046eabac1df5e8eb99a27efd4a8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/snprintf.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libc/snprintf.c b/lib/libc/snprintf.c index 6e80d8c03..42faa269d 100644 --- a/lib/libc/snprintf.c +++ b/lib/libc/snprintf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -130,6 +130,13 @@ int vsnprintf(char *s, size_t n, const char *fmt, va_list args) /* Check the format specifier. */ loop: switch (*fmt) { + case '%': + if (chars_printed < n) { + *s = '%'; + s++; + } + chars_printed++; + break; case '0': case '1': case '2': |