From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkEOX-0002AZ-0Z for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:47:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjqeM-0000bM-3X for qemu-devel@nongnu.org; Thu, 30 Oct 2014 10:24:34 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:32314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjqeL-0000b7-Qk for qemu-devel@nongnu.org; Thu, 30 Oct 2014 10:24:30 -0400 From: Stefano Stabellini Date: Thu, 30 Oct 2014 14:22:27 +0000 Message-ID: <1414678947-8607-2-git-send-email-stefano.stabellini@eu.citrix.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PULL 2/2] fix off-by-one error in pci_piix3_xen_ide_unplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, xen-devel@lists.xensource.com, James Harper , James Harper , Stefano Stabellini From: James Harper 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 Signed-off-by: Stefano Stabellini --- hw/ide/piix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 1.7.10.4