summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-05-27 22:58:52 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2019-05-28 10:17:02 +0200
commit6ce2ee8ce47afb21aaaa8cfee4fca744ebf520a9 (patch)
tree2d76f067ecc55890943e651bc50f70f8e3ba27c7 /lib
parent0ac711f382b5695846b76880b9d7bcf43f93faa1 (diff)
downloadbarebox-6ce2ee8ce47afb21aaaa8cfee4fca744ebf520a9.tar.gz
barebox-6ce2ee8ce47afb21aaaa8cfee4fca744ebf520a9.tar.xz
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 <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/libfile.c6
1 files changed, 2 insertions, 4 deletions
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);