From 1d7f2ece69c9d80264321bc4ee07f57eec392538 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Mon, 28 Sep 2015 15:45:29 +0200 Subject: [PATCH] fs/fat/fat_write: Merge calls to set_cluster() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit set_contents() had uselessly split calls to set_cluster(). Merge these calls, which removes some cases of set_cluster() being called with a size of zero. Signed-off-by: Benoît Thébaudeau --- fs/fat/fat_write.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index d0d9df7170..e08cf83b05 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -728,21 +728,10 @@ set_contents(fsdata *mydata, dir_entry *dentptr, __u8 *buffer, endclust = newclust; actsize += bytesperclust; } - /* actsize >= file size */ - actsize -= bytesperclust; - /* set remaining clusters */ - if (set_cluster(mydata, curclust, buffer, (int)actsize) != 0) { - debug("error: writing cluster\n"); - return -1; - } /* set remaining bytes */ - *gotsize += actsize; - filesize -= actsize; - buffer += actsize; actsize = filesize; - - if (set_cluster(mydata, endclust, buffer, (int)actsize) != 0) { + if (set_cluster(mydata, curclust, buffer, (int)actsize) != 0) { debug("error: writing cluster\n"); return -1; } -- 2.39.5