From b7c27a25a6f9992a6d4698c13d5865543336edce Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 22 Nov 2022 17:28:34 +0100 Subject: [PATCH] Reorganize minitar_attempt_read_entry --- src/tar.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/tar.c b/src/tar.c index bbd9306..cbf1f12 100644 --- a/src/tar.c +++ b/src/tar.c @@ -37,19 +37,14 @@ static struct minitar_entry* minitar_attempt_read_entry(struct minitar* mp, int* { struct minitar_entry entry; struct tar_header hdr; - if (!minitar_read_header(mp, &hdr)) - { - *valid = 1; // we are at end-of-file - return NULL; - } + *valid = 1; + if (!minitar_read_header(mp, &hdr)) return NULL; if (!minitar_validate_header(&hdr)) { *valid = 0; return NULL; } - *valid = 0; if (fgetpos(mp->stream, &entry.position)) return NULL; - *valid = 1; minitar_parse_metadata_from_tar_header(&hdr, &entry.metadata); if (entry.metadata.size) { @@ -69,7 +64,7 @@ struct minitar_entry* minitar_read_entry(struct minitar* mp) struct minitar_entry* result; do { result = minitar_attempt_read_entry(mp, &valid); - } while (!valid); + } while (!valid); // Skip over invalid entries return result; }