From 8f00ef69071f5de42c72544a21bb0c1ea8259c65 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Tue, 21 Aug 2007 14:18:16 +0000 Subject: [PATCH] - evaluate_media() now returns 1 only if the media is valid (total number of sectors > 0) to avoid division by zero error --- bochs/iodev/floppy.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bochs/iodev/floppy.cc b/bochs/iodev/floppy.cc index 27c7df04a..4b3fd64bd 100644 --- a/bochs/iodev/floppy.cc +++ b/bochs/iodev/floppy.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: floppy.cc,v 1.106 2007-04-06 15:22:17 vruppert Exp $ +// $Id: floppy.cc,v 1.107 2007-08-21 14:18:16 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -139,7 +139,7 @@ void bx_floppy_ctrl_c::init(void) { Bit8u i; - BX_DEBUG(("Init $Id: floppy.cc,v 1.106 2007-04-06 15:22:17 vruppert Exp $")); + BX_DEBUG(("Init $Id: floppy.cc,v 1.107 2007-08-21 14:18:16 vruppert Exp $")); DEV_dma_register_8bit_channel(2, dma_read, dma_write, "Floppy Drive"); DEV_register_irq(6, "Floppy Drive"); for (unsigned addr=0x03F2; addr<=0x03F7; addr++) { @@ -1785,7 +1785,7 @@ bx_bool bx_floppy_ctrl_c::evaluate_media(Bit8u devtype, Bit8u type, char *path, } media->sectors = media->heads * media->tracks * media->sectors_per_track; } - return(1); // success + return (media->sectors > 0); // success } else if ( S_ISCHR(stat_buf.st_mode) @@ -1805,7 +1805,7 @@ bx_bool bx_floppy_ctrl_c::evaluate_media(Bit8u devtype, Bit8u type, char *path, media->heads = floppy_type[type_idx].hd; media->sectors_per_track = floppy_type[type_idx].spt; media->sectors = floppy_type[type_idx].sectors; - return 1; + return (media->sectors > 0); } media->tracks = floppy_geom.track; media->heads = floppy_geom.head; @@ -1822,7 +1822,7 @@ bx_bool bx_floppy_ctrl_c::evaluate_media(Bit8u devtype, Bit8u type, char *path, media->sectors_per_track = floppy_type[type_idx].spt; media->sectors = floppy_type[type_idx].sectors; #endif - return 1; // success + return (media->sectors > 0); // success } else { // unknown file type BX_ERROR(("unknown mode type"));