From c94bb0427b46f2e7bad6b632c6908e54edec752f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 31 Jan 2018 16:11:18 +0100 Subject: [PATCH] vboxDumpSharedFolders: return a value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The allocation errors in this function are already handled by jumping to a cleanup label. Change the return type from void to int and return -1 on error. Signed-off-by: Ján Tomko --- src/vbox/vbox_common.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index afd00a91ac..cc7772f253 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3627,19 +3627,23 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) return ret; } -static void +static int vboxDumpSharedFolders(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { vboxArray sharedFolders = VBOX_ARRAY_INITIALIZER; size_t i = 0; + int ret = -1; def->nfss = 0; gVBoxAPI.UArray.vboxArrayGet(&sharedFolders, machine, gVBoxAPI.UArray.handleMachineGetSharedFolders(machine)); - if (sharedFolders.count <= 0) + if (sharedFolders.count <= 0) { + if (sharedFolders.count == 0) + ret = 0; goto cleanup; + } if (VIR_ALLOC_N(def->fss, sharedFolders.count) < 0) goto cleanup; @@ -3683,8 +3687,11 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine ++def->nfss; } + ret = 0; + cleanup: gVBoxAPI.UArray.vboxArrayRelease(&sharedFolders); + return ret; } static void @@ -4179,7 +4186,8 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) if (vboxDumpDisks(def, data, machine) < 0) goto cleanup; - vboxDumpSharedFolders(def, data, machine); + if (vboxDumpSharedFolders(def, data, machine) < 0) + goto cleanup; vboxDumpNetwork(def, data, machine, networkAdapterCount); vboxDumpAudio(def, data, machine); -- GitLab