summaryrefslogtreecommitdiff
path: root/lib/tar/read_sparse_map_old.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-16 21:02:58 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-16 22:48:00 +0200
commite3ef871d6a80d72db02c9ab1ef492e8f58c2ddeb (patch)
treeec28b205b651e83c795e1e264aacfe5bcb307bc4 /lib/tar/read_sparse_map_old.c
parentbfd876dbf151df164b4d87de20aec39b24f205f9 (diff)
cleanup: move error handling into read_retry
If read_retry fails to read the expected amount of data (EOF or otherwise), it is almost always an error. This commit renames read_retry to read_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/tar/read_sparse_map_old.c')
-rw-r--r--lib/tar/read_sparse_map_old.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/tar/read_sparse_map_old.c b/lib/tar/read_sparse_map_old.c
index c0b2d0d..41d309a 100644
--- a/lib/tar/read_sparse_map_old.c
+++ b/lib/tar/read_sparse_map_old.c
@@ -6,7 +6,6 @@ sparse_map_t *read_gnu_old_sparse(int fd, tar_header_t *hdr)
sparse_map_t *list = NULL, *end = NULL, *node;
gnu_sparse_t sph;
uint64_t off, sz;
- ssize_t ret;
int i;
for (i = 0; i < 4; ++i) {
@@ -41,11 +40,10 @@ sparse_map_t *read_gnu_old_sparse(int fd, tar_header_t *hdr)
return list;
do {
- ret = read_retry(fd, &sph, sizeof(sph));
- if (ret < 0)
- goto fail_errno;
- if ((size_t)ret < sizeof(sph))
- goto fail_eof;
+ if (read_data("reading GNU sparse header",
+ fd, &sph, sizeof(sph))) {
+ goto fail;
+ }
for (i = 0; i < 21; ++i) {
if (!isdigit(sph.sparse[i].offset[0]))
@@ -77,9 +75,6 @@ sparse_map_t *read_gnu_old_sparse(int fd, tar_header_t *hdr)
} while (sph.isextended != 0);
return list;
-fail_eof:
- fputs("parsing GNU sparse header: unexpected end of file", stderr);
- goto fail;
fail_errno:
perror("parsing GNU sparse header");
goto fail;