[libvirt] [PATCH 02/10] util: error: Fix error message strings to play well with additional info

Peter Krempa pkrempa at redhat.com
Wed Dec 5 16:47:43 UTC 2018


Additional information for a string is always in form of a string or
empty. Fix two offenders. One used %d as format modifier and second
always expected a string. Both are thankfully unused currently.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virerror.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/util/virerror.c b/src/util/virerror.c
index eca6ddf7d1..5d515bde57 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -977,7 +977,10 @@ virErrorMsg(virErrorNumber error, const char *info)
                 errmsg = _("POST operation failed");
             break;
         case VIR_ERR_HTTP_ERROR:
-            errmsg = _("got unknown HTTP error code %d");
+            if (info != NULL)
+                errmsg = _("got unknown HTTP error code %s");
+            else
+                errmsg = _("got unknown HTTP error code");
             break;
         case VIR_ERR_UNKNOWN_HOST:
             if (info != NULL)
@@ -1004,7 +1007,10 @@ virErrorMsg(virErrorNumber error, const char *info)
                 errmsg = _("could not connect to Xen Store %s");
             break;
         case VIR_ERR_XEN_CALL:
-            errmsg = _("failed Xen syscall %s");
+            if (info == NULL)
+                errmsg = _("failed Xen syscall");
+            else
+                errmsg = _("failed Xen syscall %s");
             break;
         case VIR_ERR_OS_TYPE:
             if (info == NULL)
-- 
2.19.2




More information about the libvir-list mailing list