FAT: Simplify get_contents
authorBenoît Thébaudeau <benoit.thebaudeau@advansee.com>
Fri, 20 Jul 2012 13:21:37 +0000 (15:21 +0200)
committerWolfgang Denk <wd@denx.de>
Sun, 2 Sep 2012 15:22:43 +0000 (17:22 +0200)
One call to get_cluster can be factorized with another, so avoid
duplicating code.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Wolfgang Denk <wd@denx.de>
fs/fat/fat.c

index fa977b35cb71cfbfe8e0fcef9324112e8530fba2..f7bb1dadff39c6906fecd61c24c3d95722e11403 100644 (file)
@@ -367,21 +367,9 @@ get_contents(fsdata *mydata, dir_entry *dentptr, __u8 *buffer,
                        actsize += bytesperclust;
                }
 
-               /* actsize >= file size */
-               actsize -= bytesperclust;
-
-               /* get remaining clusters */
-               if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
-                       printf("Error reading cluster\n");
-                       return -1;
-               }
-
                /* get remaining bytes */
-               gotsize += (int)actsize;
-               filesize -= actsize;
-               buffer += actsize;
                actsize = filesize;
-               if (get_cluster(mydata, endclust, buffer, (int)actsize) != 0) {
+               if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
                        printf("Error reading cluster\n");
                        return -1;
                }