From: Michihiro NAKAJIMA Date: Wed, 7 Nov 2012 06:25:47 +0000 (+0900) Subject: Fix build failure on Win64. X-Git-Tag: v3.1.0~39^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f54591d05a9b4d593cda12a48cf13cab43bb5db;p=thirdparty%2Flibarchive.git Fix build failure on Win64. --- diff --git a/cpio/cpio.c b/cpio/cpio.c index 95e8e0806..6f57d95d6 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -840,18 +840,21 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry) exit(1); if (r >= ARCHIVE_WARN && archive_entry_size(entry) > 0 && fd >= 0) { - bytes_read = read(fd, cpio->buff, cpio->buff_size); + bytes_read = read(fd, cpio->buff, (unsigned)cpio->buff_size); while (bytes_read > 0) { - r = archive_write_data(cpio->archive, + ssize_t bytes_write; + bytes_write = archive_write_data(cpio->archive, cpio->buff, bytes_read); - if (r < 0) + if (bytes_write < 0) lafe_errc(1, archive_errno(cpio->archive), "%s", archive_error_string(cpio->archive)); - if (r < bytes_read) { + if (bytes_write < bytes_read) { lafe_warnc(0, - "Truncated write; file may have grown while being archived."); + "Truncated write; file may have " + "grown while being archived."); } - bytes_read = read(fd, cpio->buff, cpio->buff_size); + bytes_read = read(fd, cpio->buff, + (unsigned)cpio->buff_size); } } @@ -1023,7 +1026,7 @@ extract_data(struct archive *ar, struct archive *aw) "%s", archive_error_string(ar)); exit(1); } - r = archive_write_data_block(aw, block, size, offset); + r = (int)archive_write_data_block(aw, block, size, offset); if (r != ARCHIVE_OK) { lafe_warnc(archive_errno(aw), "%s", archive_error_string(aw)); diff --git a/cpio/test/main.c b/cpio/test/main.c index 26511fe9a..5ea9c0db8 100644 --- a/cpio/test/main.c +++ b/cpio/test/main.c @@ -624,8 +624,8 @@ assertion_equal_string(const char *file, int line, if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0)) return (1); failure_start(file, line, "%s != %s", e1, e2); - l1 = strlen(e1); - l2 = strlen(e2); + l1 = (int)strlen(e1); + l2 = (int)strlen(e2); if (l1 < l2) l1 = l2; strdump(e1, v1, l1, utf8); @@ -847,8 +847,8 @@ assertion_equal_file(const char *filename, int line, const char *fn1, const char return (0); } for (;;) { - n1 = fread(buff1, 1, sizeof(buff1), f1); - n2 = fread(buff2, 1, sizeof(buff2), f2); + n1 = (int)fread(buff1, 1, sizeof(buff1), f1); + n2 = (int)fread(buff2, 1, sizeof(buff2), f2); if (n1 != n2) break; if (n1 == 0 && n2 == 0) { @@ -922,7 +922,7 @@ assertion_file_contents(const char *filename, int line, const void *buff, int s, return (0); } contents = malloc(s * 2); - n = fread(contents, 1, s * 2, f); + n = (int)fread(contents, 1, s * 2, f); fclose(f); if (n == s && memcmp(buff, contents, s) == 0) { free(contents); @@ -958,9 +958,9 @@ assertion_text_file_contents(const char *filename, int line, const char *buff, c failure_finish(NULL); return (0); } - s = strlen(buff); + s = (int)strlen(buff); contents = malloc(s * 2 + 128); - n = fread(contents, 1, s * 2 + 128 - 1, f); + n = (int)fread(contents, 1, s * 2 + 128 - 1, f); if (n >= 0) contents[n] = '\0'; fclose(f); diff --git a/libarchive/archive_crypto.c b/libarchive/archive_crypto.c index 2caf57169..af9936d75 100644 --- a/libarchive/archive_crypto.c +++ b/libarchive/archive_crypto.c @@ -90,7 +90,7 @@ win_crypto_Update(Digest_CTX *ctx, const unsigned char *buf, size_t len) static int win_crypto_Final(unsigned char *buf, size_t bufsize, Digest_CTX *ctx) { - DWORD siglen = bufsize; + DWORD siglen = (DWORD)bufsize; if (!ctx->valid) return (ARCHIVE_FAILED); diff --git a/libarchive/archive_match.c b/libarchive/archive_match.c index 6170dc539..ba348be57 100644 --- a/libarchive/archive_match.c +++ b/libarchive/archive_match.c @@ -1712,7 +1712,7 @@ match_owner_id(struct id_array *ids, int64_t id) unsigned b, m, t; t = 0; - b = ids->count; + b = (unsigned)ids->count; while (t < b) { m = (t + b)>>1; if (ids->ids[m] == id) diff --git a/libarchive/archive_read_disk_windows.c b/libarchive/archive_read_disk_windows.c index 40a1ca8c3..c117faf69 100644 --- a/libarchive/archive_read_disk_windows.c +++ b/libarchive/archive_read_disk_windows.c @@ -597,7 +597,7 @@ start_next_async_read(struct archive_read_disk *a, struct tree *t) } else ResetEvent(olp->ol.hEvent); - buffbytes = olp->buff_size; + buffbytes = (DWORD)olp->buff_size; if (buffbytes > t->current_sparse->length) buffbytes = (DWORD)t->current_sparse->length; @@ -698,7 +698,7 @@ _archive_read_data_block(struct archive *_a, const void **buff, olp = &(t->ol[t->ol_idx_done]); t->ol_idx_done = (t->ol_idx_done + 1) % MAX_OVERLAPPED; if (olp->bytes_transferred) - bytes_transferred = olp->bytes_transferred; + bytes_transferred = (DWORD)olp->bytes_transferred; else if (!GetOverlappedResult(t->entry_fh, &(olp->ol), &bytes_transferred, TRUE)) { la_dosmaperr(GetLastError()); @@ -1268,7 +1268,7 @@ update_current_filesystem(struct archive_read_disk *a, int64_t dev) return (ARCHIVE_FATAL); } t->filesystem_table = (struct filesystem *)p; - t->allocated_filesytem = s; + t->allocated_filesytem = (int)s; } t->current_filesystem_id = fid; t->current_filesystem = &(t->filesystem_table[fid]); @@ -2236,7 +2236,7 @@ setup_sparse_from_disk(struct archive_read_disk *a, ret = DeviceIoControl(handle, FSCTL_QUERY_ALLOCATED_RANGES, &range, sizeof(range), outranges, - outranges_size, &retbytes, NULL); + (DWORD)outranges_size, &retbytes, NULL); if (ret == 0 && GetLastError() == ERROR_MORE_DATA) { free(outranges); outranges_size *= 2; diff --git a/libarchive/archive_read_extract.c b/libarchive/archive_read_extract.c index aad8ac516..795f2abea 100644 --- a/libarchive/archive_read_extract.c +++ b/libarchive/archive_read_extract.c @@ -154,7 +154,7 @@ copy_data(struct archive *ar, struct archive *aw) return (ARCHIVE_OK); if (r != ARCHIVE_OK) return (r); - r = archive_write_data_block(aw, buff, size, offset); + r = (int)archive_write_data_block(aw, buff, size, offset); if (r < ARCHIVE_WARN) r = ARCHIVE_WARN; if (r != ARCHIVE_OK) { diff --git a/libarchive/archive_read_support_filter_gzip.c b/libarchive/archive_read_support_filter_gzip.c index 50a6a6bf5..a2b399781 100644 --- a/libarchive/archive_read_support_filter_gzip.c +++ b/libarchive/archive_read_support_filter_gzip.c @@ -121,7 +121,7 @@ archive_read_support_filter_gzip(struct archive *_a) * number of bytes in header. If pbits is non-NULL, it receives a * count of bits verified, suitable for use by bidder. */ -static int +static ssize_t peek_at_header(struct archive_read_filter *filter, int *pbits) { const unsigned char *p; diff --git a/libarchive/archive_read_support_filter_lrzip.c b/libarchive/archive_read_support_filter_lrzip.c index d8ae92113..0b2924243 100644 --- a/libarchive/archive_read_support_filter_lrzip.c +++ b/libarchive/archive_read_support_filter_lrzip.c @@ -113,7 +113,7 @@ lrzip_bidder_bid(struct archive_read_filter_bidder *self, if ((i < 6) || (i > 10)) return 0; - return len; + return (int)len; } static int diff --git a/libarchive/archive_read_support_filter_lzop.c b/libarchive/archive_read_support_filter_lzop.c index b3a0ed154..321130a8e 100644 --- a/libarchive/archive_read_support_filter_lzop.c +++ b/libarchive/archive_read_support_filter_lzop.c @@ -28,7 +28,9 @@ __FBSDID("$FreeBSD$"); +#ifdef HAVE_UNISTD_H #include +#endif #ifdef HAVE_ERRNO_H #include #endif diff --git a/libarchive/archive_read_support_filter_uu.c b/libarchive/archive_read_support_filter_uu.c index be2703797..493338d0b 100644 --- a/libarchive/archive_read_support_filter_uu.c +++ b/libarchive/archive_read_support_filter_uu.c @@ -490,7 +490,7 @@ read_more: uudecode->in_cnt = 0; } for (;used < avail_in; d += llen, used += llen) { - int l, body; + int64_t l, body; b = d; len = get_line(b, avail_in - used, &nl); @@ -518,7 +518,7 @@ read_more: return (ARCHIVE_FATAL); if (uudecode->in_buff != b) memmove(uudecode->in_buff, b, len); - uudecode->in_cnt = len; + uudecode->in_cnt = (int)len; if (total == 0) { /* Do not return 0; it means end-of-file. * We should try to read bytes more. */ diff --git a/libarchive/archive_read_support_format_7zip.c b/libarchive/archive_read_support_format_7zip.c index 494028e88..9e29d74fb 100644 --- a/libarchive/archive_read_support_format_7zip.c +++ b/libarchive/archive_read_support_format_7zip.c @@ -3099,7 +3099,7 @@ read_stream(struct archive_read *a, const void **buff, size_t size, { struct _7zip *zip = (struct _7zip *)a->format->data; uint64_t skip_bytes = 0; - int r; + ssize_t r; if (zip->uncompressed_buffer_bytes_remaining == 0) { if (zip->pack_stream_inbytes_remaining > 0) { @@ -3379,7 +3379,7 @@ setup_decode_folder(struct archive_read *a, struct _7z_folder *folder, /* Extract a sub stream. */ while (zip->pack_stream_inbytes_remaining > 0) { - r = extract_pack_stream(a, 0); + r = (int)extract_pack_stream(a, 0); if (r < 0) { free(b[0]); free(b[1]); free(b[2]); return (r); @@ -3570,7 +3570,7 @@ x86_Convert(struct _7zip *zip, uint8_t *data, size_t size) } zip->bcj_prevPosT = prevPosT; zip->bcj_prevMask = prevMask; - zip->bcj_ip += bufferPos; + zip->bcj_ip += (uint32_t)bufferPos; return (bufferPos); } @@ -3714,7 +3714,7 @@ Bcj2_Decode(struct _7zip *zip, uint8_t *outBuf, size_t outSize) ((uint32_t)v[1] << 16) | ((uint32_t)v[2] << 8) | ((uint32_t)v[3])) - - ((uint32_t)zip->bcj2_outPos + outPos + 4); + ((uint32_t)zip->bcj2_outPos + (uint32_t)outPos + 4); out[0] = (uint8_t)dest; out[1] = (uint8_t)(dest >> 8); out[2] = (uint8_t)(dest >> 16); @@ -3729,7 +3729,7 @@ Bcj2_Decode(struct _7zip *zip, uint8_t *outBuf, size_t outSize) */ zip->odd_bcj_size = 4 -i; for (; i < 4; i++) { - j = i - 4 + zip->odd_bcj_size; + j = i - 4 + (unsigned)zip->odd_bcj_size; zip->odd_bcj[j] = out[i]; } break; diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c index f8a197f2b..20bbc5db1 100644 --- a/libarchive/archive_read_support_format_cab.c +++ b/libarchive/archive_read_support_format_cab.c @@ -540,7 +540,7 @@ truncated_error(struct archive_read *a) return (ARCHIVE_FATAL); } -static int +static ssize_t cab_strnlen(const unsigned char *p, size_t maxlen) { size_t i; @@ -551,7 +551,7 @@ cab_strnlen(const unsigned char *p, size_t maxlen) } if (i > maxlen) return (-1);/* invalid */ - return (i); + return ((ssize_t)i); } /* Read bytes as much as remaining. */ @@ -627,8 +627,9 @@ cab_read_header(struct archive_read *a) struct cab *cab; struct cfheader *hd; size_t bytes, used; + ssize_t len; int64_t skip; - int err, i, len; + int err, i; int cur_folder, prev_folder; uint32_t offset32; @@ -1067,13 +1068,13 @@ static uint32_t cab_checksum_cfdata_4(const void *p, size_t bytes, uint32_t seed) { const unsigned char *b; - int u32num; + unsigned u32num; uint32_t sum; - u32num = bytes / 4; + u32num = (unsigned)bytes / 4; sum = seed; b = p; - while (--u32num >= 0) { + for (;u32num > 0; --u32num) { sum ^= archive_le32dec(b); b += 4; } @@ -1936,7 +1937,7 @@ cab_read_data(struct archive_read *a, const void **buff, ARCHIVE_ERRNO_FILE_FORMAT, "Invalid CFDATA"); return (ARCHIVE_FATAL); } else - return (bytes_avail); + return ((int)bytes_avail); } if (bytes_avail > cab->entry_bytes_remaining) bytes_avail = (ssize_t)cab->entry_bytes_remaining; @@ -2200,7 +2201,7 @@ lzx_translation(struct lzx_stream *strm, void *p, size_t size, uint32_t offset) size_t i = b - (unsigned char *)p; int32_t cp, displacement, value; - cp = offset + i; + cp = (int32_t)(offset + (uint32_t)i); value = archive_le32dec(&b[1]); if (value >= -cp && value < (int32_t)ds->translation_size) { if (value >= 0) @@ -2586,7 +2587,7 @@ lzx_read_blocks(struct lzx_stream *strm, int last) goto failed; return (ARCHIVE_OK); } - l = ds->block_bytes_avail; + l = (int)ds->block_bytes_avail; if (l > ds->w_size - ds->w_pos) l = ds->w_size - ds->w_pos; if (l > strm->avail_out) @@ -2966,7 +2967,7 @@ lzx_decode_blocks(struct lzx_stream *strm, int last) l = w_size - w_pos; } if (noutp + l >= endp) - l = endp - noutp; + l = (int)(endp - noutp); s = w_buff + copy_pos; if (l >= 8 && ((copy_pos + l < w_pos) || (w_pos + l < copy_pos))) { @@ -3128,7 +3129,7 @@ lzx_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits) hf->bitlen = calloc(len_size, sizeof(hf->bitlen[0])); if (hf->bitlen == NULL) return (ARCHIVE_FATAL); - hf->len_size = len_size; + hf->len_size = (int)len_size; } else memset(hf->bitlen, 0, len_size * sizeof(hf->bitlen[0])); if (hf->tbl == NULL) { @@ -3136,7 +3137,7 @@ lzx_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits) bits = tbl_bits; else bits = HTBL_BITS; - hf->tbl = malloc((1 << bits) * sizeof(hf->tbl[0])); + hf->tbl = malloc(((size_t)1 << bits) * sizeof(hf->tbl[0])); if (hf->tbl == NULL) return (ARCHIVE_FATAL); hf->tbl_bits = tbl_bits; diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index a7c071e1a..f702949fb 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -272,7 +272,7 @@ static int lha_skip_sfx(struct archive_read *); static time_t lha_dos_time(const unsigned char *); static time_t lha_win_time(uint64_t, long *); static unsigned char lha_calcsum(unsigned char, const void *, - int, int); + int, size_t); static int lha_parse_linkname(struct archive_string *, struct archive_string *); static int lha_read_data_none(struct archive_read *, const void **, @@ -1635,7 +1635,7 @@ lha_parse_linkname(struct archive_string *linkname, struct archive_string *pathname) { char * linkptr; - int symlen; + size_t symlen; linkptr = strchr(pathname->s, '|'); if (linkptr != NULL) { @@ -1690,12 +1690,12 @@ lha_win_time(uint64_t wintime, long *ns) } static unsigned char -lha_calcsum(unsigned char sum, const void *pp, int offset, int size) +lha_calcsum(unsigned char sum, const void *pp, int offset, size_t size) { unsigned char const *p = (unsigned char const *)pp; p += offset; - while (--size >= 0) + for (;size > 0; --size) sum += *p++; return (sum); } @@ -2020,7 +2020,7 @@ lzh_copy_from_window(struct lzh_stream *strm, struct lzh_dec *ds) copy_bytes = (size_t)strm->avail_out; memcpy(strm->next_out, ds->w_buff + ds->copy_pos, copy_bytes); - ds->copy_pos += copy_bytes; + ds->copy_pos += (int)copy_bytes; } else { if (ds->w_remaining <= strm->avail_out) copy_bytes = ds->w_remaining; @@ -2028,7 +2028,7 @@ lzh_copy_from_window(struct lzh_stream *strm, struct lzh_dec *ds) copy_bytes = (size_t)strm->avail_out; memcpy(strm->next_out, ds->w_buff + ds->w_size - ds->w_remaining, copy_bytes); - ds->w_remaining -= copy_bytes; + ds->w_remaining -= (int)copy_bytes; } strm->next_out += copy_bytes; strm->avail_out -= copy_bytes; @@ -2482,7 +2482,7 @@ lzh_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits) bits = tbl_bits; else bits = HTBL_BITS; - hf->tbl = malloc((1 << bits) * sizeof(hf->tbl[0])); + hf->tbl = malloc(((size_t)1 << bits) * sizeof(hf->tbl[0])); if (hf->tbl == NULL) return (ARCHIVE_FATAL); } @@ -2492,7 +2492,7 @@ lzh_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits) if (hf->tree == NULL) return (ARCHIVE_FATAL); } - hf->len_size = len_size; + hf->len_size = (int)len_size; hf->tbl_bits = tbl_bits; return (ARCHIVE_OK); } diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index 7fd9e4661..c4e7021a8 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -354,7 +354,7 @@ bid_keycmp(const char *p, const char *key, ssize_t len) * Returns the length of a detected keyword. * Returns 0 if any keywords were not found. */ -static ssize_t +static int bid_keyword(const char *p, ssize_t len) { static const char *keys_c[] = { @@ -592,8 +592,8 @@ detect_form(struct archive_read *a, int *is_form_d) { const char *p; ssize_t avail, ravail; - ssize_t len, nl; - int detected_bytes = 0, entry_cnt = 0, multiline = 0; + ssize_t detected_bytes = 0, len, nl; + int entry_cnt = 0, multiline = 0; int form_D = 0;/* The archive is generated by `NetBSD mtree -D' * (In this source we call it `form D') . */ @@ -942,7 +942,7 @@ read_mtree(struct archive_read *a, struct mtree *mtree) } if (len < 0) { free_options(global); - return (len); + return ((int)len); } /* Leading whitespace is never significant, ignore it. */ while (*p == ' ' || *p == '\t') { diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index 83ea8d85a..98b998bb1 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -1287,13 +1287,13 @@ read_header(struct archive_read *a, struct archive_entry *entry, { if (filename_size != strlen(filename)) { - unsigned char highbyte, flagbits, flagbyte, offset; - unsigned fn_end; + unsigned char highbyte, flagbits, flagbyte; + unsigned fn_end, offset; end = filename_size; fn_end = filename_size * 2; filename_size = 0; - offset = strlen(filename) + 1; + offset = (unsigned)strlen(filename) + 1; highbyte = *(p + offset++); flagbits = 0; flagbyte = 0; @@ -1753,7 +1753,7 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size, bs = rar->unp_buffer_size - rar->unp_offset; else bs = (size_t)rar->bytes_uncopied; - ret = copy_from_lzss_window(a, buff, rar->offset, bs); + ret = copy_from_lzss_window(a, buff, rar->offset, (int)bs); if (ret != ARCHIVE_OK) return (ret); rar->offset += bs; @@ -1881,7 +1881,7 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size, bs = rar->unp_buffer_size - rar->unp_offset; else bs = (size_t)rar->bytes_uncopied; - ret = copy_from_lzss_window(a, buff, rar->offset, bs); + ret = copy_from_lzss_window(a, buff, rar->offset, (int)bs); if (ret != ARCHIVE_OK) return (ret); rar->offset += bs; @@ -2413,7 +2413,7 @@ make_table(struct archive_read *a, struct huffman_code *code) code->table = (struct huffman_table_entry *)calloc(1, sizeof(*code->table) - * (1 << code->tablesize)); + * ((size_t)1 << code->tablesize)); return make_table_recurse(a, code, 0, code->table, 0, code->tablesize); } diff --git a/libarchive/archive_read_support_format_raw.c b/libarchive/archive_read_support_format_raw.c index e371ce815..843497878 100644 --- a/libarchive/archive_read_support_format_raw.c +++ b/libarchive/archive_read_support_format_raw.c @@ -158,7 +158,7 @@ archive_read_format_raw_read_data(struct archive_read *a, /* Record and return an error. */ *size = 0; *offset = info->offset; - return (avail); + return ((int)avail); } } diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index 7c38125f6..7ae2e0b5e 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -210,10 +210,10 @@ static int read_body_to_string(struct archive_read *, struct tar *, struct archive_string *, const void *h, size_t *); static int solaris_sparse_parse(struct archive_read *, struct tar *, struct archive_entry *, const char *); -static int64_t tar_atol(const char *, unsigned); -static int64_t tar_atol10(const char *, unsigned); -static int64_t tar_atol256(const char *, unsigned); -static int64_t tar_atol8(const char *, unsigned); +static int64_t tar_atol(const char *, size_t); +static int64_t tar_atol10(const char *, size_t); +static int64_t tar_atol256(const char *, size_t); +static int64_t tar_atol8(const char *, size_t); static int tar_read_header(struct archive_read *, struct tar *, struct archive_entry *, size_t *); static int tohex(int c); @@ -623,7 +623,7 @@ tar_read_header(struct archive_read *a, struct tar *tar, /* Read 512-byte header record */ h = __archive_read_ahead(a, 512, &bytes); if (bytes < 0) - return (bytes); + return ((int)bytes); if (bytes == 0) { /* EOF at a block boundary. */ /* Some writers do omit the block of nulls. */ return (ARCHIVE_EOF); @@ -753,7 +753,7 @@ tar_read_header(struct archive_read *a, struct tar *tar, bytes_read = gnu_sparse_10_read(a, tar, unconsumed); tar->entry_bytes_remaining -= bytes_read; if (bytes_read < 0) - return (bytes_read); + return ((int)bytes_read); } else { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, @@ -2391,7 +2391,7 @@ solaris_sparse_parse(struct archive_read *a, struct tar *tar, * On read, this implementation supports both extensions. */ static int64_t -tar_atol(const char *p, unsigned char_cnt) +tar_atol(const char *p, size_t char_cnt) { /* * Technically, GNU tar considers a field to be in base-256 @@ -2408,7 +2408,7 @@ tar_atol(const char *p, unsigned char_cnt) * it does obey locale. */ static int64_t -tar_atol_base_n(const char *p, unsigned char_cnt, int base) +tar_atol_base_n(const char *p, size_t char_cnt, int base) { int64_t l, limit, last_digit_limit; int digit, sign; @@ -2448,13 +2448,13 @@ tar_atol_base_n(const char *p, unsigned char_cnt, int base) } static int64_t -tar_atol8(const char *p, unsigned char_cnt) +tar_atol8(const char *p, size_t char_cnt) { return tar_atol_base_n(p, char_cnt, 8); } static int64_t -tar_atol10(const char *p, unsigned char_cnt) +tar_atol10(const char *p, size_t char_cnt) { return tar_atol_base_n(p, char_cnt, 10); } @@ -2465,7 +2465,7 @@ tar_atol10(const char *p, unsigned char_cnt) * ignored. */ static int64_t -tar_atol256(const char *_p, unsigned char_cnt) +tar_atol256(const char *_p, size_t char_cnt) { int64_t l, upper_limit, lower_limit; const unsigned char *p = (const unsigned char *)_p; diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c index 92ae14566..87f9288f1 100644 --- a/libarchive/archive_string.c +++ b/libarchive/archive_string.c @@ -486,13 +486,13 @@ archive_wstring_append_from_mbs_in_codepage(struct archive_wstring *dest, * UTF-16BE/LE NFD ===> UTF-16 NFC * UTF-16BE/LE NFC ===> UTF-16 NFD */ - count = utf16nbytes(s, length); + count = (int)utf16nbytes(s, length); } else { /* * UTF-8 NFD ===> UTF-16 NFC * UTF-8 NFC ===> UTF-16 NFD */ - count = mbsnbytes(s, length); + count = (int)mbsnbytes(s, length); } u16.s = (char *)dest->s; u16.length = dest->length << 1;; @@ -507,7 +507,7 @@ archive_wstring_append_from_mbs_in_codepage(struct archive_wstring *dest, sc->flag = saved_flag;/* restore the saved flag. */ return (ret); } else if (sc != NULL && (sc->flag & SCONV_FROM_UTF16)) { - count = utf16nbytes(s, length); + count = (int)utf16nbytes(s, length); count >>= 1; /* to be WCS length */ /* Allocate memory for WCS. */ if (NULL == archive_wstring_ensure(dest, @@ -550,8 +550,8 @@ archive_wstring_append_from_mbs_in_codepage(struct archive_wstring *dest, return (-1); /* Convert MBS to WCS. */ count = MultiByteToWideChar(from_cp, - mbflag, s, length, dest->s + dest->length, - (dest->buffer_length >> 1) -1); + mbflag, s, (int)length, dest->s + dest->length, + (int)(dest->buffer_length >> 1) -1); if (count == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { /* Expand the WCS buffer. */ @@ -727,7 +727,7 @@ archive_string_append_from_wcs_in_codepage(struct archive_string *as, else dp = &defchar_used; count = WideCharToMultiByte(to_cp, 0, ws, wslen, - as->s + as->length, as->buffer_length-1, NULL, dp); + as->s + as->length, (int)as->buffer_length-1, NULL, dp); if (count == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { /* Expand the MBS buffer and retry. */ @@ -2145,7 +2145,7 @@ invalid_mbs(const void *_p, size_t n, struct archive_string_conv *sc) if (codepage != CP_UTF8) mbflag |= MB_PRECOMPOSED; - if (MultiByteToWideChar(codepage, mbflag, p, n, NULL, 0) == 0) + if (MultiByteToWideChar(codepage, mbflag, p, (int)n, NULL, 0) == 0) return (-1); /* Invalid */ return (0); /* Okay */ } @@ -2322,7 +2322,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) /* Invalide sequence or there are not plenty bytes. */ if ((int)n < cnt) { - cnt = n; + cnt = (int)n; for (i = 1; i < cnt; i++) { if ((s[i] & 0xc0) != 0x80) { cnt = i; @@ -2391,7 +2391,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) else cnt = 1; if ((int)n < cnt) - cnt = n; + cnt = (int)n; for (i = 1; i < cnt; i++) { if ((s[i] & 0xc0) != 0x80) { cnt = i; @@ -3478,9 +3478,9 @@ strncat_from_utf8_libarchive2(struct archive_string *as, * Translates the wide-character into the current locale MBS. */ #if HAVE_WCRTOMB - n = wcrtomb(p, wc, &shift_state); + n = (int)wcrtomb(p, wc, &shift_state); #else - n = wctomb(p, wc); + n = (int)wctomb(p, wc); #endif if (n == -1) return (-1); @@ -3579,13 +3579,13 @@ win_strncat_from_utf16(struct archive_string *as, const void *_p, size_t bytes, do { defchar = 0; ll = WideCharToMultiByte(sc->to_cp, 0, - (LPCWSTR)u16, bytes>>1, mbs, mbs_size, + (LPCWSTR)u16, (int)bytes>>1, mbs, (int)mbs_size, NULL, &defchar); if (ll == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { /* Need more buffer for MBS. */ ll = WideCharToMultiByte(sc->to_cp, 0, - (LPCWSTR)u16, bytes, NULL, 0, NULL, NULL); + (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL); if (archive_string_ensure(as, ll +1) == NULL) return (-1); mbs = as->s + as->length; @@ -3662,12 +3662,12 @@ win_strncat_to_utf16(struct archive_string *as16, const void *_p, } do { count = MultiByteToWideChar(sc->from_cp, - MB_PRECOMPOSED, s, length, (LPWSTR)u16, (int)avail>>1); + MB_PRECOMPOSED, s, (int)length, (LPWSTR)u16, (int)avail>>1); if (count == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { /* Need more buffer for UTF-16 string */ count = MultiByteToWideChar(sc->from_cp, - MB_PRECOMPOSED, s, length, NULL, 0); + MB_PRECOMPOSED, s, (int)length, NULL, 0); if (archive_string_ensure(as16, (count +1) * 2) == NULL) return (-1); diff --git a/libarchive/archive_util.c b/libarchive/archive_util.c index ffeaac9c3..34d8081cb 100644 --- a/libarchive/archive_util.c +++ b/libarchive/archive_util.c @@ -243,7 +243,7 @@ __archive_mktemp(const char *tmpdir) errno = ENOMEM; goto exit_tmpfile; } - GetTempPathW(l, tmp); + GetTempPathW((DWORD)l, tmp); archive_wstrcpy(&temp_name, tmp); free(tmp); } else { @@ -297,7 +297,8 @@ __archive_mktemp(const char *tmpdir) /* Generate a random file name through CryptGenRandom(). */ p = xp; - if (!CryptGenRandom(hProv, (ep - p)*sizeof(wchar_t), (BYTE*)p)) { + if (!CryptGenRandom(hProv, (DWORD)(ep - p)*sizeof(wchar_t), + (BYTE*)p)) { la_dosmaperr(GetLastError()); goto exit_tmpfile; } diff --git a/libarchive/archive_write_add_filter_gzip.c b/libarchive/archive_write_add_filter_gzip.c index 28fd8ebc9..1a7246745 100644 --- a/libarchive/archive_write_add_filter_gzip.c +++ b/libarchive/archive_write_add_filter_gzip.c @@ -430,25 +430,6 @@ archive_compressor_gzip_write(struct archive_write_filter *f, const void *buff, return __archive_write_program_write(f, data->pdata, buff, length); } -static int -archive_compressor_gzip_close(struct archive_write_filter *f) -{ - - f->write = archive_compressor_gzip_write; - r = __archive_write_program_open(f, data->pdata, as.s); - archive_string_free(&as); - return (r); -} - -static int -archive_compressor_gzip_write(struct archive_write_filter *f, const void *buff, - size_t length) -{ - struct private_data *data = (struct private_data *)f->data; - - return __archive_write_program_write(f, data->pdata, buff, length); -} - static int archive_compressor_gzip_close(struct archive_write_filter *f) { diff --git a/libarchive/archive_write_add_filter_uuencode.c b/libarchive/archive_write_add_filter_uuencode.c index 6535f1a2d..23d9c150d 100644 --- a/libarchive/archive_write_add_filter_uuencode.c +++ b/libarchive/archive_write_add_filter_uuencode.c @@ -173,7 +173,7 @@ uu_encode(struct archive_string *as, const unsigned char *p, size_t len) { int c; - c = len; + c = (int)len; archive_strappend_char(as, c?c + 0x20:'`'); for (; len >= 3; p += 3, len -= 3) { c = p[0] >> 2; diff --git a/libarchive/archive_write_set_format_7zip.c b/libarchive/archive_write_set_format_7zip.c index e24f71ebe..dcb23b970 100644 --- a/libarchive/archive_write_set_format_7zip.c +++ b/libarchive/archive_write_set_format_7zip.c @@ -630,7 +630,7 @@ _7z_finish_entry(struct archive_write *a) s = a->null_length; r = _7z_write_data(a, a->nulls, s); if (r < 0) - return (r); + return ((int)r); } zip->total_bytes_compressed += zip->stream.total_in; zip->total_bytes_uncompressed += zip->stream.total_out; @@ -862,7 +862,7 @@ enc_uint64(struct archive_write *a, uint64_t val) numdata[0] |= mask; mask >>= 1; } - return (compress_out(a, numdata, i, ARCHIVE_Z_RUN)); + return ((int)compress_out(a, numdata, i, ARCHIVE_Z_RUN)); } static int @@ -927,7 +927,7 @@ make_substreamsInfo(struct archive_write *a, struct coder *coders) if (file->size == 0) break; archive_le32enc(crc, file->crc32); - r = compress_out(a, crc, 4, ARCHIVE_Z_RUN); + r = (int)compress_out(a, crc, 4, ARCHIVE_Z_RUN); if (r < 0) return (r); } @@ -951,7 +951,7 @@ make_streamsInfo(struct archive_write *a, uint64_t offset, uint64_t pack_size, int i, r; if (coders->codec == _7Z_COPY) - numFolders = zip->total_number_nonempty_entry; + numFolders = (int)zip->total_number_nonempty_entry; else numFolders = 1; @@ -1047,7 +1047,7 @@ make_streamsInfo(struct archive_write *a, uint64_t offset, uint64_t pack_size, /* Write Codec ID. */ codec_size &= 0x0f; - r = compress_out(a, &codec_buff[8-codec_size], + r = (int)compress_out(a, &codec_buff[8-codec_size], codec_size, ARCHIVE_Z_RUN); if (r < 0) return (r); @@ -1059,7 +1059,7 @@ make_streamsInfo(struct archive_write *a, uint64_t offset, uint64_t pack_size, return (r); /* Write Codec properties. */ - r = compress_out(a, coders[i].props, + r = (int)compress_out(a, coders[i].props, coders[i].prop_size, ARCHIVE_Z_RUN); if (r < 0) return (r); @@ -1105,7 +1105,7 @@ make_streamsInfo(struct archive_write *a, uint64_t offset, uint64_t pack_size, if (r < 0) return (r); archive_le32enc(crc, header_crc); - r = compress_out(a, crc, 4, ARCHIVE_Z_RUN); + r = (int)compress_out(a, crc, 4, ARCHIVE_Z_RUN); if (r < 0) return (r); } @@ -1199,7 +1199,7 @@ make_time(struct archive_write *a, uint8_t type, unsigned flg, int ti) b |= mask; mask >>= 1; if (mask == 0) { - r = compress_out(a, &b, 1, ARCHIVE_Z_RUN); + r = (int)compress_out(a, &b, 1, ARCHIVE_Z_RUN); if (r < 0) return (r); mask = 0x80; @@ -1207,7 +1207,7 @@ make_time(struct archive_write *a, uint8_t type, unsigned flg, int ti) } } if (mask != 0x80) { - r = compress_out(a, &b, 1, ARCHIVE_Z_RUN); + r = (int)compress_out(a, &b, 1, ARCHIVE_Z_RUN); if (r < 0) return (r); } @@ -1228,7 +1228,7 @@ make_time(struct archive_write *a, uint8_t type, unsigned flg, int ti) continue; archive_le64enc(filetime, utcToFiletime(file->times[ti].time, file->times[ti].time_ns)); - r = compress_out(a, filetime, 8, ARCHIVE_Z_RUN); + r = (int)compress_out(a, filetime, 8, ARCHIVE_Z_RUN); if (r < 0) return (r); } @@ -1299,7 +1299,7 @@ make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size, b |= mask; mask >>= 1; if (mask == 0) { - r = compress_out(a, &b, 1, ARCHIVE_Z_RUN); + r = (int)compress_out(a, &b, 1, ARCHIVE_Z_RUN); if (r < 0) return (r); mask = 0x80; @@ -1307,7 +1307,7 @@ make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size, } } if (mask != 0x80) { - r = compress_out(a, &b, 1, ARCHIVE_Z_RUN); + r = (int)compress_out(a, &b, 1, ARCHIVE_Z_RUN); if (r < 0) return (r); } @@ -1334,7 +1334,7 @@ make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size, b |= mask; mask >>= 1; if (mask == 0) { - r = compress_out(a, &b, 1, ARCHIVE_Z_RUN); + r = (int)compress_out(a, &b, 1, ARCHIVE_Z_RUN); if (r < 0) return (r); mask = 0x80; @@ -1342,7 +1342,7 @@ make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size, } } if (mask != 0x80) { - r = compress_out(a, &b, 1, ARCHIVE_Z_RUN); + r = (int)compress_out(a, &b, 1, ARCHIVE_Z_RUN); if (r < 0) return (r); } @@ -1365,7 +1365,7 @@ make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size, file = zip->file_list.first; for (;file != NULL; file = file->next) { - r = compress_out(a, file->utf16name, file->name_len+2, + r = (int)compress_out(a, file->utf16name, file->name_len+2, ARCHIVE_Z_RUN); if (r < 0) return (r); @@ -1421,7 +1421,7 @@ make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size, attr |= 1;/* Read Only. */ attr |= ((uint32_t)file->mode) << 16; archive_le32enc(&encattr, attr); - r = compress_out(a, &encattr, 4, ARCHIVE_Z_RUN); + r = (int)compress_out(a, &encattr, 4, ARCHIVE_Z_RUN); if (r < 0) return (r); } @@ -1515,7 +1515,7 @@ file_new(struct archive_write *a, struct archive_entry *entry, memcpy(file->utf16name, u16, u16len); file->utf16name[u16len+0] = 0; file->utf16name[u16len+1] = 0; - file->name_len = u16len; + file->name_len = (unsigned)u16len; file->mode = archive_entry_mode(entry); if (archive_entry_filetype(entry) == AE_IFREG) file->size = archive_entry_size(entry); diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index 0fac55d8d..c1900528a 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -994,7 +994,7 @@ static void isoent_remove_child(struct isoent *, struct isoent *); static void isoent_setup_directory_location(struct iso9660 *, int, struct vdd *); static void isoent_setup_file_location(struct iso9660 *, int); -static int get_path_component(char *, int, const char *); +static int get_path_component(char *, size_t, const char *); static int isoent_tree(struct archive_write *, struct isoent **); static struct isoent *isoent_find_child(struct isoent *, const char *); static struct isoent *isoent_find_entry(struct isoent *, const char *); @@ -2889,7 +2889,7 @@ set_directory_record_rr(unsigned char *bp, int dr_len, if (nmmax > 0xff) nmmax = 0xff; while (nmlen + 5 > nmmax) { - length = nmmax; + length = (int)nmmax; if (bp != NULL) { bp[3] = length; bp[5] = 0x01;/* Alternate Name continues @@ -2912,7 +2912,7 @@ set_directory_record_rr(unsigned char *bp, int dr_len, bp[4] = 1; /* version */ } } - length = 5 + nmlen; + length = 5 + (int)nmlen; if (bp != NULL) { bp[3] = length; bp[5] = 0; @@ -3511,7 +3511,7 @@ set_directory_record(unsigned char *p, size_t n, struct isoent *isoent, /* Volume Sequence Number */ set_num_723(bp+29, iso9660->volume_sequence_number); /* Length of File Identifier */ - set_num_711(bp+33, fi_len); + set_num_711(bp+33, (unsigned char)fi_len); /* File Identifier */ switch (t) { case DIR_REC_VD: @@ -3542,20 +3542,20 @@ set_directory_record(unsigned char *p, size_t n, struct isoent *isoent, if (t == DIR_REC_VD) { if (p != NULL) /* Length of Directory Record */ - set_num_711(p, dr_len); + set_num_711(p, (unsigned char)dr_len); else - isoent->dr_len.vd = dr_len; - return (dr_len); + isoent->dr_len.vd = (int)dr_len; + return ((int)dr_len); } /* Rockridge */ if (iso9660->opt.rr && vdd_type != VDD_JOLIET) - dr_len = set_directory_record_rr(bp, dr_len, + dr_len = set_directory_record_rr(bp, (int)dr_len, isoent, iso9660, t); if (p != NULL) /* Length of Directory Record */ - set_num_711(p, dr_len); + set_num_711(p, (unsigned char)dr_len); else { /* * Save the size which is needed to write this @@ -3568,15 +3568,15 @@ set_directory_record(unsigned char *p, size_t n, struct isoent *isoent, * in switch .... */ break; case DIR_REC_SELF: - isoent->dr_len.self = dr_len; break; + isoent->dr_len.self = (int)dr_len; break; case DIR_REC_PARENT: - isoent->dr_len.parent = dr_len; break; + isoent->dr_len.parent = (int)dr_len; break; case DIR_REC_NORMAL: - isoent->dr_len.normal = dr_len; break; + isoent->dr_len.normal = (int)dr_len; break; } } - return (dr_len); + return ((int)dr_len); } /* @@ -4255,7 +4255,7 @@ _write_path_table(struct archive_write *a, int type_m, int depth, bp = wb -1; } /* Length of Directory Identifier */ - set_num_711(bp+1, len); + set_num_711(bp+1, (unsigned char)len); /* Extended Attribute Record Length */ set_num_711(bp+2, 0); /* Location of Extent */ @@ -4278,7 +4278,7 @@ _write_path_table(struct archive_write *a, int type_m, int depth, bp[9+len] = 0; len++; } - wsize += 8 + len; + wsize += 8 + (int)len; bp += 8 + len; } if ((bp + 1) > wb) { @@ -5448,7 +5448,8 @@ isoent_setup_file_location(struct iso9660 *iso9660, int location) size = fd_boot_image_size(iso9660->el_torito.media_type); if (size == 0) size = (size_t)archive_entry_size(isoent->file->entry); - block = (size + LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS; + block = ((int)size + LOGICAL_BLOCK_SIZE -1) + >> LOGICAL_BLOCK_BITS; location += block; iso9660->total_file_block += block; isoent->file->content.blocks = block; @@ -5509,10 +5510,10 @@ isoent_setup_file_location(struct iso9660 *iso9660, int location) } static int -get_path_component(char *name, int n, const char *fn) +get_path_component(char *name, size_t n, const char *fn) { char *p; - int l; + size_t l; p = strchr(fn, '/'); if (p == NULL) { @@ -5525,7 +5526,7 @@ get_path_component(char *name, int n, const char *fn) memcpy(name, fn, l); name[l] = '\0'; - return (l); + return ((int)l); } /* @@ -6017,7 +6018,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent, char *dot, *xdot; int ext_off, noff, weight; - l = np->file->basename.length; + l = (int)np->file->basename.length; p = malloc(l+31+2+1); if (p == NULL) { archive_set_error(&a->archive, ENOMEM, @@ -6081,7 +6082,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent, ext_off = l; } else { *dot = '.'; - ext_off = dot - p; + ext_off = (int)(dot - p); if (iso9660->opt.iso_level == 1) { if (dot - p <= 8) { @@ -6108,11 +6109,11 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent, ext_off = dnmax; } } else if (l > ffmax) { - int extlen = strlen(dot); + int extlen = (int)strlen(dot); int xdoff; if (xdot != NULL) - xdoff = xdot - p; + xdoff = (int)(xdot - p); else xdoff = 0; @@ -6149,7 +6150,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent, } /* Save an offset of a file name extension to sort files. */ np->ext_off = ext_off; - np->ext_len = strlen(&p[ext_off]); + np->ext_len = (int)strlen(&p[ext_off]); np->id_len = l = ext_off + np->ext_len; /* Make an offset of the number which is used to be set @@ -6266,10 +6267,10 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent, p += 2; lt -= 2; } - ext_off = dot - (unsigned char *)np->identifier; + ext_off = (int)(dot - (unsigned char *)np->identifier); np->ext_off = ext_off; - np->ext_len = l - ext_off; - np->id_len = l; + np->ext_len = (int)l - ext_off; + np->id_len = (int)l; /* * Get a length of MBS of a full-pathname. @@ -6283,11 +6284,11 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent, "No memory"); return (ARCHIVE_FATAL); } - np->mb_len = iso9660->mbs.length; + np->mb_len = (int)iso9660->mbs.length; if (np->mb_len != (int)np->file->basename.length) weight = np->mb_len; } else - np->mb_len = np->file->basename.length; + np->mb_len = (int)np->file->basename.length; /* If a length of full-pathname is longer than 240 bytes, * it violates Joliet extensions regulation. */ @@ -7508,7 +7509,7 @@ zisofs_detect_magic(struct archive_write *a, const void *buff, size_t s) l = s; memcpy(iso9660->zisofs.magic_buffer + iso9660->zisofs.magic_cnt, buff, l); - iso9660->zisofs.magic_cnt += l; + iso9660->zisofs.magic_cnt += (int)l; if (iso9660->zisofs.magic_cnt < magic_max) return; } diff --git a/libarchive/archive_write_set_format_mtree.c b/libarchive/archive_write_set_format_mtree.c index 8e984ca8d..9c0613c9b 100644 --- a/libarchive/archive_write_set_format_mtree.c +++ b/libarchive/archive_write_set_format_mtree.c @@ -399,7 +399,8 @@ mtree_indent(struct mtree_writer *mtree) for (i = 0; i < (INDENTNAMELEN + 1 + pd); i++) archive_strappend_char(&mtree->buf, ' '); } else { - for (i = r -s + nd; i < (INDENTNAMELEN + 1); i++) + for (i = (int)(r -s + nd); + i < (INDENTNAMELEN + 1); i++) archive_strappend_char(&mtree->buf, ' '); } s = ++r; @@ -1949,10 +1950,10 @@ mtree_entry_find_child(struct mtree_entry *parent, const char *child_name) } static int -get_path_component(char *name, int n, const char *fn) +get_path_component(char *name, size_t n, const char *fn) { char *p; - int l; + size_t l; p = strchr(fn, '/'); if (p == NULL) { @@ -1965,7 +1966,7 @@ get_path_component(char *name, int n, const char *fn) memcpy(name, fn, l); name[l] = '\0'; - return (l); + return ((int)l); } /* diff --git a/libarchive/archive_write_set_format_pax.c b/libarchive/archive_write_set_format_pax.c index f07dd0dcb..754e5f96f 100644 --- a/libarchive/archive_write_set_format_pax.c +++ b/libarchive/archive_write_set_format_pax.c @@ -691,7 +691,8 @@ archive_write_pax_header(struct archive_write *a, return (r); if (r < ret) ret = r; - r = archive_write_pax_data(a, mac_metadata, mac_metadata_size); + r = (int)archive_write_pax_data(a, mac_metadata, + mac_metadata_size); if (r < ARCHIVE_WARN) return (r); if (r < ret) diff --git a/libarchive/filter_fork_windows.c b/libarchive/filter_fork_windows.c index 43fce7719..fa59cc9e9 100644 --- a/libarchive/filter_fork_windows.c +++ b/libarchive/filter_fork_windows.c @@ -88,7 +88,7 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) for (l = 0, i = 0; acmd->argv[i] != NULL; i++) { if (i == 0) continue; - l += strlen(acmd->argv[i]) + 1; + l += (int)strlen(acmd->argv[i]) + 1; } if (archive_string_ensure(&cmdline, l + 1) == NULL) goto fail; diff --git a/libarchive/test/main.c b/libarchive/test/main.c index bb9650490..d442da067 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -622,8 +622,8 @@ assertion_equal_string(const char *file, int line, if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0)) return (1); failure_start(file, line, "%s != %s", e1, e2); - l1 = strlen(e1); - l2 = strlen(e2); + l1 = (int)strlen(e1); + l2 = (int)strlen(e2); if (l1 < l2) l1 = l2; strdump(e1, v1, l1, utf8); @@ -845,8 +845,8 @@ assertion_equal_file(const char *filename, int line, const char *fn1, const char return (0); } for (;;) { - n1 = fread(buff1, 1, sizeof(buff1), f1); - n2 = fread(buff2, 1, sizeof(buff2), f2); + n1 = (int)fread(buff1, 1, sizeof(buff1), f1); + n2 = (int)fread(buff2, 1, sizeof(buff2), f2); if (n1 != n2) break; if (n1 == 0 && n2 == 0) { @@ -920,7 +920,7 @@ assertion_file_contents(const char *filename, int line, const void *buff, int s, return (0); } contents = malloc(s * 2); - n = fread(contents, 1, s * 2, f); + n = (int)fread(contents, 1, s * 2, f); fclose(f); if (n == s && memcmp(buff, contents, s) == 0) { free(contents); @@ -956,9 +956,9 @@ assertion_text_file_contents(const char *filename, int line, const char *buff, c failure_finish(NULL); return (0); } - s = strlen(buff); + s = (int)strlen(buff); contents = malloc(s * 2 + 128); - n = fread(contents, 1, s * 2 + 128 - 1, f); + n = (int)fread(contents, 1, s * 2 + 128 - 1, f); if (n >= 0) contents[n] = '\0'; fclose(f); diff --git a/libarchive/test/test_fuzz.c b/libarchive/test/test_fuzz.c index c437f20a3..a03f7517a 100644 --- a/libarchive/test/test_fuzz.c +++ b/libarchive/test/test_fuzz.c @@ -321,7 +321,7 @@ DEFINE_TEST(test_fuzz) /* Fuzz < 1% of the bytes in the archive. */ memcpy(image, rawimage, size); - q = size / 100; + q = (int)size / 100; if (!q) q = 1; numbytes = (int)(rand() % q); for (j = 0; j < numbytes; ++j) diff --git a/libarchive/test/test_sparse_basic.c b/libarchive/test/test_sparse_basic.c index d564f0c52..67c51dd35 100644 --- a/libarchive/test/test_sparse_basic.c +++ b/libarchive/test/test_sparse_basic.c @@ -118,14 +118,15 @@ create_sparse_file(const char *path, const struct sparse *s) assert(SetFilePointerEx(handle, distance, NULL, FILE_CURRENT) != 0); } else { - DWORD w, wr, size; + DWORD w, wr; + size_t size; size = s->size; while (size) { if (size > sizeof(buff)) w = sizeof(buff); else - w = size; + w = (DWORD)size; assert(WriteFile(handle, buff, w, &wr, NULL) != 0); size -= wr; } diff --git a/libarchive/test/test_write_format_tar_sparse.c b/libarchive/test/test_write_format_tar_sparse.c index e0f1d6fda..c8e0f4797 100644 --- a/libarchive/test/test_write_format_tar_sparse.c +++ b/libarchive/test/test_write_format_tar_sparse.c @@ -85,7 +85,7 @@ test_1(void) ws = 0x81000 - i; assertEqualInt(ws, archive_write_data(a, buff2, ws)); - i += ws; + i += (long)ws; } /* Close out the archive. */ diff --git a/tar/test/main.c b/tar/test/main.c index 2835901db..14d9b3e64 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -624,8 +624,8 @@ assertion_equal_string(const char *file, int line, if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0)) return (1); failure_start(file, line, "%s != %s", e1, e2); - l1 = strlen(e1); - l2 = strlen(e2); + l1 = (int)strlen(e1); + l2 = (int)strlen(e2); if (l1 < l2) l1 = l2; strdump(e1, v1, l1, utf8); @@ -847,8 +847,8 @@ assertion_equal_file(const char *filename, int line, const char *fn1, const char return (0); } for (;;) { - n1 = fread(buff1, 1, sizeof(buff1), f1); - n2 = fread(buff2, 1, sizeof(buff2), f2); + n1 = (int)fread(buff1, 1, sizeof(buff1), f1); + n2 = (int)fread(buff2, 1, sizeof(buff2), f2); if (n1 != n2) break; if (n1 == 0 && n2 == 0) { @@ -922,7 +922,7 @@ assertion_file_contents(const char *filename, int line, const void *buff, int s, return (0); } contents = malloc(s * 2); - n = fread(contents, 1, s * 2, f); + n = (int)fread(contents, 1, s * 2, f); fclose(f); if (n == s && memcmp(buff, contents, s) == 0) { free(contents); @@ -958,9 +958,9 @@ assertion_text_file_contents(const char *filename, int line, const char *buff, c failure_finish(NULL); return (0); } - s = strlen(buff); + s = (int)strlen(buff); contents = malloc(s * 2 + 128); - n = fread(contents, 1, s * 2 + 128 - 1, f); + n = (int)fread(contents, 1, s * 2 + 128 - 1, f); if (n >= 0) contents[n] = '\0'; fclose(f); diff --git a/tar/test/test_copy.c b/tar/test/test_copy.c index dd49bc410..c4c1aa057 100644 --- a/tar/test/test_copy.c +++ b/tar/test/test_copy.c @@ -122,7 +122,7 @@ compute_filenames(void) if (i > 9) { buff[j--] = '0' + ((i / 10) % 10); if (i > 99) - buff[j--] = '0' + (i / 100); + buff[j--] = '0' + (char)(i / 100); } buff[j] = '_'; /* Guard against obvious screwups in the above code. */ @@ -205,7 +205,7 @@ verify_tree(size_t limit) sprintf(name1, "f/%s", filenames[i]); if (i <= limit) { assertFileExists(name1); - assertFileContents(name1, strlen(name1), name1); + assertFileContents(name1, (int)strlen(name1), name1); } sprintf(name2, "l/%s", filenames[i]); diff --git a/tar/test/test_option_r.c b/tar/test/test_option_r.c index 70c2087c9..bfac8ddc3 100644 --- a/tar/test/test_option_r.c +++ b/tar/test/test_option_r.c @@ -126,5 +126,5 @@ DEFINE_TEST(test_option_r) assertEmptyFile("extract.err"); /* Verify that the second copy of f1 overwrote the first. */ - assertFileContents(buff, strlen(buff), "f1"); + assertFileContents(buff, (int)strlen(buff), "f1"); } diff --git a/tar/test/test_stdio.c b/tar/test/test_stdio.c index b95a4e305..bf5dd7744 100644 --- a/tar/test/test_stdio.c +++ b/tar/test/test_stdio.c @@ -113,7 +113,7 @@ DEFINE_TEST(test_stdio) assertEqualInt(r, 0); /* Verify xvOf.out is the file contents */ p = slurpfile(&s, "xvOf.out"); - assert(s = 3); + assertEqualInt((int)s, 3); assertEqualMem(p, "abc", 3); /* TODO: Verify xvf.err */ diff --git a/tar/test/test_windows.c b/tar/test/test_windows.c index b3f3546be..1977ec644 100644 --- a/tar/test/test_windows.c +++ b/tar/test/test_windows.c @@ -54,7 +54,7 @@ mkfullpath(char **path1, char **path2, const char *tpath, int type) assert(NULL != fp1); fp2 = malloc(l*2); assert(NULL != fp2); - l = GetFullPathNameA(tpath, l, fp1, NULL); + l = GetFullPathNameA(tpath, (DWORD)l, fp1, NULL); if ((type & 0x01) == 0) { for (p1 = fp1; *p1 != '\0'; p1++) if (*p1 == '\\') @@ -229,7 +229,7 @@ DEFINE_TEST(test_windows) assertEqualInt(0, systemf("%s -tf ../archive10.tar > ../list10", testprog)); /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list10"); + assertFileContents(fp2, (int)strlen(fp2), "../list10"); free(fp1); free(fp2); @@ -241,7 +241,7 @@ DEFINE_TEST(test_windows) assertEqualInt(0, systemf("%s -tf ../archive11.tar > ../list11", testprog)); /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list11"); + assertFileContents(fp2, (int)strlen(fp2), "../list11"); free(fp1); free(fp2); @@ -253,7 +253,7 @@ DEFINE_TEST(test_windows) assertEqualInt(0, systemf("%s -tf ../archive12.tar > ../list12", testprog)); /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list12"); + assertFileContents(fp2, (int)strlen(fp2), "../list12"); free(fp1); free(fp2); @@ -265,7 +265,7 @@ DEFINE_TEST(test_windows) assertEqualInt(0, systemf("%s -tf ../archive13.tar > ../list13", testprog)); /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list13"); + assertFileContents(fp2, (int)strlen(fp2), "../list13"); free(fp1); free(fp2); @@ -277,7 +277,7 @@ DEFINE_TEST(test_windows) assertEqualInt(0, systemf("%s -tf ../archive14.tar > ../list14", testprog)); /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list14"); + assertFileContents(fp2, (int)strlen(fp2), "../list14"); free(fp1); free(fp2); @@ -289,7 +289,7 @@ DEFINE_TEST(test_windows) assertEqualInt(0, systemf("%s -tf ../archive15.tar > ../list15", testprog)); /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list15"); + assertFileContents(fp2, (int)strlen(fp2), "../list15"); free(fp1); free(fp2); @@ -302,7 +302,7 @@ DEFINE_TEST(test_windows) assertEqualInt(0, systemf("%s -tf ../archive16.tar > ../list16", testprog)); /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list16"); + assertFileContents(fp2, (int)strlen(fp2), "../list16"); free(fp1); free(fp2); @@ -315,7 +315,7 @@ DEFINE_TEST(test_windows) assertEqualInt(0, systemf("%s -tf ../archive17.tar > ../list17", testprog)); /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list17"); + assertFileContents(fp2, (int)strlen(fp2), "../list17"); free(fp1); free(fp2); #else