aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-05-12 17:28:51 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-05-12 17:28:51 -0700
commitedd10c1dc8a724aa113a0af88cf5c04a8fe2155f (patch)
tree39c4cbece0c5ef7dd4feb3c9242f6d7db20efdb6
parente396d6cb00469cfa5a52ad899d0f0c9f9a46997d (diff)
downloadsyslinux-edd10c1dc8a724aa113a0af88cf5c04a8fe2155f.tar.gz
syslinux-edd10c1dc8a724aa113a0af88cf5c04a8fe2155f.tar.xz
syslinux-edd10c1dc8a724aa113a0af88cf5c04a8fe2155f.zip
diskio: sanitize the reduced transfer sizes
Simply shift the size left by 1 when computing the transfer sizes. This will always end with the values ..., 1, 0 as it should. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--core/fs/diskio.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/fs/diskio.c b/core/fs/diskio.c
index 6afba219..cdbed793 100644
--- a/core/fs/diskio.c
+++ b/core/fs/diskio.c
@@ -74,8 +74,8 @@ static int chs_rdwr_sectors(struct disk *disk, void *buf,
if (retry--)
continue;
- /* if we are reading ONE sector and go here, just make it _faile_ */
- chunk = chunk == 1 ? 0 : ((chunk+1) >> 1);
+ /* For any starting value, this will always end with ..., 1, 0 */
+ chunk >>= 1;
if (chunk) {
MaxTransfer = chunk;
retry = RETRY_COUNT;
@@ -163,13 +163,16 @@ static int edd_rdwr_sectors(struct disk *disk, void *buf,
break;
if (retry--)
continue;
- chunk = chunk == 1 ? 0 : ((chunk+1) >> 1);
+
+ /* For any starting value, this will always end with ..., 1, 0 */
+ chunk >>= 1;
if (chunk) {
MaxTransfer = chunk;
retry = RETRY_COUNT;
pkt.blocks = chunk;
continue;
}
+
/*** XXX: Consider falling back to CHS here?! ***/
printf("reading sectors error(EDD)\n");
return done; /* Failure */