summaryrefslogtreecommitdiff
path: root/lib/comp
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-16 19:29:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-16 22:47:59 +0200
commitbfd876dbf151df164b4d87de20aec39b24f205f9 (patch)
tree53ac348da6c430b1ecf5f546ee4758ac73cb16e0 /lib/comp
parent74a064d9f15fa2d534e8b2d1ade68d10d5b65dfd (diff)
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/comp')
-rw-r--r--lib/comp/compressor.c14
1 files changed, 3 insertions, 11 deletions
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)