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/sqfs/meta_writer.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'lib/sqfs/meta_writer.c') diff --git a/lib/sqfs/meta_writer.c b/lib/sqfs/meta_writer.c index ef869e7..d55af3d 100644 --- a/lib/sqfs/meta_writer.c +++ b/lib/sqfs/meta_writer.c @@ -38,24 +38,10 @@ struct meta_writer_t { static int write_block(int fd, meta_block_t *outblk) { - size_t count; - ssize_t ret; - - count = le16toh(((uint16_t *)outblk->data)[0]) & 0x7FFF; - - ret = write_retry(fd, outblk->data, count + 2); - - if (ret < 0) { - perror("writing meta data block"); - return -1; - } - - if ((size_t)ret < count) { - fputs("meta data written to file was truncated\n", stderr); - return -1; - } + size_t count = le16toh(((uint16_t *)outblk->data)[0]) & 0x7FFF; - return 0; + return write_data("writing meta data block", fd, + outblk->data, count + 2); } meta_writer_t *meta_writer_create(int fd, compressor_t *cmp, bool keep_in_mem) -- cgit v1.2.3