[PATCH v4 03/13] lib: sbi: print not fill '0' when left-aligned

Xiang W wxjstz at 126.com
Thu Jun 8 00:29:53 PDT 2023


Left alignment and padding '0' should not exist at the same time,
this patch is not padded with 0 when left aligned.

Signed-off-by: Xiang W <wxjstz at 126.com>
---
 lib/sbi/sbi_console.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c
index 97ee328..b18f9c5 100644
--- a/lib/sbi/sbi_console.c
+++ b/lib/sbi/sbi_console.c
@@ -288,6 +288,8 @@ static int print(char **out, u32 *out_len, const char *format, va_list args)
 				if (!flags_done)
 					++format;
 			}
+			if (flags & PAD_RIGHT)
+				flags &= ~PAD_ZERO;
 			/* Get width */
 			width = 0;
 			for (; *format >= '0' && *format <= '9'; ++format) {
-- 
2.39.2




More information about the opensbi mailing list