Skip to content

Commit

Permalink
fix off-by-one error in pci_piix3_xen_ide_unplug
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
  • Loading branch information
James Harper authored and Stefano Stabellini committed Oct 30, 2014
1 parent 37f9e25 commit d4f9e80
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hw/ide/piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d4f9e80

Please sign in to comment.