Permalink
Browse files

Fix build failure with -Wextra -Wunused GCC options since it happend …

…on FreeBSD current.
  • Loading branch information...
1 parent 2b046ef commit 433f74b08f999c970b31ba36307bd05a77e0f135 @ggcueroad ggcueroad committed Feb 8, 2012
@@ -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;
@@ -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
@@ -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);
@@ -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,
@@ -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);
@@ -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)
@@ -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++;
@@ -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;
@@ -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. */
@@ -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;
@@ -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
@@ -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);
@@ -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);
@@ -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,
@@ -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,
@@ -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");
@@ -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);
@@ -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);
@@ -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';
@@ -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));

0 comments on commit 433f74b

Please sign in to comment.