[PATCH 01/13] Introduce virReportError macro for general error reporting

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 cfg.mk                        |    1 +
 src/util/virterror_internal.h |    3 +++
 2 files changed, 4 insertions(+)

diff --git a/cfg.mk b/cfg.mk
index 6dfe799..69b2a28 100644
--- 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
diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h
index cb7df03..06417b5 100644
--- a/src/util/virterror_internal.h
+++ b/src/util/virterror_internal.h
@@ -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);
-- 
1.7.10.4

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