On 7/29/21 4:16 AM, Yi Wang wrote:
From: Jia Zhou <zhou.jia2(a)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(a)zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59(a)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;
Ooops yes. This is a bug. However, I'd prefer that 'j' would be defined
inside the loop.
Also, I'm having difficulties applying this patch. Partly because it's
multipart e-mail and even if I extract text/plain part then git am is
still unhappy. Can you please use git send-email?
Michal