Commit c6546154 authored by Heyi Guo's avatar Heyi Guo
Browse files

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: default avatarHeyi Guo <guoheyi@linux.alibaba.com>
Change-Id: I9b296372a1002046eabac1df5e8eb99a27efd4a8
parent 128c5f02
/* /*
* 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 * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -130,6 +130,13 @@ int vsnprintf(char *s, size_t n, const char *fmt, va_list args) ...@@ -130,6 +130,13 @@ int vsnprintf(char *s, size_t n, const char *fmt, va_list args)
/* Check the format specifier. */ /* Check the format specifier. */
loop: loop:
switch (*fmt) { switch (*fmt) {
case '%':
if (chars_printed < n) {
*s = '%';
s++;
}
chars_printed++;
break;
case '0': case '0':
case '1': case '1':
case '2': case '2':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment