]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix build failure in aggressive warnings
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 9 Feb 2012 15:56:49 +0000 (00:56 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 9 Feb 2012 16:43:49 +0000 (01:43 +0900)
14 files changed:
cpio/test/main.c
libarchive/archive_rb.c
libarchive/archive_read_disk_entry_from_file.c
libarchive/archive_read_disk_posix.c
libarchive/archive_read_support_format_rar.c
libarchive/archive_read_support_format_zip.c
libarchive/archive_string.c
libarchive/archive_write_disk_posix.c
libarchive/archive_write_set_format_iso9660.c
libarchive/test/main.c
libarchive/test/test_acl_pax.c
libarchive/test/test_acl_posix1e.c
libarchive/test/test_sparse_basic.c
tar/test/main.c

index e19aabcc42c63cfc0764a886ecb3885dc7c55255..a0c5295860c7872a6510c7bd063c92e3f710a811 100644 (file)
@@ -1316,7 +1316,7 @@ assertion_file_nlinks(const char *file, int line,
 
        assertion_count(file, line);
        r = lstat(pathname, &st);
-       if (r == 0 && st.st_nlink == nlinks)
+       if (r == 0 && (int)st.st_nlink == nlinks)
                        return (1);
        failure_start(file, line, "File %s has %d links, expected %d",
            pathname, st.st_nlink, nlinks);
@@ -1380,7 +1380,7 @@ assertion_is_dir(const char *file, int line, const char *pathname, int mode)
        /* Windows doesn't handle permissions the same way as POSIX,
         * so just ignore the mode tests. */
        /* TODO: Can we do better here? */
-       if (mode >= 0 && mode != (st.st_mode & 07777)) {
+       if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
                failure_start(file, line, "Dir %s has wrong mode", pathname);
                logprintf("  Expected: 0%3o\n", mode);
                logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1413,7 +1413,7 @@ assertion_is_reg(const char *file, int line, const char *pathname, int mode)
        /* Windows doesn't handle permissions the same way as POSIX,
         * so just ignore the mode tests. */
        /* TODO: Can we do better here? */
-       if (mode >= 0 && mode != (st.st_mode & 07777)) {
+       if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
                failure_start(file, line, "File %s has wrong mode", pathname);
                logprintf("  Expected: 0%3o\n", mode);
                logprintf("  Found: 0%3o\n", st.st_mode & 07777);
index fa307be25064c2ef40349ed9433004f8c46aefee..70bf7e6d3379b873c717d640f0e19c2a5947aec1 100644 (file)
@@ -96,7 +96,7 @@ __archive_rb_tree_init(struct archive_rb_tree *rbt,
     const struct archive_rb_tree_ops *ops)
 {
        rbt->rbt_ops = ops;
-       *((const struct archive_rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE;
+       *((struct archive_rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE;
 }
 
 struct archive_rb_node *
@@ -683,7 +683,7 @@ __archive_rb_tree_iterate(struct archive_rb_tree *rbt,
         */
        if (RB_SENTINEL_P(self->rb_nodes[direction])) {
                while (!RB_ROOT_P(rbt, self)) {
-                       if (other == RB_POSITION(self))
+                       if (other == (unsigned int)RB_POSITION(self))
                                return RB_FATHER(self);
                        self = RB_FATHER(self);
                }
index 8ce88b380fca8994b9c734b81c468da08ac15312..284b9e9733b3fe2b4df36aa3f142f3fb75b88854 100644 (file)
@@ -191,7 +191,7 @@ archive_read_disk_entry_from_file(struct archive *_a,
                        fd = open(path, O_RDONLY | O_NONBLOCK);
                if (fd >= 0) {
                        unsigned long stflags;
-                       int r = ioctl(fd, EXT2_IOC_GETFLAGS, &stflags);
+                       r = ioctl(fd, EXT2_IOC_GETFLAGS, &stflags);
                        if (r == 0 && stflags != 0)
                                archive_entry_set_fflags(entry, stflags, 0);
                }
@@ -870,12 +870,12 @@ setup_sparse(struct archive_read_disk *a,
                if (fm->fm_mapped_extents == 0)
                        break;
                fe = fm->fm_extents;
-               for (i = 0; i < fm->fm_mapped_extents; i++, fe++) {
+               for (i = 0; i < (int)fm->fm_mapped_extents; i++, fe++) {
                        if (!(fe->fe_flags & FIEMAP_EXTENT_UNWRITTEN)) {
                                /* The fe_length of the last block does not
                                 * adjust itself to its size files. */
                                int64_t length = fe->fe_length;
-                               if (fe->fe_logical + length > size)
+                               if (fe->fe_logical + length > (uint64_t)size)
                                        length -= fe->fe_logical + length - size;
                                if (fe->fe_logical == 0 && length == size) {
                                        /* This is not sparse. */
index b81ab30fe7194e31dfce27049e5bcb13f63a9098..dd03ceebaa2c7b026f998a979b50d5e7961f6332 100644 (file)
@@ -2214,7 +2214,8 @@ tree_target_is_same_as_parent(struct tree *t, const struct stat *st)
        struct tree_entry *te;
 
        for (te = t->current->parent; te != NULL; te = te->parent) {
-               if (te->dev == st->st_dev && te->ino == st->st_ino)
+               if (te->dev == (int64_t)st->st_dev &&
+                   te->ino == (int64_t)st->st_ino)
                        return (1);
        }
        return (0);
@@ -2231,7 +2232,8 @@ tree_current_is_symblic_link_target(struct tree *t)
 
        lst = tree_current_lstat(t);
        st = tree_current_stat(t);
-       return (st != NULL && st->st_dev == t->current_filesystem->dev &&
+       return (st != NULL &&
+           (int64_t)st->st_dev == t->current_filesystem->dev &&
            st->st_dev != lst->st_dev);
 }
 
index 838407950b8eb065784e43961682e35b033313a9..1a8b157eb1f3227e998a91144c89748029cda077 100644 (file)
@@ -305,7 +305,7 @@ static int archive_read_format_rar_cleanup(struct archive_read *);
 
 /* Support functions */
 static int read_header(struct archive_read *, struct archive_entry *, char);
-static time_t get_time(int time);
+static time_t get_time(int);
 static int read_exttime(const char *, struct rar *, const char *);
 static int read_symlink_stored(struct archive_read *, struct archive_entry *,
                                struct archive_string_conv *);
@@ -1047,7 +1047,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
   memcpy(&rar_header, p, sizeof(rar_header));
   rar->file_flags = archive_le16dec(rar_header.flags);
   header_size = archive_le16dec(rar_header.size);
-  if (header_size < sizeof(file_header) + 7) {
+  if (header_size < (int64_t)sizeof(file_header) + 7) {
     archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
       "Invalid header size");
     return (ARCHIVE_FATAL);
index fce04b8a2cc1557731ef4e68bfdb5af2a1c55177..5668f12c5375f1122ea00c7894850f2d2aba2c80 100644 (file)
@@ -265,7 +265,7 @@ archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
        if (zip->central_directory_entries != archive_le16dec(p + 8))
                return 0;
        /* Central directory can't extend beyond end of this file. */
-       if (zip->central_directory_offset + zip->central_directory_size > filesize)
+       if (zip->central_directory_offset + (int64_t)zip->central_directory_size > filesize)
                return 0;
 
        /* This is just a tiny bit higher than the maximum returned by
index 49ff108ee0a34c7f105f100b96d0451e38a71af2..1dce5600e44bd5852aa87e9548016f38522f07d7 100644 (file)
@@ -1646,7 +1646,7 @@ make_codepage_from_charset(const char *charset)
  * Return ANSI Code Page of current locale set by setlocale().
  */
 static unsigned
-get_current_codepage()
+get_current_codepage(void)
 {
        char *locale, *p;
        unsigned cp;
@@ -1721,7 +1721,7 @@ static struct {
  * Return OEM Code Page of current locale set by setlocale().
  */
 static unsigned
-get_current_oemcp()
+get_current_oemcp(void)
 {
        int i;
        char *locale, *p;
@@ -1750,7 +1750,7 @@ get_current_oemcp()
  */
 
 static unsigned
-get_current_codepage()
+get_current_codepage(void)
 {
        return (-1);/* Unknown */
 }
@@ -1761,7 +1761,7 @@ make_codepage_from_charset(const char *charset)
        return (-1);/* Unknown */
 }
 static unsigned
-get_current_oemcp()
+get_current_oemcp(void)
 {
        return (-1);/* Unknown */
 }
index a07960f550fbfcd1bd517730420138cbdf809db3..752ce89806edd183427cc2aed52664885e2fe818 100644 (file)
@@ -1672,7 +1672,7 @@ cleanup_pathname_win(struct archive_write_disk *a)
        p = a->name;
        while (*p != '\0' && alen) {
                l = mbtowc(&wc, p, alen);
-               if (l == -1) {
+               if (l == (size_t)-1) {
                        while (*p != '\0') {
                                if (*p == '\\')
                                        *p = '/';
@@ -1979,6 +1979,7 @@ set_time(int fd, int mode, const char *name,
         * on fds and symlinks.
         */
        struct timespec ts[2];
+       (void)mode; /* UNUSED */
        ts[0].tv_sec = atime;
        ts[0].tv_nsec = atime_nsec;
        ts[1].tv_sec = mtime;
@@ -2036,6 +2037,11 @@ set_time(int fd, int mode, const char *name,
        /*
         * We don't know how to set the time on this platform.
         */
+       (void)fd; /* UNUSED */
+       (void)mode; /* UNUSED */
+       (void)name; /* UNUSED */
+       (void)atime_nsec; /* UNUSED */
+       (void)mtime_nsec; /* UNUSED */
        return (ARCHIVE_WARN);
 #endif
 }
@@ -2105,6 +2111,9 @@ set_times(struct archive_write_disk *a,
                r1 = set_time(fd, mode, name,
                              atime, atime_nanos,
                              birthtime, birthtime_nanos);
+#else
+       (void)birthtime; /* UNUSED */
+       (void)birthtime_nanos; /* UNUSED */
 #endif
        r2 = set_time(fd, mode, name,
                      atime, atime_nanos,
@@ -2537,12 +2546,12 @@ set_mac_metadata(struct archive_write_disk *a, const char *pathname,
 /* Default empty function body to satisfy mainline code. */
 static int
 set_acls(struct archive_write_disk *a, int fd, const char *name,
-        struct archive_acl *acl)
+        struct archive_acl *aacl)
 {
        (void)a; /* UNUSED */
        (void)fd; /* UNUSED */
        (void)name; /* UNUSED */
-       (void)acl; /* UNUSED */
+       (void)aacl; /* UNUSED */
        return (ARCHIVE_OK);
 }
 
index 2e43be54343fe6546ea1362c128a9514dcca3e81..bdb3e3a1b569f0f951decf2d96beee654c5d0948 100644 (file)
@@ -3689,7 +3689,7 @@ wb_set_offset(struct archive_write *a, int64_t off)
                ext_bytes = off - iso9660->wbuff_tail;
                iso9660->wbuff_remaining = sizeof(iso9660->wbuff)
                   - (iso9660->wbuff_tail - iso9660->wbuff_offset);
-               while (ext_bytes >= iso9660->wbuff_remaining) {
+               while (ext_bytes >= (int64_t)iso9660->wbuff_remaining) {
                        if (write_null(a, (size_t)iso9660->wbuff_remaining)
                            != ARCHIVE_OK)
                                return (ARCHIVE_FATAL);
@@ -6513,8 +6513,7 @@ isoent_traverse_tree(struct archive_write *a, struct vdd* vdd)
        struct idr idr;
        int depth;
        int r;
-       int (*genid)(struct archive_write *a, struct isoent *isoent,
-           struct idr *idr);
+       int (*genid)(struct archive_write *, struct isoent *, struct idr *);
 
        idr_init(iso9660, vdd, &idr);
        np = vdd->rootent;
@@ -7283,7 +7282,7 @@ setup_boot_information(struct archive_write *a)
                size_t rsize;
                ssize_t i, rs;
 
-               if (size > sizeof(buff))
+               if (size > (int64_t)sizeof(buff))
                        rsize = sizeof(buff);
                else
                        rsize = (size_t)size;
@@ -7466,7 +7465,7 @@ zisofs_detect_magic(struct archive_write *a, const void *buff, size_t s)
        int64_t entry_size;
 
        entry_size = archive_entry_size(file->entry);
-       if (sizeof(iso9660->zisofs.magic_buffer) > entry_size)
+       if ((int64_t)sizeof(iso9660->zisofs.magic_buffer) > entry_size)
                magic_max = entry_size;
        else
                magic_max = sizeof(iso9660->zisofs.magic_buffer);
@@ -7511,7 +7510,7 @@ zisofs_detect_magic(struct archive_write *a, const void *buff, size_t s)
        ceil = (uncompressed_size +
                (ARCHIVE_LITERAL_LL(1) << log2_bs) -1) >> log2_bs;
        doff = (ceil + 1) * 4 + 16;
-       if (entry_size < doff)
+       if (entry_size < (int64_t)doff)
                return;/* Invalid data. */
 
        /* Check every Block Pointer has valid value. */
index 64f0380602d5b8f35259b6d41a2ea86f3b537376..386b10b500b1ba0934f365d456376cc035184be3 100644 (file)
@@ -1314,7 +1314,7 @@ assertion_file_nlinks(const char *file, int line,
 
        assertion_count(file, line);
        r = lstat(pathname, &st);
-       if (r == 0 && st.st_nlink == nlinks)
+       if (r == 0 && (int)st.st_nlink == nlinks)
                        return (1);
        failure_start(file, line, "File %s has %d links, expected %d",
            pathname, st.st_nlink, nlinks);
@@ -1378,7 +1378,7 @@ assertion_is_dir(const char *file, int line, const char *pathname, int mode)
        /* Windows doesn't handle permissions the same way as POSIX,
         * so just ignore the mode tests. */
        /* TODO: Can we do better here? */
-       if (mode >= 0 && mode != (st.st_mode & 07777)) {
+       if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
                failure_start(file, line, "Dir %s has wrong mode", pathname);
                logprintf("  Expected: 0%3o\n", mode);
                logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1411,7 +1411,7 @@ assertion_is_reg(const char *file, int line, const char *pathname, int mode)
        /* Windows doesn't handle permissions the same way as POSIX,
         * so just ignore the mode tests. */
        /* TODO: Can we do better here? */
-       if (mode >= 0 && mode != (st.st_mode & 07777)) {
+       if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
                failure_start(file, line, "File %s has wrong mode", pathname);
                logprintf("  Expected: 0%3o\n", mode);
                logprintf("  Found: 0%3o\n", st.st_mode & 07777);
index 6a7ee1516491f3de4dc6cb38266bd4f516db2156..2bee4572cf7f0b6c3138bf57daf9ad1bb02286b3 100644 (file)
@@ -163,7 +163,7 @@ compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode)
                }
        }
        assertEqualInt(ARCHIVE_EOF, r);
-       assert((mode & 0777) == (archive_entry_mode(ae) & 0777));
+       assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777));
        failure("Could not find match for ACL "
            "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
            acls[marker[0]].type, acls[marker[0]].permset,
index 68e76671ba2942b28a8fe11bffbd7af4a5c7ab16..2055682bb2abb6655b5670b7fe3c073051ae7597 100644 (file)
@@ -193,7 +193,7 @@ compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode)
                }
        }
        assertEqualInt(ARCHIVE_EOF, r);
-       assert((mode & 0777) == (archive_entry_mode(ae) & 0777));
+       assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777));
        failure("Could not find match for ACL "
            "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
            acls[marker[0]].type, acls[marker[0]].permset,
index 52d76c6013df74441ef82381764820d53ac9d3b3..1d62e7c7883a45076758a9580ece45120aa4db56 100644 (file)
@@ -177,6 +177,7 @@ is_sparse_supported(const char *path)
        char buff[1024];
        const char *testfile = "can_sparse";
 
+       (void)path; /* UNUSED */
        memset(&ut, 0, sizeof(ut));
        assertEqualInt(uname(&ut), 0);
        p = ut.release;
@@ -221,6 +222,7 @@ is_sparse_supported(const char *path)
 static int
 is_sparse_supported(const char *path)
 {
+       (void)path; /* UNUSED */
        return (0);
 }
 
index eb33cf27145a5e8500a9ea3958d4285a255b296b..984b4cea9185c72d10503b122d095491fb7fc37f 100644 (file)
@@ -1316,7 +1316,7 @@ assertion_file_nlinks(const char *file, int line,
 
        assertion_count(file, line);
        r = lstat(pathname, &st);
-       if (r == 0 && st.st_nlink == nlinks)
+       if (r == 0 && (int)st.st_nlink == nlinks)
                        return (1);
        failure_start(file, line, "File %s has %d links, expected %d",
            pathname, st.st_nlink, nlinks);
@@ -1380,7 +1380,7 @@ assertion_is_dir(const char *file, int line, const char *pathname, int mode)
        /* Windows doesn't handle permissions the same way as POSIX,
         * so just ignore the mode tests. */
        /* TODO: Can we do better here? */
-       if (mode >= 0 && mode != (st.st_mode & 07777)) {
+       if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
                failure_start(file, line, "Dir %s has wrong mode", pathname);
                logprintf("  Expected: 0%3o\n", mode);
                logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1413,7 +1413,7 @@ assertion_is_reg(const char *file, int line, const char *pathname, int mode)
        /* Windows doesn't handle permissions the same way as POSIX,
         * so just ignore the mode tests. */
        /* TODO: Can we do better here? */
-       if (mode >= 0 && mode != (st.st_mode & 07777)) {
+       if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
                failure_start(file, line, "File %s has wrong mode", pathname);
                logprintf("  Expected: 0%3o\n", mode);
                logprintf("  Found: 0%3o\n", st.st_mode & 07777);