vbox: reduce variable scope in vboxDumpStorageControllers

Most of the variables were reinitialized on every iteration.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Ján Tomko 2020-09-23 18:55:44 +02:00
parent 92047567cf
commit f4b6e71611

View File

@ -3077,23 +3077,18 @@ static int
vboxDumpStorageControllers(virDomainDefPtr def, IMachine *machine) vboxDumpStorageControllers(virDomainDefPtr def, IMachine *machine)
{ {
vboxArray storageControllers = VBOX_ARRAY_INITIALIZER; vboxArray storageControllers = VBOX_ARRAY_INITIALIZER;
IStorageController *controller = NULL;
PRUint32 storageBus = StorageBus_Null;
PRUint32 controllerType = StorageControllerType_Null;
virDomainControllerDefPtr cont = NULL;
size_t i = 0; size_t i = 0;
int model = -1, ret = -1; int ret = -1;
virDomainControllerType type = VIR_DOMAIN_CONTROLLER_TYPE_LAST;
gVBoxAPI.UArray.vboxArrayGet(&storageControllers, machine, gVBoxAPI.UArray.vboxArrayGet(&storageControllers, machine,
gVBoxAPI.UArray.handleMachineGetStorageControllers(machine)); gVBoxAPI.UArray.handleMachineGetStorageControllers(machine));
for (i = 0; i < storageControllers.count; i++) { for (i = 0; i < storageControllers.count; i++) {
controller = storageControllers.items[i]; IStorageController *controller = storageControllers.items[i];
storageBus = StorageBus_Null; PRUint32 storageBus = StorageBus_Null;
controllerType = StorageControllerType_Null; PRUint32 controllerType = StorageControllerType_Null;
type = VIR_DOMAIN_CONTROLLER_TYPE_LAST; virDomainControllerType type = VIR_DOMAIN_CONTROLLER_TYPE_LAST;
model = -1; int model = -1;
if (!controller) if (!controller)
continue; continue;
@ -3131,8 +3126,6 @@ vboxDumpStorageControllers(virDomainDefPtr def, IMachine *machine)
case StorageControllerType_IntelAhci: case StorageControllerType_IntelAhci:
case StorageControllerType_I82078: case StorageControllerType_I82078:
case StorageControllerType_Null: case StorageControllerType_Null:
model = -1;
break; break;
} }
@ -3163,6 +3156,8 @@ vboxDumpStorageControllers(virDomainDefPtr def, IMachine *machine)
} }
if (type != VIR_DOMAIN_CONTROLLER_TYPE_LAST) { if (type != VIR_DOMAIN_CONTROLLER_TYPE_LAST) {
virDomainControllerDefPtr cont;
cont = virDomainDefAddController(def, type, -1, model); cont = virDomainDefAddController(def, type, -1, model);
if (!cont) { if (!cont) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,