From f4b6e71611ff90055c130e21277fbf8fd3e0f6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 23 Sep 2020 18:55:44 +0200 Subject: [PATCH] vbox: reduce variable scope in vboxDumpStorageControllers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of the variables were reinitialized on every iteration. Signed-off-by: Ján Tomko Reviewed-by: Martin Kletzander --- src/vbox/vbox_common.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index dad36007c4..ffe03061a1 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3077,23 +3077,18 @@ static int vboxDumpStorageControllers(virDomainDefPtr def, IMachine *machine) { vboxArray storageControllers = VBOX_ARRAY_INITIALIZER; - IStorageController *controller = NULL; - PRUint32 storageBus = StorageBus_Null; - PRUint32 controllerType = StorageControllerType_Null; - virDomainControllerDefPtr cont = NULL; size_t i = 0; - int model = -1, ret = -1; - virDomainControllerType type = VIR_DOMAIN_CONTROLLER_TYPE_LAST; + int ret = -1; gVBoxAPI.UArray.vboxArrayGet(&storageControllers, machine, gVBoxAPI.UArray.handleMachineGetStorageControllers(machine)); for (i = 0; i < storageControllers.count; i++) { - controller = storageControllers.items[i]; - storageBus = StorageBus_Null; - controllerType = StorageControllerType_Null; - type = VIR_DOMAIN_CONTROLLER_TYPE_LAST; - model = -1; + IStorageController *controller = storageControllers.items[i]; + PRUint32 storageBus = StorageBus_Null; + PRUint32 controllerType = StorageControllerType_Null; + virDomainControllerType type = VIR_DOMAIN_CONTROLLER_TYPE_LAST; + int model = -1; if (!controller) continue; @@ -3131,8 +3126,6 @@ vboxDumpStorageControllers(virDomainDefPtr def, IMachine *machine) case StorageControllerType_IntelAhci: case StorageControllerType_I82078: case StorageControllerType_Null: - model = -1; - break; } @@ -3163,6 +3156,8 @@ vboxDumpStorageControllers(virDomainDefPtr def, IMachine *machine) } if (type != VIR_DOMAIN_CONTROLLER_TYPE_LAST) { + virDomainControllerDefPtr cont; + cont = virDomainDefAddController(def, type, -1, model); if (!cont) { virReportError(VIR_ERR_INTERNAL_ERROR,