From 833ab9522d510197270543e47868d86ec67db5aa Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Mon, 17 Jun 2013 23:37:23 +0200 Subject: ioexact: make mayexit a bool It's used as such, so therefore make it a bool instead of int. Signed-off-by: Daniel Borkmann --- ioexact.c | 7 +++++-- ioexact.h | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ioexact.c b/ioexact.c index 1600784..7ba6594 100644 --- a/ioexact.c +++ b/ioexact.c @@ -1,12 +1,13 @@ #include #include #include +#include #include "ioexact.h" extern volatile sig_atomic_t sigint; -ssize_t read_exact(int fd, void *buf, size_t len, int mayexit) +ssize_t read_exact(int fd, void *buf, size_t len, bool mayexit) { ssize_t num = 0, written; @@ -21,6 +22,7 @@ ssize_t read_exact(int fd, void *buf, size_t len, int mayexit) } if (!written) return 0; + len -= written; buf += written; num += written; @@ -29,7 +31,7 @@ ssize_t read_exact(int fd, void *buf, size_t len, int mayexit) return num; } -ssize_t write_exact(int fd, void *buf, size_t len, int mayexit) +ssize_t write_exact(int fd, void *buf, size_t len, bool mayexit) { ssize_t num = 0, written; @@ -44,6 +46,7 @@ ssize_t write_exact(int fd, void *buf, size_t len, int mayexit) } if (!written) return 0; + len -= written; buf += written; num += written; diff --git a/ioexact.h b/ioexact.h index 6234e8e..c69552b 100644 --- a/ioexact.h +++ b/ioexact.h @@ -1,7 +1,9 @@ #ifndef IOEXACT_H #define IOEXACT_H -extern ssize_t read_exact(int fd, void *buf, size_t len, int mayexit); -extern ssize_t write_exact(int fd, void *buf, size_t len, int mayexit); +#include + +extern ssize_t read_exact(int fd, void *buf, size_t len, bool mayexit); +extern ssize_t write_exact(int fd, void *buf, size_t len, bool mayexit); #endif /* IOEXACT_H */ -- cgit v1.2.3-54-g00ecf