From 0a8aedfdef9a0ebf33081e263010796c82b14cae Mon Sep 17 00:00:00 2001 From: Grzegorz Antoniak Date: Thu, 4 Oct 2018 22:01:35 +0200 Subject: [PATCH] Removed usage of __attribute__ macros and unsafe cast in debug code --- libarchive/archive_read_support_format_rar5.c | 40 +++++-------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/libarchive/archive_read_support_format_rar5.c b/libarchive/archive_read_support_format_rar5.c index 4b770d77e..d891ff94c 100644 --- a/libarchive/archive_read_support_format_rar5.c +++ b/libarchive/archive_read_support_format_rar5.c @@ -48,14 +48,6 @@ /*#define DONT_FAIL_ON_CRC_ERROR*/ /*#define DEBUG*/ -#if __GNUC__ > 4 && !defined __OpenBSD__ -#define fallthrough __attribute__((fallthrough)) -#define unused __attribute__((unused)) -#else -#define fallthrough -#define unused -#endif - #define rar5_min(a, b) (((a) > (b)) ? (b) : (a)) #define rar5_max(a, b) (((a) > (b)) ? (a) : (b)) #define rar5_countof(X) ((const ssize_t) (sizeof(X) / sizeof(*X))) @@ -597,7 +589,7 @@ static int run_filter(struct archive_read* a, struct filter_info* flt) { break; case FILTER_E8: - fallthrough; + /* fallthrough */ case FILTER_E8E9: ret = run_e8e9_filter(rar, flt, flt->type == FILTER_E8E9); break; @@ -1255,15 +1247,15 @@ static int process_head_file_extra(struct archive_read* a, ret = parse_file_extra_htime(a, e, rar, &extra_data_size); break; case CRYPT: - fallthrough; + /* fallthrough */ case VERSION_: - fallthrough; + /* fallthrough */ case REDIR: - fallthrough; + /* fallthrough */ case UOWNER: - fallthrough; + /* fallthrough */ case SUBDATA: - fallthrough; + /* fallthrough */ default: archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Unknown extra field in file/service block: 0x%02x", @@ -3150,13 +3142,13 @@ static int do_unpack(struct archive_read* a, struct rar5* rar, case STORE: return do_unstore_file(a, rar, buf, size, offset); case FASTEST: - fallthrough; + /* fallthrough */ case FAST: - fallthrough; + /* fallthrough */ case NORMAL: - fallthrough; + /* fallthrough */ case GOOD: - fallthrough; + /* fallthrough */ case BEST: return uncompress_file(a); default: @@ -3251,24 +3243,12 @@ static int verify_checksums(struct archive_read* a) { (void) blake2sp_final(&rar->file.b2state, b2_buf, 32); if(memcmp(&rar->file.blake2sp, b2_buf, 32) != 0) { - DEBUG_CODE { - printf("Checksum error: BLAKE2sp (%08x/%08x)\n", - *(uint32_t*)rar->file.blake2sp, - *(uint32_t*)b2_buf); - } - #ifndef DONT_FAIL_ON_CRC_ERROR archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Checksum error: BLAKE2"); return ARCHIVE_FATAL; #endif - } else { - DEBUG_CODE { - printf("Checksum OK: BLAKE2sp (%08x/%08x)\n", - *(uint32_t*)rar->file.blake2sp, - *(uint32_t*)b2_buf); - } } } } -- 2.47.2