On 05/15/2012 05:30 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Add a VIR_ERR_DOMAIN_LAST sentinel for virErrorDomain and
replace the virErrorDomainName function by a VIR_ENUM_IMPL
In the process the naming of error domains is santized
s/santized/sanitized/
* src/util/virterror.c: Use VIR_ENUM_IMPL for converting
error domains to strings
* include/libvirt/virterror.h: Add VIR_ERR_DOMAIN_LAST
---
include/libvirt/virterror.h | 13 +++
src/util/virterror.c | 219 +++++++++++++------------------------------
2 files changed, 78 insertions(+), 154 deletions(-)
Oh my - I dug through my old branches, and saw that I tried (and failed)
to do this type of cleanup 18 months ago. Your version is cleaner than
my attempt; I like it.
/*
@@ -585,7 +496,7 @@ virDefaultErrorFunc(virErrorPtr err)
lvl = _("error");
break;
}
- dom = virErrorDomainName(err->domain);
+ dom = virErrorDomainTypeToString(err->domain);
You are missing a check for dom==NULL (possible if a newer server sends
an error domain we are not familiar with); you should have a catch-all
case that converts NULL to "Unknown".
ACK with that tweak.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org