Skip to content
Snippets Groups Projects
Commit 6b8f185f authored by Wu, Josh's avatar Wu, Josh Committed by Tom Rini
Browse files

fs: fat: don't call disk_write with zero sector num


In the set_cluster() function, it will convert the buffer size to sector
numbers. Then call disk_write() to write by sector.
For remaining buffer, the size is less than a sector, call disk_write()
again to write them in one sector.

But if the total buffer size is less then one sector, the original code
will call disk_write() with zero sector number. It is unnecessary.
So this patch fix this. Now it will not call disk_write() if total buffer size
is less than one sector.

Signed-off-by: default avatarJosh Wu <josh.wu@atmel.com>
parent 7ea50d52
No related branches found
No related tags found
No related merge requests found
...@@ -552,9 +552,11 @@ set_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, ...@@ -552,9 +552,11 @@ set_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer,
debug("clustnum: %d, startsect: %d\n", clustnum, startsect); debug("clustnum: %d, startsect: %d\n", clustnum, startsect);
if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) { if ((size / mydata->sect_size) > 0) {
debug("Error writing data\n"); if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
return -1; debug("Error writing data\n");
return -1;
}
} }
if (size % mydata->sect_size) { if (size % mydata->sect_size) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment