From bfd876dbf151df164b4d87de20aec39b24f205f9 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 16 Jul 2019 19:29:27 +0200 Subject: cleanup: move error handling into write_retry If write_retry fails to write everything, it is *always* an error. This commit renames write_retry to write_data and moves error handling into the function, making a lot of error handling code redundant. Signed-off-by: David Oberhollenzer --- include/util.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/util.h b/include/util.h index 997cbf5..aff313f 100644 --- a/include/util.h +++ b/include/util.h @@ -23,9 +23,11 @@ int canonicalize_name(char *filename); /* A wrapper around the write() system call. It retries the write if it is - interrupted by a signal or only part of the data was written. + interrupted by a signal or only part of the data was written. Returns 0 + on success. Writes to stderr on failure using 'errstr' as a perror style + error prefix. */ -ssize_t write_retry(int fd, const void *data, size_t size); +int write_data(const char *errstr, int fd, const void *data, size_t size); /* A wrapper around the read() system call. It retries the read if it is -- cgit v1.2.3