From b4c6fa4418ee89ad52116420461fde5b58919452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 12 Feb 2016 13:49:18 +0100 Subject: [PATCH] vsh: use virBufferTrim in vshOutputLogFile Use virBufferTrim to strip the extra newline at the end of the message instead of open-coding it after the buffer's string is formatted. --- tools/vsh.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 44674451f0..4ce17279bb 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2110,6 +2110,7 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format, } virBufferAsprintf(&buf, "%s ", lvl); virBufferVasprintf(&buf, msg_format, ap); + virBufferTrim(&buf, "\n", -1); virBufferAddChar(&buf, '\n'); if (virBufferError(&buf)) @@ -2117,10 +2118,6 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format, str = virBufferContentAndReset(&buf); len = strlen(str); - if (len > 1 && str[len - 2] == '\n') { - str[len - 1] = '\0'; - len--; - } /* write log */ if (safewrite(ctl->log_fd, str, len) < 0)