[libvirt] [PATCH 22/23] Replace use of virConfError with virReportError

Daniel P. Berrange berrange at redhat.com
Wed Jul 18 18:40:58 UTC 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

Update the libvirtd config handling code to use virReportError
instead of the virConfError custom macro

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 cfg.mk                   |    1 -
 daemon/libvirtd-config.c |   60 ++++++++++++++++++++++------------------------
 2 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 334a5c5..1ceae3c 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -511,7 +511,6 @@ msg_gen_function += lxcError
 msg_gen_function += regerror
 msg_gen_function += vah_error
 msg_gen_function += vah_warning
-msg_gen_function += virConfError
 msg_gen_function += virGenericReportError
 msg_gen_function += virLibConnError
 msg_gen_function += virLibDomainError
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index 6781e05..2875927 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -35,10 +35,6 @@
 
 #define VIR_FROM_THIS VIR_FROM_CONF
 
-#define virConfError(code, ...)                                      \
-    virReportErrorHelper(VIR_FROM_THIS, code, __FILE__,              \
-                         __FUNCTION__, __LINE__, __VA_ARGS__)
-
 /* Allocate an array of malloc'd strings from the config file, filename
  * (used only in diagnostics), using handle "conf".  Upon error, return -1
  * and free any allocated memory.  Otherwise, save the array in *list_arg
@@ -56,17 +52,17 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
     switch (p->type) {
     case VIR_CONF_STRING:
         if (VIR_ALLOC_N(list, 2) < 0) {
-            virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
-                         _("failed to allocate memory for %s config list"),
-                         key);
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("failed to allocate memory for %s config list"),
+                           key);
             return -1;
         }
         list[0] = strdup (p->str);
         list[1] = NULL;
         if (list[0] == NULL) {
-            virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
-                         _("failed to allocate memory for %s config list value"),
-                         key);
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("failed to allocate memory for %s config list value"),
+                           key);
             VIR_FREE(list);
             return -1;
         }
@@ -78,17 +74,17 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
         for (pp = p->list; pp; pp = pp->next)
             len++;
         if (VIR_ALLOC_N(list, 1+len) < 0) {
-            virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
-                         _("failed to allocate memory for %s config list"),
-                         key);
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("failed to allocate memory for %s config list"),
+                           key);
             return -1;
         }
         for (i = 0, pp = p->list; pp; ++i, pp = pp->next) {
             if (pp->type != VIR_CONF_STRING) {
-                virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
-                             _("remoteReadConfigFile: %s: %s:"
-                               " must be a string or list of strings"),
-                             filename, key);
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("remoteReadConfigFile: %s: %s:"
+                                 " must be a string or list of strings"),
+                               filename, key);
                 VIR_FREE(list);
                 return -1;
             }
@@ -98,9 +94,9 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
                 for (j = 0 ; j < i ; j++)
                     VIR_FREE(list[j]);
                 VIR_FREE(list);
-                virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
-                             _("failed to allocate memory for %s config list value"),
-                             key);
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("failed to allocate memory for %s config list value"),
+                               key);
                 return -1;
             }
 
@@ -110,10 +106,10 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
     }
 
     default:
-        virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
-                     _("remoteReadConfigFile: %s: %s:"
-                       " must be a string or list of strings"),
-                     filename, key);
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("remoteReadConfigFile: %s: %s:"
+                         " must be a string or list of strings"),
+                       filename, key);
         return -1;
     }
 
@@ -127,11 +123,11 @@ checkType (virConfValuePtr p, const char *filename,
            const char *key, virConfType required_type)
 {
     if (p->type != required_type) {
-        virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
-                     _("remoteReadConfigFile: %s: %s: invalid type:"
-                       " got %s; expected %s"), filename, key,
-                     virConfTypeName (p->type),
-                     virConfTypeName (required_type));
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("remoteReadConfigFile: %s: %s: invalid type:"
+                         " got %s; expected %s"), filename, key,
+                       virConfTypeName (p->type),
+                       virConfTypeName (required_type));
         return -1;
     }
     return 0;
@@ -189,9 +185,9 @@ static int remoteConfigGetAuth(virConfPtr conf, const char *key, int *auth, cons
     } else if (STREQ(p->str, "polkit")) {
         *auth = VIR_NET_SERVER_SERVICE_AUTH_POLKIT;
     } else {
-        virConfError(VIR_ERR_CONFIG_UNSUPPORTED,
-                     _("remoteReadConfigFile: %s: %s: unsupported auth %s"),
-                     filename, key, p->str);
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("remoteReadConfigFile: %s: %s: unsupported auth %s"),
+                       filename, key, p->str);
         return -1;
     }
 
-- 
1.7.10.4




More information about the libvir-list mailing list