From e3ef871d6a80d72db02c9ab1ef492e8f58c2ddeb Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 16 Jul 2019 21:02:58 +0200 Subject: 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 --- lib/sqfs/data_reader.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'lib/sqfs/data_reader.c') diff --git a/lib/sqfs/data_reader.c b/lib/sqfs/data_reader.c index 7f857b2..96ccb39 100644 --- a/lib/sqfs/data_reader.c +++ b/lib/sqfs/data_reader.c @@ -110,13 +110,9 @@ int data_reader_dump_file(data_reader_t *data, file_info_t *fi, int outfd, if (bs == 0) { memset(data->buffer, 0, unpackedsz); compressed = false; - } else { - ret = read_retry(data->sqfsfd, data->buffer, bs); - if (ret < 0) - goto fail_rd; - - if ((size_t)ret < bs) - goto fail_trunc; + } else if (read_data("reading data block", + data->sqfsfd, data->buffer, bs)) { + return -1; } if (compressed) { @@ -163,12 +159,6 @@ fail_sparse: fail_seek: perror("seek on squashfs"); return -1; -fail_rd: - perror("reading from squashfs"); - return -1; -fail_trunc: - fputs("reading from squashfs: unexpected end of file\n", stderr); - return -1; fail_bs: fputs("found compressed block larger than block size\n", stderr); return -1; -- cgit v1.2.3