[PATCH 5/5] common/log.c: use vscnprintf() in log_dispatch()

Rasmus Villemoes rasmus.villemoes at prevas.dk
Thu May 20 12:05:28 CEST 2021


We have to use the *printf variant which returns the strlen() of the
resulting string, not the
how-much-would-have-been-printed-given-enough-space, in order to use
that value to inspect the last character in the string.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
---
 common/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/log.c b/common/log.c
index ea407c6db9..cba8df5caa 100644
--- a/common/log.c
+++ b/common/log.c
@@ -220,7 +220,7 @@ static int log_dispatch(struct log_rec *rec, const char *fmt, va_list args)
 			if (!rec->msg) {
 				int len;
 
-				len = vsnprintf(buf, sizeof(buf), fmt, args);
+				len = vscnprintf(buf, sizeof(buf), fmt, args);
 				rec->msg = buf;
 				gd->log_cont = len && buf[len - 1] != '\n';
 			}
-- 
2.29.2



More information about the U-Boot mailing list