FAT: fix next_sector implementation syslinux-4.00-pre13
authorH. Peter Anvin <hpa@zytor.com>
Sun, 31 Jan 2010 19:10:54 +0000 (11:10 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 31 Jan 2010 19:10:54 +0000 (11:10 -0800)
"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@zytor.com>
core/fs/fat/fat.c

index db72bd2..79439e0 100644 (file)
@@ -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;