diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-16 19:29:27 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-16 22:47:59 +0200 |
commit | bfd876dbf151df164b4d87de20aec39b24f205f9 (patch) | |
tree | 53ac348da6c430b1ecf5f546ee4758ac73cb16e0 /lib/sqfs/write_xattr.c | |
parent | 74a064d9f15fa2d534e8b2d1ade68d10d5b65dfd (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/sqfs/write_xattr.c')
-rw-r--r-- | lib/sqfs/write_xattr.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/sqfs/write_xattr.c b/lib/sqfs/write_xattr.c index 0e11757..31fdf50 100644 --- a/lib/sqfs/write_xattr.c +++ b/lib/sqfs/write_xattr.c @@ -105,7 +105,6 @@ int write_xattr(int outfd, fstree_t *fs, sqfs_super_t *super, meta_writer_t *mw; tree_xattr_t *it; uint32_t offset; - ssize_t ret; if (fs->xattr == NULL) return 0; @@ -179,17 +178,13 @@ int write_xattr(int outfd, fstree_t *fs, sqfs_super_t *super, idtbl.xattr_ids = htole32(count); idtbl.unused = 0; - ret = write_retry(outfd, &idtbl, sizeof(idtbl)); - if (ret < 0) - goto fail_wr; - if ((size_t)ret < sizeof(idtbl)) - goto fail_trunc; + if (write_data("writing xattr ID table", outfd, &idtbl, sizeof(idtbl))) + goto fail_tbl; - ret = write_retry(outfd, tbl, sizeof(tbl[0]) * blocks); - if (ret < 0) - goto fail_wr; - if ((size_t)ret < sizeof(tbl[0]) * blocks) - goto fail_trunc; + if (write_data("writing xattr ID table", + outfd, tbl, sizeof(tbl[0]) * blocks)) { + goto fail_tbl; + } super->xattr_id_table_start = super->bytes_used; super->bytes_used += sizeof(idtbl) + sizeof(tbl[0]) * blocks; @@ -197,12 +192,6 @@ int write_xattr(int outfd, fstree_t *fs, sqfs_super_t *super, free(tbl); meta_writer_destroy(mw); return 0; -fail_wr: - perror("writing xattr ID table"); - goto fail_tbl; -fail_trunc: - fputs("writing xattr ID table: truncated write\n", stderr); - goto fail_tbl; fail_tbl: free(tbl); fail_mw: |