Message ID | d940ae2022944035bb92d394351bb4c0@HKNPR04MB0388.apcprd04.prod.outlook.com |
---|---|
State | New |
Headers | show |
On Thu, 30 Oct 2014, James Harper wrote: > Fix off-by-one error when unplugging disks, which would otherwise leave the last ATA disk plugged, with obvious consequences. Also rewrite loop to be more readable. > > Signed-off-by: James Harper <james.harper@ejbdigital.com.au> Added to my queue > diff --git a/hw/ide/piix.c b/hw/ide/piix.c > index 574b9c1..b0172fb 100644 > --- a/hw/ide/piix.c > +++ b/hw/ide/piix.c > @@ -171,11 +171,11 @@ int pci_piix3_xen_ide_unplug(DeviceState *dev) > { > PCIIDEState *pci_ide; > DriveInfo *di; > - int i = 0; > + int i; > > pci_ide = PCI_IDE(dev); > > - for (; i < 3; i++) { > + for (i = 0; i < 4; i++) { > di = drive_get_by_index(IF_IDE, i); > if (di != NULL && !di->media_cd) { > BlockBackend *blk = blk_by_legacy_dinfo(di); >
diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 574b9c1..b0172fb 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -171,11 +171,11 @@ int pci_piix3_xen_ide_unplug(DeviceState *dev) { PCIIDEState *pci_ide; DriveInfo *di; - int i = 0; + int i; pci_ide = PCI_IDE(dev); - for (; i < 3; i++) { + for (i = 0; i < 4; i++) { di = drive_get_by_index(IF_IDE, i); if (di != NULL && !di->media_cd) { BlockBackend *blk = blk_by_legacy_dinfo(di);
Fix off-by-one error when unplugging disks, which would otherwise leave the last ATA disk plugged, with obvious consequences. Also rewrite loop to be more readable. Signed-off-by: James Harper <james.harper@ejbdigital.com.au>