[libvirt] [PATCHv2 6/6] error: drop old-style error reporting

2012-01-19 Thread Eric Blake
While we still don't want to enable gcc's new -Wformat-literal
warning, I found a rather easy case where the warning could be
reduced, by getting rid of obsolete error-reporting practices.
This is the last place where we were passing the (unused) net
and conn arguments for constructing an error.

* src/util/virterror_internal.h (virErrorMsg): Delete prototype.
(virReportError): Delete macro.
* src/util/virterror.c (virErrorMsg): Make static.
* src/libvirt_private.syms (virterror_internal.h): Drop export.
* src/util/conf.c (virConfError): Convert to macro.
(virConfErrorHelper): New function, and adjust error calls.
* src/xen/xen_hypervisor.c (virXenErrorFunc): Delete.
(xenHypervisorGetSchedulerType)
(xenHypervisorGetSchedulerParameters)
(xenHypervisorSetSchedulerParameters)
(xenHypervisorDomainBlockStats)
(xenHypervisorDomainInterfaceStats)
(xenHypervisorDomainGetOSType)
(xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus):
Update callers.
---
 src/libvirt_private.syms  |1 -
 src/util/conf.c   |   22 ++---
 src/util/virterror.c  |2 +-
 src/util/virterror_internal.h |8 --
 src/xen/xen_hypervisor.c  |  164 
 5 files changed, 76 insertions(+), 121 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9a7200b..f8d97d1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1387,7 +1387,6 @@ virSocketAddrSetPort;

 # virterror_internal.h
 virDispatchError;
-virErrorMsg;
 virRaiseErrorFull;
 virReportErrorHelper;
 virReportOOMErrorFull;
diff --git a/src/util/conf.c b/src/util/conf.c
index 502dafb..8ad60e0 100644
--- a/src/util/conf.c
+++ b/src/util/conf.c
@@ -89,27 +89,23 @@ struct _virConf {
  *
  * Handle an error at the xend daemon interface
  */
+#define virConfError(ctxt, error, info) \
+virConfErrorHelper(__FILE__, __FUNCTION__, __LINE__, ctxt, error, info)
 static void
-virConfError(virConfParserCtxtPtr ctxt,
- virErrorNumber error, const char *info)
+virConfErrorHelper(const char *file, const char *func, size_t line,
+   virConfParserCtxtPtr ctxt,
+   virErrorNumber error, const char *info)
 {
-const char *format;
-
 if (error == VIR_ERR_OK)
 return;

 /* Construct the string 'filename:line: info' if we have that. */
 if (ctxt  ctxt-filename) {
-virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
-info, ctxt-filename, NULL,
-ctxt-line, 0,
-%s:%d: %s, ctxt-filename, ctxt-line, info);
+virReportErrorHelper(VIR_FROM_CONF, error, file, func, line,
+ _(%s:%d: %s), ctxt-filename, ctxt-line, info);
 } else {
-format = virErrorMsg(error, info);
-virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
-info, NULL, NULL,
-ctxt ? ctxt-line : 0, 0,
-format, info);
+virReportErrorHelper(VIR_FROM_CONF, error, file, func, line,
+ %s, info);
 }
 }

diff --git a/src/util/virterror.c b/src/util/virterror.c
index 8205516..ff44a57 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -756,7 +756,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
  *
  * Returns the constant string associated to @error
  */
-const char *
+static const char *
 virErrorMsg(virErrorNumber error, const char *info)
 {
 const char *errmsg = NULL;
diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h
index d61ea0d..b8cb279 100644
--- a/src/util/virterror_internal.h
+++ b/src/util/virterror_internal.h
@@ -47,14 +47,6 @@ void virRaiseErrorFull(const char *filename,
const char *fmt, ...)
 ATTRIBUTE_FMT_PRINTF(12, 13);

-/* Includes 'dom' and 'net' for compatbility, but they're ignored */
-# define virRaiseError(dom, net, domain, code, level,  \
-  str1, str2, str3, int1, int2, msg, ...)   \
-virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__,   \
-  domain, code, level, str1, str2, str3, int1, int2, \
-  msg, __VA_ARGS__)
-
-const char *virErrorMsg(virErrorNumber error, const char *info);
 void virReportErrorHelper(int domcode, int errcode,
   const char *filename,
   const char *funcname,
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 0c92be8..2bb3466 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -880,40 +880,6 @@ struct xenUnifiedDriver xenHypervisorDriver = {
  __FUNCTION__, __LINE__, __VA_ARGS__)

 /**
- * virXenErrorFunc:
- * @error: the error number
- * @func: the function failing
- * @info: extra information string
- * @value: extra information number
- *
- * Handle an error at the xend 

Re: [libvirt] [PATCHv2 6/6] error: drop old-style error reporting

2012-01-19 Thread Daniel P. Berrange
On Thu, Jan 19, 2012 at 11:44:46AM -0700, Eric Blake wrote:
 While we still don't want to enable gcc's new -Wformat-literal
 warning, I found a rather easy case where the warning could be
 reduced, by getting rid of obsolete error-reporting practices.
 This is the last place where we were passing the (unused) net
 and conn arguments for constructing an error.
 
 * src/util/virterror_internal.h (virErrorMsg): Delete prototype.
 (virReportError): Delete macro.
 * src/util/virterror.c (virErrorMsg): Make static.
 * src/libvirt_private.syms (virterror_internal.h): Drop export.
 * src/util/conf.c (virConfError): Convert to macro.
 (virConfErrorHelper): New function, and adjust error calls.
 * src/xen/xen_hypervisor.c (virXenErrorFunc): Delete.
 (xenHypervisorGetSchedulerType)
 (xenHypervisorGetSchedulerParameters)
 (xenHypervisorSetSchedulerParameters)
 (xenHypervisorDomainBlockStats)
 (xenHypervisorDomainInterfaceStats)
 (xenHypervisorDomainGetOSType)
 (xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus):
 Update callers.
 ---
  src/libvirt_private.syms  |1 -
  src/util/conf.c   |   22 ++---
  src/util/virterror.c  |2 +-
  src/util/virterror_internal.h |8 --
  src/xen/xen_hypervisor.c  |  164 
  5 files changed, 76 insertions(+), 121 deletions(-)

ACK, I didn't realize we still had code using this.

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list