From 0bf726cfec99b0f03791a028d44493b19f5bf61b Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Thu, 16 Jan 2020 16:13:40 +0100 Subject: [PATCH] RAR5 and WARC readers: move unnecessary comparsion into a comment RAR5 reader: comment out unreachable code Found by LGTM.com code analysis --- libarchive/archive_read_support_format_rar5.c | 9 +++++++-- libarchive/archive_read_support_format_warc.c | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libarchive/archive_read_support_format_rar5.c b/libarchive/archive_read_support_format_rar5.c index 6e91eab85..26374582e 100644 --- a/libarchive/archive_read_support_format_rar5.c +++ b/libarchive/archive_read_support_format_rar5.c @@ -1821,12 +1821,16 @@ static int process_head_file(struct archive_read* a, struct rar5* rar, int ret = process_head_file_extra(a, entry, rar, extra_data_size); - /* Sanity check. */ + /* + * TODO: rewrite or remove useless sanity check + * as extra_data_size is not passed as a pointer + * if(extra_data_size < 0) { archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, "File extra data size is not zero"); return ARCHIVE_FATAL; } + */ if(ret != ARCHIVE_OK) return ret; @@ -3043,7 +3047,8 @@ static int do_uncompress_block(struct archive_read* a, const uint8_t* p) { } continue; - } else if(num < 262) { + } else { + /* num < 262 */ const int idx = num - 258; const int dist = dist_cache_touch(rar, idx); diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c index c1c54450c..72977b8e0 100644 --- a/libarchive/archive_read_support_format_warc.c +++ b/libarchive/archive_read_support_format_warc.c @@ -626,7 +626,8 @@ _warc_rdver(const char *buf, size_t bsz) if (ver >= 1200U) { if (memcmp(c, "\r\n", 2U) != 0) ver = 0U; - } else if (ver < 1200U) { + } else { + /* ver < 1200U */ if (*c != ' ' && *c != '\t') ver = 0U; } -- 2.47.2