[PATCH] util: fix: duplicated index at nested loop in virNVMeDeviceListCreateReAttachList

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

 



From: Jia Zhou <zhou.jia2@xxxxxxxxxx>

When loop in function virNVMeDeviceListCreateReAttachList() there may be
reused index @i, this patch fix this by using a new @j.

Signed-off-by: Jia Zhou <zhou.jia2@xxxxxxxxxx>
Signed-off-by: Yi Wang <wang.yi59@xxxxxxxxxx>
---
 src/util/virnvme.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/util/virnvme.c b/src/util/virnvme.c
index 49102e3..b54a195 100644
--- a/src/util/virnvme.c
+++ b/src/util/virnvme.c
@@ -399,7 +399,7 @@ virNVMeDeviceListCreateReAttachList(virNVMeDeviceListPtr activeList,
                                     virNVMeDeviceListPtr toReAttachList)
 {
     g_autoptr(virPCIDeviceList) pciDevices = NULL;
-    size_t i;
+    size_t i, j;
 
     if (!(pciDevices = virPCIDeviceListNew()))
         return NULL;
@@ -412,8 +412,8 @@ virNVMeDeviceListCreateReAttachList(virNVMeDeviceListPtr activeList,
         /* Check if there is any other NVMe device with the same PCI address as
          * @d. To simplify this, let's just count how many NVMe devices with
          * the same PCI address there are on the @activeList. */
-        for (i = 0; i < activeList->count; i++) {
-            virNVMeDevicePtr other = activeList->devs[i];
+        for (j = 0; j < activeList->count; j++) {
+            virNVMeDevicePtr other = activeList->devs[j];
 
             if (!virPCIDeviceAddressEqual(&d->address, &other->address))
                 continue;
-- 
1.8.3.1

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux