]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Eliminate warnings on Visual Studio 10 W64.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Tue, 22 Dec 2009 00:39:58 +0000 (19:39 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Tue, 22 Dec 2009 00:39:58 +0000 (19:39 -0500)
On Win64, the size of 'int' is stil 4 bytes and the size of 'size_t'
is 8 bytes. A conversion from 'size_t' to 'int', causes warning
with compiling.

SVN-Revision: 1772

14 files changed:
cpio/cpio_windows.c
libarchive/archive_entry.c
libarchive/archive_read_support_compression_program.c
libarchive/archive_read_support_format_mtree.c
libarchive/archive_read_support_format_tar.c
libarchive/archive_windows.c
libarchive/archive_write_set_compression_compress.c
libarchive/archive_write_set_format_cpio.c
libarchive/archive_write_set_format_cpio_newc.c
libarchive/archive_write_set_format_mtree.c
libarchive/archive_write_set_format_pax.c
libarchive/archive_write_set_format_zip.c
tar/bsdtar_windows.c
tar/util.c

index 841e94928868471951451e505f6786546b3920cf..420e01d5e19285434f2a6fe8c218684d33a830a0 100644 (file)
@@ -61,10 +61,10 @@ permissive_name(const char *name)
 {
        wchar_t *wn, *wnp;
        wchar_t *ws, *wsp;
-       size_t l, len, slen, alloclen;
+       DWORD l, len, slen, alloclen;
        int unc;
 
-       len = strlen(name);
+       len = (DWORD)strlen(name);
        wn = malloc((len + 1) * sizeof(wchar_t));
        if (wn == NULL)
                return (NULL);
index 4a3ce266cebf7275f3d323bf66c4405b2008a3ac..00025e7eb3ead35193050fa0428e64f30cf8b17d 100644 (file)
@@ -222,7 +222,7 @@ static const wchar_t *
 aes_get_wcs(struct aes *aes)
 {
        wchar_t *w;
-       int r;
+       size_t r;
 
        /* Return WCS form if we already have it. */
        if (aes->aes_set & AES_SET_WCS)
@@ -240,7 +240,7 @@ aes_get_wcs(struct aes *aes)
                if (w == NULL)
                        __archive_errx(1, "No memory for aes_get_wcs()");
                r = mbstowcs(w, aes->aes_mbs.s, wcs_length);
-               if (r > 0) {
+               if (r != (size_t)-1 && r != 0) {
                        w[r] = 0;
                        aes->aes_set |= AES_SET_WCS;
                        return (aes->aes_wcs = w);
index f9b2cc6117213c1d39d0e94172fab33f2cb0794e..3115b5c56e3758b33ad37c531d4d913e30a3ff49 100644 (file)
@@ -205,7 +205,7 @@ program_bidder_bid(struct archive_read_filter_bidder *self,
                /* No match, so don't bid. */
                if (memcmp(p, state->signature, state->signature_len) != 0)
                        return (0);
-               return (state->signature_len * 8);
+               return ((int)state->signature_len * 8);
        }
 
        /* Otherwise, bid once and then never bid again. */
index 167ff3e86b2fa2354d507ea24e0a8e2ffe2e5731..8d88d7815efe199eb68485273abebbc712d076fe 100644 (file)
@@ -196,7 +196,7 @@ mtree_bid(struct archive_read *a)
                return (-1);
 
        if (strncmp(p, signature, strlen(signature)) == 0)
-               return (8 * strlen(signature));
+               return (8 * (int)strlen(signature));
        return (0);
 }
 
index 79ab246c8903b625c525cd918d855d3ff83a57a2..fb5a7851d780a42065626f0b3abc1b29730d33dd 100644 (file)
@@ -2318,7 +2318,7 @@ base64_decode(const char *s, size_t len, size_t *out_len)
 
        /* If the decode table is not yet initialized, prepare it. */
        if (decode_table[digits[1]] != 1) {
-               size_t i;
+               unsigned i;
                memset(decode_table, 0xff, sizeof(decode_table));
                for (i = 0; i < sizeof(digits); i++)
                        decode_table[digits[i]] = i;
index f938ca0a9259fa33d95c755580acb44d5f946dd8..03a459e7c492beee1c8ff5494287ed586a5b836e 100644 (file)
@@ -125,14 +125,14 @@ permissive_name(const char *name)
 {
        wchar_t *wn, *wnp;
        wchar_t *ws, *wsp;
-       size_t l, len, slen;
+       DWORD l, len, slen;
        int unc;
 
-       len = strlen(name);
+       len = (DWORD)strlen(name);
        wn = malloc((len + 1) * sizeof(wchar_t));
        if (wn == NULL)
                return (NULL);
-       l = MultiByteToWideChar(CP_ACP, 0, name, len, wn, len);
+       l = MultiByteToWideChar(CP_ACP, 0, name, (int)len, wn, (int)len);
        if (l == 0) {
                free(wn);
                return (NULL);
@@ -323,8 +323,8 @@ __link(const char *src, const char *dst)
                else
                        wcscat(wnewsrc, L"\\");
                /* Converting multi-byte src to wide-char src */
-               wlen = wcslen(wsrc);
-               slen = strlen(src);
+               wlen = (int)wcslen(wsrc);
+               slen = (int)strlen(src);
                n = MultiByteToWideChar(CP_ACP, 0, src, slen, wsrc, wlen);
                if (n == 0) {
                        free (wnewsrc);
index be1902692a83218b6f24b6df0c17205d428d79a7..158c06a84746696a7c1cc187f0233b4d269739e5 100644 (file)
@@ -425,7 +425,7 @@ archive_compressor_compress_finish(struct archive_write *a)
        ssize_t block_length, target_block_length, bytes_written;
        int ret;
        struct private_data *state;
-       unsigned tocopy;
+       size_t tocopy;
 
        state = (struct private_data *)a->compressor.data;
        if (a->client_writer == NULL) {
index bddb529ee3bd330a864640f6af759730bb5dde10..ab7897c0c53abfce43d7b8f8546b1b0a55fbab7b 100644 (file)
@@ -187,7 +187,7 @@ archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry)
        ret2 = ARCHIVE_OK;
 
        path = archive_entry_pathname(entry);
-       pathlength = strlen(path) + 1; /* Include trailing null. */
+       pathlength = (int)strlen(path) + 1; /* Include trailing null. */
 
        memset(&h, 0, sizeof(h));
        format_octal(070707, &h.c_magic, sizeof(h.c_magic));
@@ -327,7 +327,8 @@ static int
 archive_write_cpio_finish_entry(struct archive_write *a)
 {
        struct cpio *cpio;
-       int to_write, ret;
+       size_t to_write;
+       int ret;
 
        cpio = (struct cpio *)a->format_data;
        ret = ARCHIVE_OK;
index 9dbfbbba5bad242491ec62e662a6e1d6c8587137..641c883dd7054fced01adad6791e68c39454c1dc 100644 (file)
@@ -125,7 +125,7 @@ archive_write_newc_header(struct archive_write *a, struct archive_entry *entry)
        ret2 = ARCHIVE_OK;
 
        path = archive_entry_pathname(entry);
-       pathlength = strlen(path) + 1; /* Include trailing null. */
+       pathlength = (int)strlen(path) + 1; /* Include trailing null. */
 
        memset(&h, 0, sizeof(h));
        format_hex(0x070701, &h.c_magic, sizeof(h.c_magic));
@@ -278,7 +278,8 @@ static int
 archive_write_newc_finish_entry(struct archive_write *a)
 {
        struct cpio *cpio;
-       int to_write, ret;
+       size_t to_write;
+       int ret;
 
        cpio = (struct cpio *)a->format_data;
        while (cpio->entry_bytes_remaining > 0) {
index b01f80c6011ccd0f2a7615dbc147dfec6ca5bee7..1b46147a6522984fac66d7f8eb73faedd5d28267 100644 (file)
@@ -854,7 +854,7 @@ archive_write_mtree_data(struct archive_write *a, const void *buff, size_t n)
                 * Compute a POSIX 1003.2 checksum
                 */
                const unsigned char *p;
-               int nn;
+               size_t nn;
 
                for (nn = n, p = buff; nn--; ++p)
                        COMPUTE_CRC(mtree->crc, *p);
index ae3b2b5aebdbb32799d1f42c5caf537d1072c0ab..2d10db1b37590da7c7f4dde9d864f81c448bda0a 100644 (file)
@@ -307,7 +307,7 @@ add_pax_attr(struct archive_string *as, const char *key, const char *value)
         * PAX attributes have the following layout:
         *     <len> <space> <key> <=> <value> <nl>
         */
-       len = 1 + strlen(key) + 1 + strlen(value) + 1;
+       len = 1 + (int)strlen(key) + 1 + (int)strlen(value) + 1;
 
        /*
         * The <len> field includes the length of the <len> field, so
@@ -362,7 +362,7 @@ archive_write_pax_header_xattrs(struct pax *pax, struct archive_entry *entry)
                url_encoded_name = url_encode(name);
                if (url_encoded_name != NULL) {
                        /* Convert narrow-character to wide-character. */
-                       int wcs_length = strlen(url_encoded_name);
+                       size_t wcs_length = strlen(url_encoded_name);
                        wcs_name = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t));
                        if (wcs_name == NULL)
                                __archive_errx(1, "No memory for xattr conversion");
@@ -1025,7 +1025,7 @@ build_ustar_entry_name(char *dest, const char *src, size_t src_length,
        char *p;
        int need_slash = 0; /* Was there a trailing slash? */
        size_t suffix_length = 99;
-       int insert_length;
+       size_t insert_length;
 
        /* Length of additional dir element to be added. */
        if (insert == NULL)
@@ -1249,7 +1249,8 @@ archive_write_pax_finish_entry(struct archive_write *a)
 static int
 write_nulls(struct archive_write *a, size_t padding)
 {
-       int ret, to_write;
+       int ret;
+       size_t to_write;
 
        while (padding > 0) {
                to_write = padding < a->null_length ? padding : a->null_length;
index 4c19b8e0d0a42b39de56580bdc9d931644717e6c..877ae09316b37e105464164964aab72fe0671099 100644 (file)
@@ -329,7 +329,7 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
        archive_le16enc(&h.flags, ZIP_FLAGS);
        archive_le16enc(&h.compression, zip->compression);
        archive_le32enc(&h.timedate, dos_time(archive_entry_mtime(entry)));
-       archive_le16enc(&h.filename_length, path_length(entry));
+       archive_le16enc(&h.filename_length, (uint16_t)path_length(entry));
 
        switch (zip->compression) {
        case COMPRESSION_STORE:
@@ -530,7 +530,7 @@ archive_write_zip_finish(struct archive_write *a)
                archive_le32enc(&h.crc32, l->crc32);
                archive_le32enc(&h.compressed_size, l->compressed_size);
                archive_le32enc(&h.uncompressed_size, archive_entry_size(l->entry));
-               archive_le16enc(&h.filename_length, path_length(l->entry));
+               archive_le16enc(&h.filename_length, (uint16_t)path_length(l->entry));
                archive_le16enc(&h.extra_length, sizeof(e));
                archive_le16enc(&h.attributes_external[2], archive_entry_mode(l->entry));
                archive_le32enc(&h.offset, l->offset);
@@ -663,5 +663,5 @@ write_path(struct archive_entry *entry, struct archive_write *archive)
                written_bytes += 1;
        }
 
-       return written_bytes;
+       return ((int)written_bytes);
 }
index 5fc2d9fd6670f6327002789acc220e4a5865a38e..4d1205028f3ea943fd573ad9067b25b2a4526f59 100644 (file)
@@ -62,10 +62,10 @@ permissive_name(const char *name)
 {
        wchar_t *wn, *wnp;
        wchar_t *ws, *wsp;
-       size_t l, len, slen, alloclen;
+       DWORD l, len, slen, alloclen;
        int unc;
 
-       len = strlen(name);
+       len = (DWORD)strlen(name);
        wn = malloc((len + 1) * sizeof(wchar_t));
        if (wn == NULL)
                return (NULL);
index 6a4b3f26640218648eac3ef6463a9ffd549d6716..5a32c361b8d277568fc1ce2088da267339ad4af6 100644 (file)
@@ -149,13 +149,13 @@ safe_fprintf(FILE *f, const char *fmt, ...)
                        } else {
                                /* Not printable, format the bytes. */
                                while (n-- > 0)
-                                       i += bsdtar_expand_char(
+                                       i += (unsigned)bsdtar_expand_char(
                                            outbuff, i, *p++);
                        }
                } else {
                        /* After any conversion failure, don't bother
                         * trying to convert the rest. */
-                       i += bsdtar_expand_char(outbuff, i, *p++);
+                       i += (unsigned)bsdtar_expand_char(outbuff, i, *p++);
                        try_wc = 0;
                }