[PATCH 1/2] vsh: use virBufferTrim in vshOutputLogFile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 073347a..9dd3ba3 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2086,6 +2086,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))
@@ -2093,10 +2094,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)
-- 
2.4.10

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]