[syslinux:fsc] FAT: fix next_sector implementation
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Sun Jan 31 17:15:09 PST 2010
Commit-ID: c6cae247bbefd1693e4ade2236ebc5ee5ea4ed1e
Gitweb: http://syslinux.zytor.com/commit/c6cae247bbefd1693e4ade2236ebc5ee5ea4ed1e
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sun, 31 Jan 2010 11:10:54 -0800
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Sun, 31 Jan 2010 11:10:54 -0800
FAT: fix next_sector implementation
"return ++sector;" is a bit subtle and I brainfarted and changed to
"return sector++;" -- change it to "return sector+1;" to make it
obvious we're not looking for a side effect at all here...
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
core/fs/fat/fat.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c
index db72bd2..79439e0 100644
--- a/core/fs/fat/fat.c
+++ b/core/fs/fat/fat.c
@@ -97,17 +97,17 @@ static sector_t get_next_sector(struct fs_info* fs, uint32_t sector)
int clust_shift = sbi->clust_shift;
if (sector < data_area) {
+ /* Root directory sector... */
sector++;
- /* if we reached the end of root area */
if (sector == data_area)
- sector = 0; /* return 0 */
+ sector = 0; /* Ran out of root directory, return EOF */
return sector;
}
data_sector = sector - data_area;
- if ((data_sector + 1) & sbi->clust_mask) /* in a cluster */
- return sector++;
-
+ if ((data_sector + 1) & sbi->clust_mask) /* Still in the same cluster */
+ return sector+1; /* Next sector inside cluster */
+
/* get a new cluster */
cluster = data_sector >> clust_shift;
cluster = get_next_cluster(fs, cluster + 2) - 2;
More information about the Syslinux-commits
mailing list