diff mbox

[v2,7/12] output: Fix fmtstr return value

Message ID E1fITaI-0000VG-Gw@gondobar (mailing list archive)
State Superseded
Delegated to: Herbert Xu
Headers show

Commit Message

Herbert Xu May 15, 2018, 6:37 a.m. UTC
The function fmtstr is meant to return the actual length of output
produced, rather than the untruncated length.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---

 src/output.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/output.c b/src/output.c
index 4d3b4c2..34243ea 100644
--- a/src/output.c
+++ b/src/output.c
@@ -286,7 +286,7 @@  fmtstr(char *outbuf, size_t length, const char *fmt, ...)
 	va_start(ap, fmt);
 	ret = xvsnprintf(outbuf, length, fmt, ap);
 	va_end(ap);
-	return ret;
+	return ret > (int)length ? length : ret;
 }