On 7/10/19 2:02 AM, Peter Krempa wrote: > On Tue, Jul 09, 2019 at 12:46:30 -0500, Eric Blake wrote: >> Even though we don't accept any flags, it is unfriendly to callers >> that use the modern API to have to fall back to the flag-free API. >> >> Signed-off-by: Eric Blake <ebl...@redhat.com> >> --- >> src/vbox/vbox_common.c | 24 ++++++++++++++++++++++-- >> 1 file changed, 22 insertions(+), 2 deletions(-) >> >> diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c >> index 54e31bec9d..44c98cadf6 100644 >> --- a/src/vbox/vbox_common.c >> +++ b/src/vbox/vbox_common.c >> @@ -553,7 +553,8 @@ static int vboxConnectClose(virConnectPtr conn) >> } >> >> static int >> -vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) >> +vboxDomainSaveFlags(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED, >> + const char *dxml, unsigned int flags) >> { >> vboxDriverPtr data = dom->conn->privateData; >> IConsole *console = NULL; >> @@ -564,6 +565,9 @@ vboxDomainSave(virDomainPtr dom, const char *path >> ATTRIBUTE_UNUSED) >> nsresult rc; >> int ret = -1; >> >> + virCheckFlags(0, -1); >> + virCheckNonNullArgReturn(dxml, -1); > > This reports: invalid argument: dxml in vboxDomainSave must not be NULL > > I'm not certain that the internal function name makes sense to external > users.
In which case I can hand-roll a more specific error instead of reusing the common macro. But I do see pre-existing uses of virCheckNonNullArgXXX in src/esx and src/vz prior to this patch, so it's not the first time we've used the common macros. > >> + >> if (!data->vboxObj) >> return ret; >> >> @@ -607,6 +611,12 @@ vboxDomainSave(virDomainPtr dom, const char *path >> ATTRIBUTE_UNUSED) >> return ret; >> } >> >> +static int >> +vboxDomainSave(virDomainPtr dom, const char *path) >> +{ >> + return vboxDomainSaveFlags(dom, path, NULL, 0); > > So, this passes NULL 'dxml' into vboxDomainSaveFlags which explicitly > rejects it. What's the point? > > Ah I see. Was the above supposed to be virCheckNullArgGoto? D'oh. Yes, I got it backwards. The function wants to succeed only if the user omitted the optional dxml argument. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list