2010/2/15 Daniel Veillard <veillard@xxxxxxxxxx>: > On Sun, Feb 14, 2010 at 11:29:20PM +0100, Matthias Bolte wrote: >> --- >> src/security/security_driver.c | 18 ------------------ >> src/security/security_driver.h | 6 +++--- >> 2 files changed, 3 insertions(+), 21 deletions(-) >> >> diff --git a/src/security/security_driver.c b/src/security/security_driver.c >> index 27945a6..4c98190 100644 >> --- a/src/security/security_driver.c >> +++ b/src/security/security_driver.c >> @@ -90,24 +90,6 @@ virSecurityDriverStartup(virSecurityDriverPtr *drv, >> return -2; >> } >> >> -void >> -virSecurityReportError(int code, const char *fmt, ...) >> -{ >> - va_list args; >> - char errorMessage[1024]; >> - >> - if (fmt) { >> - va_start(args, fmt); >> - vsnprintf(errorMessage, sizeof(errorMessage) - 1, fmt, args); >> - va_end(args); >> - } else >> - errorMessage[0] = '\0'; >> - >> - virRaiseError(NULL, NULL, NULL, VIR_FROM_SECURITY, code, >> - VIR_ERR_ERROR, NULL, NULL, NULL, -1, -1, "%s", >> - errorMessage); >> -} >> - >> /* >> * Helpers >> */ >> diff --git a/src/security/security_driver.h b/src/security/security_driver.h >> index 8860d81..15671b3 100644 >> --- a/src/security/security_driver.h >> +++ b/src/security/security_driver.h >> @@ -88,9 +88,9 @@ int virSecurityDriverStartup(virSecurityDriverPtr *drv, >> int >> virSecurityDriverVerify(virDomainDefPtr def); >> >> -void >> -virSecurityReportError(int code, const char *fmt, ...) >> - ATTRIBUTE_FMT_PRINTF(2, 3); >> +#define virSecurityReportError(code, fmt...) \ >> + virReportErrorHelper(NULL, VIR_FROM_SECURITY, code, __FILE__, \ >> + __FUNCTION__, __LINE__, fmt) >> >> /* Helpers */ >> void virSecurityDriverInit(virSecurityDriverPtr drv); > > ACK, but ultimately a macro end up inflating generated code, which > might not be ideal especially for something which is very unfrequently > used at runtime. So I'm wondering a bit about the goal here > > Daniel > The goal here is to unify and improve the error reporting. The typical pattern is a macro that includes the error domain and the __FILE__, __FUNCTION__ and __LINE__ stuff. Basically the new macro does the same as the old function, but via virReportErrorHelper. Having __FILE__, __FUNCTION__ and __LINE__ in the virSecurityReportError macro results in correct values for those. With the old function virRaiseError expanded to virRaiseErrorFull and included the __FILE__, __FUNCTION__ and __LINE__ info from within the virSecurityReportError function, rendering this information useless, because they were always the same for every call to virSecurityReportError. I should have included this into the commit message. I'll do that before pushing it. Matthias -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list