From: Michihiro NAKAJIMA Date: Wed, 8 Feb 2012 22:20:28 +0000 (+0900) Subject: Fix build failure with -Wextra -Wunused GCC options since it happend on FreeBSD current. X-Git-Tag: v3.0.4~2^2~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=433f74b08f999c970b31ba36307bd05a77e0f135;p=thirdparty%2Flibarchive.git Fix build failure with -Wextra -Wunused GCC options since it happend on FreeBSD current. --- diff --git a/libarchive/archive_read_open_memory.c b/libarchive/archive_read_open_memory.c index 07940a2ac..bcc7d6f78 100644 --- a/libarchive/archive_read_open_memory.c +++ b/libarchive/archive_read_open_memory.c @@ -149,6 +149,7 @@ memory_read_seek(struct archive *a, void *client_data, int64_t offset, int whenc { struct read_memory_data *mine = (struct read_memory_data *)client_data; + (void)a; /* UNUSED */ switch (whence) { case SEEK_SET: mine->p = mine->start + offset; diff --git a/libarchive/archive_read_support_format_7zip.c b/libarchive/archive_read_support_format_7zip.c index a7b0cc91b..ee0c13644 100644 --- a/libarchive/archive_read_support_format_7zip.c +++ b/libarchive/archive_read_support_format_7zip.c @@ -630,7 +630,7 @@ archive_read_format_7zip_read_header(struct archive_read *a, if (zip_entry->flg & ATIME_IS_SET) archive_entry_set_atime(entry, zip_entry->atime, zip_entry->atime_ns); - if (zip_entry->ssIndex != -1) { + if (zip_entry->ssIndex != (uint32_t)-1) { zip->entry_bytes_remaining = zip->si.ss.unpackSizes[zip_entry->ssIndex]; archive_entry_set_size(entry, zip->entry_bytes_remaining); @@ -1988,7 +1988,7 @@ folder_uncompressed_size(struct _7z_folder *f) while (--n >= 0) { unsigned i; for (i = 0; i < pairs; i++) { - if (f->bindPairs[i].outIndex == n) + if (f->bindPairs[i].outIndex == (uint64_t)n) break; } if (i >= pairs) @@ -2729,7 +2729,7 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip, } __archive_read_consume(a, 32); if (next_header_offset != 0) { - if (bytes_avail >= next_header_offset) + if (bytes_avail >= (ssize_t)next_header_offset) __archive_read_consume(a, next_header_offset); else if (__archive_read_seek(a, next_header_offset + zip->seek_base, SEEK_SET) < 0) @@ -2842,7 +2842,7 @@ get_uncompressed_data(struct archive_read *a, const void **buff, size_t size, struct _7zip *zip = (struct _7zip *)a->format->data; ssize_t bytes_avail; - if (zip->codec == _7Z_COPY && zip->codec2 == -1) { + if (zip->codec == _7Z_COPY && zip->codec2 == (unsigned long)-1) { /* Copy mode. */ /* @@ -2901,7 +2901,7 @@ extract_pack_stream(struct archive_read *a, size_t minimum) ssize_t bytes_avail; int r; - if (zip->codec == _7Z_COPY && zip->codec2 == -1) { + if (zip->codec == _7Z_COPY && zip->codec2 == (unsigned long)-1) { if (minimum == 0) minimum = 1; if (__archive_read_ahead(a, minimum, &bytes_avail) == NULL @@ -2911,10 +2911,10 @@ extract_pack_stream(struct archive_read *a, size_t minimum) "Truncated 7-Zip file body"); return (ARCHIVE_FATAL); } - if (bytes_avail > zip->pack_stream_inbytes_remaining) + if (bytes_avail > (ssize_t)zip->pack_stream_inbytes_remaining) bytes_avail = zip->pack_stream_inbytes_remaining; zip->pack_stream_inbytes_remaining -= bytes_avail; - if (bytes_avail > zip->folder_outbytes_remaining) + if (bytes_avail > (ssize_t)zip->folder_outbytes_remaining) bytes_avail = zip->folder_outbytes_remaining; zip->folder_outbytes_remaining -= bytes_avail; zip->uncompressed_buffer_bytes_remaining = bytes_avail; @@ -3056,7 +3056,7 @@ static int seek_pack(struct archive_read *a) { struct _7zip *zip = (struct _7zip *)a->format->data; - uint64_t pack_offset; + int64_t pack_offset; if (zip->pack_stream_remaining <= 0) { archive_set_error(&(a->archive), @@ -3336,7 +3336,7 @@ setup_decode_folder(struct archive_read *a, struct _7z_folder *folder, if ((r = seek_pack(a)) < 0) return (r); - if (sunpack[i] == -1) + if (sunpack[i] == (uint64_t)-1) zip->folder_outbytes_remaining = zip->pack_stream_inbytes_remaining; else diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c index 1b81ee92c..685c54841 100644 --- a/libarchive/archive_read_support_format_cab.c +++ b/libarchive/archive_read_support_format_cab.c @@ -349,7 +349,7 @@ static int lzx_read_bitlen(struct lzx_stream *, struct huffman *, int); static int lzx_huffman_init(struct huffman *, size_t, int); static void lzx_huffman_free(struct huffman *); static int lzx_make_huffman_table(struct huffman *); -static int inline lzx_decode_huffman(struct huffman *, unsigned); +static inline int lzx_decode_huffman(struct huffman *, unsigned); static int lzx_decode_huffman_tree(struct huffman *, unsigned, int); diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c index da0fec7cc..364afdf2b 100644 --- a/libarchive/archive_read_support_format_iso9660.c +++ b/libarchive/archive_read_support_format_iso9660.c @@ -1756,7 +1756,8 @@ parse_file_info(struct archive_read *a, struct file_info *parent, */ if (location > 0 && (location + ((fsize + iso9660->logical_block_size -1) - / iso9660->logical_block_size)) > iso9660->volume_block) { + / iso9660->logical_block_size)) + > (uint32_t)iso9660->volume_block) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid location of extent of file"); return (NULL); @@ -2254,7 +2255,7 @@ register_CE(struct archive_read *a, int32_t location, offset >= file->offset) || offset < iso9660->current_position || (((uint64_t)file->ce_offset) + file->ce_size) - > iso9660->logical_block_size || + > (uint64_t)iso9660->logical_block_size || offset + file->ce_offset + file->ce_size > iso9660->volume_size) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index f3c7d282b..4f0bf0ed4 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -289,7 +289,7 @@ static void lzh_huffman_free(struct huffman *); static int lzh_read_pt_bitlen(struct lzh_stream *, int start, int end); static int lzh_make_fake_table(struct huffman *, uint16_t); static int lzh_make_huffman_table(struct huffman *); -static int inline lzh_decode_huffman(struct huffman *, unsigned); +static inline int lzh_decode_huffman(struct huffman *, unsigned); static int lzh_decode_huffman_tree(struct huffman *, unsigned, int); diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index c70e0e5b3..192697af0 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -2408,9 +2408,9 @@ expand(struct archive_read *a, int64_t end) if ((lensymbol = read_next_symbol(a, &rar->lengthcode)) < 0) goto bad_data; - if (lensymbol > sizeof(lengthbases)/sizeof(lengthbases[0])) + if (lensymbol > (int)(sizeof(lengthbases)/sizeof(lengthbases[0]))) goto bad_data; - if (lensymbol > sizeof(lengthbits)/sizeof(lengthbits[0])) + if (lensymbol > (int)(sizeof(lengthbits)/sizeof(lengthbits[0]))) goto bad_data; len = lengthbases[lensymbol] + 2; if (lengthbits[lensymbol] > 0) { @@ -2442,9 +2442,9 @@ expand(struct archive_read *a, int64_t end) } else { - if (symbol-271 > sizeof(lengthbases)/sizeof(lengthbases[0])) + if (symbol-271 > (int)(sizeof(lengthbases)/sizeof(lengthbases[0]))) goto bad_data; - if (symbol-271 > sizeof(lengthbits)/sizeof(lengthbits[0])) + if (symbol-271 > (int)(sizeof(lengthbits)/sizeof(lengthbits[0]))) goto bad_data; len = lengthbases[symbol-271]+3; if(lengthbits[symbol-271] > 0) { @@ -2456,9 +2456,9 @@ expand(struct archive_read *a, int64_t end) if ((offssymbol = read_next_symbol(a, &rar->offsetcode)) < 0) goto bad_data; - if (offssymbol > sizeof(offsetbases)/sizeof(offsetbases[0])) + if (offssymbol > (int)(sizeof(offsetbases)/sizeof(offsetbases[0]))) goto bad_data; - if (offssymbol > sizeof(offsetbits)/sizeof(offsetbits[0])) + if (offssymbol > (int)(sizeof(offsetbits)/sizeof(offsetbits[0]))) goto bad_data; offs = offsetbases[offssymbol]+1; if(offsetbits[offssymbol] > 0) diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index 42412880f..eb255819c 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -2333,6 +2333,8 @@ solaris_sparse_parse(struct archive_read *a, struct tar *tar, int64_t start, end; int hole = 1; + (void)entry; /* UNUSED */ + end = 0; if (*p == ' ') p++; diff --git a/libarchive/archive_read_support_format_xar.c b/libarchive/archive_read_support_format_xar.c index 3c01cbe43..92569bb64 100644 --- a/libarchive/archive_read_support_format_xar.c +++ b/libarchive/archive_read_support_format_xar.c @@ -2624,6 +2624,7 @@ strappend_base64(struct xar *xar, const unsigned char *b; size_t len; + (void)xar; /* UNUSED */ len = 0; out = buff; b = (const unsigned char *)s; diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index 2201ef74e..5d129376f 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -785,7 +785,7 @@ compression_name(int compression) }; if (compression < - sizeof(compression_names)/sizeof(compression_names[0])) + (int)(sizeof(compression_names)/sizeof(compression_names[0]))) return compression_names[compression]; else return "??"; @@ -928,6 +928,8 @@ zip_read_data_none(struct archive_read *a, const void **_buff, const char *buff; ssize_t bytes_avail; + (void)offset; /* UNUSED */ + zip = (struct zip *)(a->format->data); if (zip->entry->flags & ZIP_LENGTH_AT_END) { @@ -1008,6 +1010,8 @@ zip_read_data_deflate(struct archive_read *a, const void **buff, const void *compressed_buff; int r; + (void)offset; /* UNUSED */ + zip = (struct zip *)(a->format->data); /* If the buffer hasn't been allocated, allocate it now. */ diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c index 22b8d8b7c..21b02e9b0 100644 --- a/libarchive/archive_string.c +++ b/libarchive/archive_string.c @@ -1195,7 +1195,7 @@ create_sconv_object(const char *fc, const char *tc, * Check if "from charset" and "to charset" are the same. */ if (strcmp(fc, tc) == 0 || - (sc->from_cp != -1 && sc->from_cp == sc->to_cp)) + (sc->from_cp != (unsigned)-1 && sc->from_cp == sc->to_cp)) sc->same = 1; else sc->same = 0; diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index 7760ad734..f36fb24e0 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -2086,6 +2086,9 @@ set_times(struct archive_write_disk *a, mtime_nanos, ctime, ctime_nanos) == 0) { return (ARCHIVE_OK); } +#else /* Tru64 */ + (void)ctime; /* UNUSED */ + (void)ctime_nanos; /* UNUSED */ #endif /* Tru64 */ #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME diff --git a/libarchive/archive_write_set_format_7zip.c b/libarchive/archive_write_set_format_7zip.c index 089ea0d54..9fbf98bcf 100644 --- a/libarchive/archive_write_set_format_7zip.c +++ b/libarchive/archive_write_set_format_7zip.c @@ -846,7 +846,7 @@ enc_uint64(struct archive_write *a, uint64_t val) int i; numdata[0] = 0; - for (i = 1; i < sizeof(numdata); i++) { + for (i = 1; i < (int)sizeof(numdata); i++) { if (val < mask) { numdata[0] |= (uint8_t)val; break; @@ -2179,6 +2179,8 @@ compression_code_ppmd(struct archive *a, { struct ppmd_stream *strm; + (void)a; /* UNUSED */ + strm = (struct ppmd_stream *)lastrm->real_stream; /* Copy encoded data if there are remaining bytes from previous call. */ @@ -2219,6 +2221,8 @@ compression_end_ppmd(struct archive *a, struct la_zstream *lastrm) { struct ppmd_stream *strm; + (void)a; /* UNUSED */ + strm = (struct ppmd_stream *)lastrm->real_stream; __archive_ppmd7_functions.Ppmd7_Free(&strm->ppmd7_context, &g_szalloc); free(strm->buff); diff --git a/libarchive/archive_write_set_format_xar.c b/libarchive/archive_write_set_format_xar.c index bb9b55184..31f674508 100644 --- a/libarchive/archive_write_set_format_xar.c +++ b/libarchive/archive_write_set_format_xar.c @@ -676,7 +676,7 @@ xar_write_data(struct archive_write *a, const void *buff, size_t s) } #if !defined(_WIN32) || defined(__CYGWIN__) if (xar->bytes_remaining == - archive_entry_size(xar->cur_file->entry)) { + (uint64_t)archive_entry_size(xar->cur_file->entry)) { /* * Get the path of a shell script if so. */ @@ -1938,6 +1938,8 @@ file_create_virtual_dir(struct archive_write *a, struct xar *xar, { struct file *file; + (void)xar; /* UNUSED */ + file = file_new(a, NULL); if (file == NULL) return (NULL); diff --git a/libarchive/test/test_acl_nfs4.c b/libarchive/test/test_acl_nfs4.c index 820b9d60f..ebf9a4656 100644 --- a/libarchive/test/test_acl_nfs4.c +++ b/libarchive/test/test_acl_nfs4.c @@ -276,7 +276,7 @@ DEFINE_TEST(test_acl_nfs4) * fail when added to existing NFS4 ACLs. */ set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); - for (i = 0; i < sizeof(acls_bad)/sizeof(acls_bad[0]); ++i) { + for (i = 0; i < (int)(sizeof(acls_bad)/sizeof(acls_bad[0])); ++i) { struct acl_t *p = &acls_bad[i]; failure("Malformed ACL test #%d", i); assertEqualInt(ARCHIVE_FAILED, diff --git a/libarchive/test/test_acl_posix1e.c b/libarchive/test/test_acl_posix1e.c index bbe8bcde2..68e76671b 100644 --- a/libarchive/test/test_acl_posix1e.c +++ b/libarchive/test/test_acl_posix1e.c @@ -263,7 +263,7 @@ DEFINE_TEST(test_acl_posix1e) * fail when added to existing POSIX.1e ACLs. */ set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); - for (i = 0; i < sizeof(acls_nfs4)/sizeof(acls_nfs4[0]); ++i) { + for (i = 0; i < (int)(sizeof(acls_nfs4)/sizeof(acls_nfs4[0])); ++i) { struct acl_t *p = &acls_nfs4[i]; failure("Malformed ACL test #%d", i); assertEqualInt(ARCHIVE_FAILED, diff --git a/libarchive/test/test_read_disk_directory_traversals.c b/libarchive/test/test_read_disk_directory_traversals.c index 0477b2cda..3ecfbc2d5 100644 --- a/libarchive/test/test_read_disk_directory_traversals.c +++ b/libarchive/test/test_read_disk_directory_traversals.c @@ -1276,6 +1276,8 @@ test_restore_atime(void) static int metadata_filter(struct archive *a, void *data, struct archive_entry *ae) { + (void)data; /* UNUSED */ + failure("CTime should be set"); assertEqualInt(8, archive_entry_ctime_is_set(ae)); failure("MTime should be set"); diff --git a/libarchive/test/test_read_format_mtree.c b/libarchive/test/test_read_format_mtree.c index 1e5e585e7..0d86bd478 100644 --- a/libarchive/test/test_read_format_mtree.c +++ b/libarchive/test/test_read_format_mtree.c @@ -36,7 +36,7 @@ test_read_format_mtree1(void) /* Compute max 64-bit signed twos-complement value * without relying on overflow. This assumes that long long * is at least 64 bits. */ - const static long long max_int64 = ((((long long)1) << 62) - 1) + (((long long)1) << 62); + static const long long max_int64 = ((((long long)1) << 62) - 1) + (((long long)1) << 62); time_t min_time, t; extract_reference_file(reffile); diff --git a/libarchive/test/test_write_disk_lookup.c b/libarchive/test/test_write_disk_lookup.c index 2a5ea4abb..cabdae8dd 100644 --- a/libarchive/test/test_write_disk_lookup.c +++ b/libarchive/test/test_write_disk_lookup.c @@ -37,6 +37,9 @@ static int64_t group_lookup(void *d, const char *name, int64_t g) { int *mp = d; + + (void)g; /* UNUSED */ + assertEqualInt(*mp, 0x13579); if (strcmp(name, "FOOGROUP")) return (1); @@ -55,6 +58,9 @@ static int64_t user_lookup(void *d, const char *name, int64_t u) { int *mp = d; + + (void)u; /* UNUSED */ + assertEqualInt(*mp, 0x1234); if (strcmp("FOO", name) == 0) return (2); diff --git a/libarchive/test/test_write_format_iso9660_filename.c b/libarchive/test/test_write_format_iso9660_filename.c index 337233e56..ce3fa82ef 100644 --- a/libarchive/test/test_write_format_iso9660_filename.c +++ b/libarchive/test/test_write_format_iso9660_filename.c @@ -228,11 +228,11 @@ create_iso_image(unsigned char *buff, size_t buffsize, size_t *used, sym1[0] = 'x'; sym1[1] = '\0'; - for (i = 0; i < sizeof(sym128)-2; i++) + for (i = 0; i < (int)sizeof(sym128)-2; i++) sym128[i] = 'a'; sym128[sizeof(sym128)-2] = 'x'; sym128[sizeof(sym128)-1] = '\0'; - for (i = 0; i < sizeof(sym255)-2; i++) + for (i = 0; i < (int)sizeof(sym255)-2; i++) sym255[i] = 'a'; sym255[sizeof(sym255)-2] = 'x'; sym255[sizeof(sym255)-1] = '\0'; diff --git a/libarchive/test/test_write_format_iso9660_zisofs.c b/libarchive/test/test_write_format_iso9660_zisofs.c index 7db9b5013..2e3e03f15 100644 --- a/libarchive/test/test_write_format_iso9660_zisofs.c +++ b/libarchive/test/test_write_format_iso9660_zisofs.c @@ -365,10 +365,10 @@ test_write_format_iso9660_zisofs_2(void) for (i = 0; i < 256; i++) { int j; if (i == 0) { - for (j = 0; j < sizeof(data); j++) + for (j = 0; j < (int)sizeof(data); j++) data[j] = (i^j) & 0xff; } else { - for (j = 0; j < sizeof(data); j++) + for (j = 0; j < (int)sizeof(data); j++) data[j] ^= i+j; } assertEqualIntA(a, 1024, archive_write_data(a, data, 1024));