All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
To: u-boot@lists.denx.de
Subject: [PATCH 5/5] common/log.c: use vscnprintf() in log_dispatch()
Date: Thu, 20 May 2021 12:05:28 +0200	[thread overview]
Message-ID: <20210520100528.322846-6-rasmus.villemoes@prevas.dk> (raw)
In-Reply-To: <20210520100528.322846-1-rasmus.villemoes@prevas.dk>

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@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

  parent reply	other threads:[~2021-05-20 10:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 10:05 [PATCH 0/5] assorted printf-related patches Rasmus Villemoes
2021-05-20 10:05 ` [PATCH 1/5] lib/vsprintf.c: make sure vsnprintf() never returns a negative value Rasmus Villemoes
2021-05-20 17:51   ` Simon Glass
2021-05-21 12:53     ` Rasmus Villemoes
2021-05-21 14:15       ` Heinrich Schuchardt
2021-05-21 14:27         ` Tom Rini
2021-05-21 14:42           ` Heinrich Schuchardt
2021-05-27 23:01             ` Rasmus Villemoes
2021-06-19 17:32               ` Simon Glass
2021-05-21 14:40         ` Rasmus Villemoes
2021-05-21 15:43           ` Heinrich Schuchardt
2021-05-21 14:48         ` Sean Anderson
2021-05-20 10:05 ` [PATCH 2/5] lib/vsprintf.c: implement printf() in terms of vprintf() Rasmus Villemoes
2021-05-20 17:51   ` Simon Glass
2021-05-20 10:05 ` [PATCH 3/5] lib/vsprintf.c: remove stale comment Rasmus Villemoes
2021-05-20 17:51   ` Simon Glass
2021-05-21 14:22   ` Heinrich Schuchardt
2021-05-20 10:05 ` [PATCH 4/5] lib/vsprintf.c: remove unused ip6_addr_string() Rasmus Villemoes
2021-05-20 17:51   ` Simon Glass
2021-05-21 14:32   ` Heinrich Schuchardt
2021-05-20 10:05 ` Rasmus Villemoes [this message]
2021-05-20 17:51   ` [PATCH 5/5] common/log.c: use vscnprintf() in log_dispatch() Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210520100528.322846-6-rasmus.villemoes@prevas.dk \
    --to=rasmus.villemoes@prevas.dk \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.