From 88ca06769028e442bf873b270c176ca0e9f021f8 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Thu, 12 Oct 2006 22:44:13 +0000 Subject: xread/write can use full_read/write (smaller code) --- libbb/xfuncs.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'libbb/xfuncs.c') diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index d22cd279a..efc919491 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -113,24 +113,20 @@ int xopen3(const char *pathname, int flags, int mode) // Die with an error message if we can't read the entire buffer. void xread(int fd, void *buf, size_t count) { - while (count) { - ssize_t size = safe_read(fd, buf, count); - if (size < 1) + if (count) { + ssize_t size = full_read(fd, buf, count); + if (size != count) bb_error_msg_and_die("short read"); - count -= size; - buf = ((char *) buf) + size; } } // Die with an error message if we can't write the entire buffer. void xwrite(int fd, void *buf, size_t count) { - while (count) { - ssize_t size = safe_write(fd, buf, count); - if (size < 1) + if (count) { + ssize_t size = full_write(fd, buf, count); + if (size != count) bb_error_msg_and_die("short write"); - count -= size; - buf = ((char *) buf) + size; } } -- cgit v1.2.3