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 --- lib/comp/compressor.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'lib/comp') diff --git a/lib/comp/compressor.c b/lib/comp/compressor.c index cc04aa6..96bc3b1 100644 --- a/lib/comp/compressor.c +++ b/lib/comp/compressor.c @@ -59,24 +59,16 @@ static const char *names[] = { int generic_write_options(int fd, const void *data, size_t size) { uint8_t buffer[size + 2]; - ssize_t ret; *((uint16_t *)buffer) = htole16(0x8000 | size); memcpy(buffer + 2, data, size); - ret = write_retry(fd, buffer, sizeof(buffer)); - - if (ret < 0) { - perror("writing compressor options"); - return -1; - } - - if ((size_t)ret < sizeof(buffer)) { - fputs("writing compressor options: truncated write\n", stderr); + if (write_data("writing compressor options", + fd, buffer, sizeof(buffer))) { return -1; } - return ret; + return sizeof(buffer); } int generic_read_options(int fd, void *data, size_t size) -- cgit v1.2.3