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 --- tar/sqfs2tar.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'tar') diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c index 110c8c4..15c0363 100644 --- a/tar/sqfs2tar.c +++ b/tar/sqfs2tar.c @@ -161,23 +161,11 @@ out_exit: static int terminate_archive(void) { char buffer[1024]; - ssize_t ret; memset(buffer, '\0', sizeof(buffer)); - ret = write_retry(STDOUT_FILENO, buffer, sizeof(buffer)); - - if (ret < 0) { - perror("adding archive terminator"); - return -1; - } - - if ((size_t)ret < sizeof(buffer)) { - fputs("adding archive terminator: truncated write\n", stderr); - return -1; - } - - return 0; + return write_data("adding archive terminator", STDOUT_FILENO, + buffer, sizeof(buffer)); } static int write_tree_dfs(fstree_t *fs, tree_node_t *n, data_reader_t *data) -- cgit v1.2.3