From 6ce2ee8ce47afb21aaaa8cfee4fca744ebf520a9 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 27 May 2019 22:58:52 -0700 Subject: libfile: Simplify read_full() We can figure out the amount of written data by substracting 'insize' from 'size' so there is no need to keep a separate counter for that. Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- lib/libfile.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libfile.c b/lib/libfile.c index eb12d158d8..814cd9c2cd 100644 --- a/lib/libfile.c +++ b/lib/libfile.c @@ -80,20 +80,18 @@ int read_full(int fd, void *buf, size_t size) { size_t insize = size; int now; - int total = 0; while (size) { now = read(fd, buf, size); if (now == 0) - return total; + break; if (now < 0) return now; - total += now; size -= now; buf += now; } - return insize; + return insize - size; } EXPORT_SYMBOL(read_full); -- cgit v1.2.3