[PATCH 05/13] virsh: Refactor vshError

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

 



The code is moved into a newly introduced generic vshPrintStderr and
vshError changed into a tiny wrapper.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 tools/vsh.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 64507fe560..91e2ae2067 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2111,18 +2111,18 @@ vshTTYMakeRaw(vshControl *ctl G_GNUC_UNUSED,
 }
 
 
-void
-vshError(vshControl *ctl, const char *format, ...)
+static void G_GNUC_PRINTF(3, 0)
+vshPrintStderr(vshControl *ctl,
+               int level,
+               const char *format,
+               va_list ap)
 {
-    va_list ap;
     g_autofree char *str = NULL;
 
-    va_start(ap, format);
     str = g_strdup_vprintf(format, ap);
-    va_end(ap);
 
     if (ctl)
-        vshOutputLogFile(ctl, VSH_ERR_ERROR, str);
+        vshOutputLogFile(ctl, level, str);
 
     /* Most output is to stdout, but if someone ran virsh 2>&1, then
      * printing to stderr will not interleave correctly with stdout
@@ -2133,6 +2133,17 @@ vshError(vshControl *ctl, const char *format, ...)
 }
 
 
+void
+vshError(vshControl *ctl, const char *format, ...)
+{
+    va_list ap;
+
+    va_start(ap, format);
+    vshPrintStderr(ctl, VSH_ERR_ERROR, format, ap);
+    va_end(ap);
+}
+
+
 void
 vshEventLoop(void *opaque)
 {
-- 
2.48.1




[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]

  Powered by Linux