Most of the variables were reinitialized on every iteration. Also remove the pointless initialization of 'i'. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/vbox/vbox_common.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index b9b72e2e02..6a517ff96c 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3079,23 +3079,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; + size_t i; 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; @@ -3133,8 +3128,6 @@ vboxDumpStorageControllers(virDomainDefPtr def, IMachine *machine) case StorageControllerType_IntelAhci: case StorageControllerType_I82078: case StorageControllerType_Null: - model = -1; - break; } @@ -3165,6 +3158,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, -- 2.26.2