[PATCHv2 07/10] virterror: clean up VIR_ERR_XML_DETAIL usage

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

 



All current callers were supplying arguments, so there was no
way to get to the old int1 approach.  Also, this refactors
virDefaultErrorFunc to allow smaller compilation size.

* src/util/virterror.c (virDefaultErrorFunc): Drop
VIR_ERR_XML_DETAIL special handling.
(virErrorMsg): Unify semantics.
---

This changes existing callers from:

location...: at line 1: xml msg...

to the slightly longer:

location...: parser error: at line 1: xml msg...

I could go with "%s" instead of "parser error" to keep things
unchanged, if desired.

 src/util/virterror.c |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/src/util/virterror.c b/src/util/virterror.c
index 8ec9d97..4c12ba3 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -581,17 +581,11 @@ virDefaultErrorFunc(virErrorPtr err)
     } else if ((err->net != NULL) && (err->code != VIR_ERR_INVALID_NETWORK)) {
         network = err->net->name;
     }
+    fprintf(stderr, "libvir: %s%s %s%s: %s",
+            dom, lvl, domain, network, err->message);
     len = strlen(err->message);
-    if ((err->domain == VIR_FROM_XML) && (err->code == VIR_ERR_XML_DETAIL) &&
-        (err->int1 != 0))
-        fprintf(stderr, "libvir: %s%s %s%s: line %d: %s",
-                dom, lvl, domain, network, err->int1, err->message);
-    else if ((len == 0) || (err->message[len - 1] != '\n'))
-        fprintf(stderr, "libvir: %s%s %s%s: %s\n",
-                dom, lvl, domain, network, err->message);
-    else
-        fprintf(stderr, "libvir: %s%s %s%s: %s",
-                dom, lvl, domain, network, err->message);
+    if ((len == 0) || (err->message[len - 1] != '\n'))
+        fputc('\n', stderr);
 }

 /**
@@ -890,12 +884,7 @@ virErrorMsg(virErrorNumber error, const char *info)
             errmsg = _("failed to write configuration file");
             break;
         case VIR_ERR_XML_DETAIL:
-            /* FIXME: Adjust all callers before unifying semantics.  */
-            if (info == NULL)
-                errmsg = _("parser error");
-            else
-                errmsg = "%s";
-            info = NULL;
+            errmsg = _("parser error");
             break;
         case VIR_ERR_INVALID_NETWORK:
             /* FIXME: Adjust all callers before unifying semantics.  */
-- 
1.7.0.1

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