
From: Jia Zhou <zhou.jia2@zte.com.cn> 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@zte.com.cn> Signed-off-by: Yi Wang <wang.yi59@zte.com.cn> --- 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