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/super.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'lib/sqfs/super.c') diff --git a/lib/sqfs/super.c b/lib/sqfs/super.c index d3b79c6..59eb366 100644 --- a/lib/sqfs/super.c +++ b/lib/sqfs/super.c @@ -47,7 +47,6 @@ int sqfs_super_init(sqfs_super_t *super, size_t block_size, uint32_t mtime, int sqfs_super_write(sqfs_super_t *super, int fd) { sqfs_super_t copy; - ssize_t ret; copy.magic = htole32(super->magic); copy.inode_count = htole32(super->inode_count); @@ -72,18 +71,8 @@ int sqfs_super_write(sqfs_super_t *super, int fd) if (lseek(fd, 0, SEEK_SET) == (off_t)-1) goto fail_seek; - ret = write_retry(fd, ©, sizeof(copy)); - - if (ret < 0) { - perror("squashfs writing super block"); + if (write_data("writing super block", fd, ©, sizeof(copy))) return -1; - } - - if ((size_t)ret < sizeof(copy)) { - fputs("squashfs writing super block: truncated write\n", - stderr); - return -1; - } if (lseek(fd, 0, SEEK_END) == (off_t)-1) goto fail_seek; -- cgit v1.2.3