[syslinux:pathbased] diskio: sanitize the reduced transfer sizes
syslinux-bot for H. Peter Anvin
hpa at linux.intel.com
Wed May 12 17:30:13 PDT 2010
Commit-ID: edd10c1dc8a724aa113a0af88cf5c04a8fe2155f
Gitweb: http://syslinux.zytor.com/commit/edd10c1dc8a724aa113a0af88cf5c04a8fe2155f
Author: H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Wed, 12 May 2010 17:28:51 -0700
Committer: H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Wed, 12 May 2010 17:28:51 -0700
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 at linux.intel.com>
---
core/fs/diskio.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/core/fs/diskio.c b/core/fs/diskio.c
index 6afba21..cdbed79 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 */
More information about the Syslinux-commits
mailing list