
From: Ricardo Salveti ricardo@foundries.io
This patch optimizes the commit mentioned below by avoiding running a set of commands which useless in the case when size < mydata->sect_size and idx would be 0.
Fixes: 5b3ddb17ba ("fs/fat/fat.c: Do not perform zero block reads if there are no blocks left")
Signed-off-by: Ricardo Salveti ricardo@foundries.io Co-developed-by: Oleksandr Suvorov oleksandr.suvorov@foundries.io Signed-off-by: Oleksandr Suvorov oleksandr.suvorov@foundries.io ---
fs/fat/fat.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 7021138b987..4a509755442 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -275,14 +275,10 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size) buffer += mydata->sect_size; size -= mydata->sect_size; } - } else { + } else if (size >= mydata->sect_size) { __u32 idx; - idx = size / mydata->sect_size; - if (idx == 0) - ret = 0; - else - ret = disk_read(startsect, idx, buffer); + ret = disk_read(startsect, idx, buffer); if (ret != idx) { debug("Error reading data (got %d)\n", ret); return -1;