[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt PATCH 12/14] vbox: reduce variable scope in vboxDumpStorageControllers



On Wed, Sep 23, 2020 at 08:15:01PM +0200, Ján Tomko wrote:
Most of the variables were reinitialized on every iteration.

Also remove the pointless initialization of 'i'.


Same reply about the 'i' (👁), for the rest:

Reviewed-by: Martin Kletzander <mkletzan redhat com>

Signed-off-by: Ján Tomko <jtomko redhat com>
---
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

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]