]> xenbits.xensource.com Git - libvirt.git/commitdiff
Introduce virReportError macro for general error reporting
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 18 Jul 2012 10:23:56 +0000 (11:23 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 18 Jul 2012 13:01:10 +0000 (14:01 +0100)
Nearly every source file does something like

  #define VIR_FROM_THIS VIR_FROM_FOO
  #define virFooReportErorr(code, ...) \
     virReportErrorHelper(VIR_FROM_THIS, code,  __FILE__,    \
                          __FUNCTION__, __LINE__, \
                          __VA_ARGS__)

This creates needless duplication and inconsistent error
reporting function names in each file. It is trivial to
just have virterror_internal.h provide a virReportError
macro that is equivalent

* src/util/virterror_internal.h: Define virReportError(code, ...)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
cfg.mk
src/util/virterror_internal.h

diff --git a/cfg.mk b/cfg.mk
index 6dfe799774545d1b08fc56353f02c8e896f11762..69b2a288d0aaad326eed2377b7bcc9e3cc9ae795 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -560,6 +560,7 @@ msg_gen_function += virNetworkReportError
 msg_gen_function += virNodeDeviceReportError
 msg_gen_function += virNWFilterReportError
 msg_gen_function += virRaiseError
+msg_gen_function += virReportError
 msg_gen_function += virReportErrorHelper
 msg_gen_function += virReportSystemError
 msg_gen_function += virSecretReportError
index cb7df03c52e09d5ce434f5d60b0ec97c80905082..06417b5e108b08ed549485fffa521f208a7fc9b0 100644 (file)
@@ -153,6 +153,9 @@ void virReportOOMErrorFull(int domcode,
 # define virReportOOMError() \
     virReportOOMErrorFull(VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
 
+# define virReportError(code, ...)                                   \
+    virReportErrorHelper(VIR_FROM_THIS, code, __FILE__,              \
+                         __FUNCTION__, __LINE__, __VA_ARGS__)
 
 int virSetError(virErrorPtr newerr);
 void virDispatchError(virConnectPtr conn);