]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add printf attributes to the printflike functions used in tests and fix
authorzoulasc <christos@zoulas.com>
Tue, 21 Jan 2020 18:34:18 +0000 (13:34 -0500)
committerMartin Matuska <martin@matuska.org>
Wed, 22 Jan 2020 23:19:32 +0000 (00:19 +0100)
the format errors.

Closes #1318

38 files changed:
CMakeLists.txt
cat/test/test_0.c
cpio/test/test_basic.c
cpio/test/test_format_newc.c
libarchive/test/test_compat_zip.c
libarchive/test/test_fuzz.c
libarchive/test/test_read_extract.c
libarchive/test/test_read_format_gtar_sparse.c
libarchive/test/test_read_format_zip.c
libarchive/test/test_read_format_zip_7075_utf8_paths.c
libarchive/test/test_read_format_zip_comment_stored.c
libarchive/test/test_read_format_zip_extra_padding.c
libarchive/test/test_read_format_zip_high_compression.c
libarchive/test/test_read_format_zip_jar.c
libarchive/test/test_read_format_zip_mac_metadata.c
libarchive/test/test_read_format_zip_malformed.c
libarchive/test/test_read_format_zip_msdos.c
libarchive/test/test_read_format_zip_nested.c
libarchive/test/test_read_format_zip_nofiletype.c
libarchive/test/test_read_format_zip_padded.c
libarchive/test/test_read_format_zip_sfx.c
libarchive/test/test_read_format_zip_with_invalid_traditional_eocd.c
libarchive/test/test_read_format_zip_zip64.c
libarchive/test/test_read_pax_truncated.c
libarchive/test/test_read_truncated_filter.c
libarchive/test/test_sparse_basic.c
libarchive/test/test_write_disk.c
libarchive/test/test_write_format_cpio_empty.c
libarchive/test/test_write_format_shar_empty.c
libarchive/test/test_write_format_tar.c
libarchive/test/test_write_format_tar_sparse.c
libarchive_fe/err.h
tar/test/test_basic.c
tar/test/test_copy.c
tar/test/test_option_C_upper.c
tar/test/test_option_s.c
test_utils/test_common.h
test_utils/test_main.c

index 552aef96197c014d7069f9f8db1be7d5942cb5af..9e46c6ca3fe9264956cfa66cea06789ec2b9906d 100644 (file)
@@ -287,6 +287,10 @@ IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$")
   ADD_DEFINITIONS(-D_XOPEN_SOURCE=500) # Ask wchar.h for mbstate_t
 ENDIF()
 
+IF(MINGW)
+  ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO)
+ENDIF()
+
 #
 INCLUDE(CheckCSourceCompiles)
 INCLUDE(CheckCSourceRuns)
index f9fe5d8473f9d790f228ac3537fed15fb50592af..c806c24356c0b84bc8eea8e81f4d8d68e98f2085 100644 (file)
@@ -59,7 +59,7 @@ DEFINE_TEST(test_0)
         * we know some option that will succeed.
         */
        if (0 != systemf("%s --version >" DEV_NULL, testprog)) {
-               failure("Unable to successfully run: %s --version\n", testprog, testprog);
+               failure("Unable to successfully run: %s --version\n", testprog);
                assert(0);
        }
 
index a8fedf89e9688f030e171483f5052bcccb54a833..b716253408fa55d747a84fb4a48167fd965dee1c 100644 (file)
@@ -33,15 +33,15 @@ verify_files(const char *msg)
         */
 
        /* Regular file with 2 links. */
-       failure(msg);
+       failure("%s", msg);
        assertIsReg("file", 0644);
-       failure(msg);
+       failure("%s", msg);
        assertFileSize("file", 10);
-       failure(msg);
+       failure("%s", msg);
        assertFileNLinks("file", 2);
 
        /* Another name for the same file. */
-       failure(msg);
+       failure("%s", msg);
        assertIsHardlink("linkfile", "file");
 
        /* Symlink */
@@ -49,11 +49,11 @@ verify_files(const char *msg)
                assertIsSymlink("symlink", "file", 0);
 
        /* Another file with 1 link and different permissions. */
-       failure(msg);
+       failure("%s", msg);
        assertIsReg("file2", 0777);
-       failure(msg);
+       failure("%s", msg);
        assertFileSize("file2", 10);
-       failure(msg);
+       failure("%s", msg);
        assertFileNLinks("file2", 1);
 
        /* dir */
index 6c981f6ac139361b603f29abfaaa075a6a7a4e7b..49387a73580bfb4d97b32d3c068ae4167b31f9da 100644 (file)
@@ -205,9 +205,11 @@ DEFINE_TEST(test_format_newc)
        gid = from_hex(e + 30, 8); /* gid */
        assertEqualMem(e + 38, "00000003", 8); /* nlink */
        t = from_hex(e + 46, 8); /* mtime */
-       failure("t=0x%08x now=0x%08x=%d", t, now, now);
+       failure("t=%#08jx now=%#08jx=%jd", (intmax_t)t, (intmax_t)now,
+           (intmax_t)now);
        assert(t <= now); /* File wasn't created in future. */
-       failure("t=0x%08x now - 2=0x%08x = %d", t, now - 2, now - 2);
+       failure("t=%#08jx now - 2=%#08jx=%jd", (intmax_t)t, (intmax_t)now - 2,
+           (intmax_t)now - 2);
        assert(t >= now - 2); /* File was created w/in last 2 secs. */
        failure("newc format stores body only with last appearance of a link\n"
            "       first appearance should be empty, so this file size\n"
@@ -243,7 +245,8 @@ DEFINE_TEST(test_format_newc)
                assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
                assertEqualMem(e + 38, "00000001", 8); /* nlink */
                t2 = from_hex(e + 46, 8); /* mtime */
-               failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
+               failure("First entry created at t=%#08jx this entry created"
+                   " at t2=%#08jx", (intmax_t)t, (intmax_t)t2);
                assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
                assertEqualMem(e + 54, "00000005", 8); /* File size */
                fs = from_hex(e + 54, 8);
@@ -278,7 +281,8 @@ DEFINE_TEST(test_format_newc)
        assertEqualInt(nlinks("dir"), from_hex(e + 38, 8)); /* nlinks */
 #endif
        t2 = from_hex(e + 46, 8); /* mtime */
-       failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
+       failure("First entry created at t=%#08jx this entry created at"
+           "t2=%#08jx", (intmax_t)t, (intmax_t)t2);
        assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
        assertEqualMem(e + 54, "00000000", 8); /* File size */
        fs = from_hex(e + 54, 8);
@@ -311,7 +315,8 @@ DEFINE_TEST(test_format_newc)
        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
        assertEqualMem(e + 38, "00000003", 8); /* nlink */
        t2 = from_hex(e + 46, 8); /* mtime */
-       failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
+       failure("First entry created at t=%#08jx this entry created at"
+           "t2=%#08jx", (intmax_t)t, (intmax_t)t2);
        assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
        assertEqualInt(10, from_hex(e + 54, 8)); /* File size */
        fs = from_hex(e + 54, 8);
index 39152206c1bc6d5a7e6a0e71b7342abe748c67ab..813ea5dc6701c4bd48a6d5f5d9d5337e15247b14 100644 (file)
@@ -156,7 +156,7 @@ DEFINE_TEST(test_compat_zip_4)
        size_t s;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* SFX files require seek support. */
        assert((a = archive_read_new()) != NULL);
@@ -214,7 +214,7 @@ DEFINE_TEST(test_compat_zip_5)
        size_t s;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* Verify with seek support.
         * Everything works correctly here. */
@@ -370,7 +370,7 @@ DEFINE_TEST(test_compat_zip_6)
        size_t s;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
@@ -402,7 +402,7 @@ DEFINE_TEST(test_compat_zip_7)
        int i;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        for (i = 1; i < 1000; ++i) {
                assert((a = archive_read_new()) != NULL);
@@ -436,7 +436,7 @@ DEFINE_TEST(test_compat_zip_8)
        size_t s;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
index d02fd993f97281159f7a521279b42f4957eac507..b2654c4a3396d9b95bcfef6bf3bee4e6a355c81b 100644 (file)
@@ -119,7 +119,8 @@ test_fuzz(const struct files *filesets)
                        for (i = 0; filesets[n].names[i] != NULL; ++i)
                        {
                                char *newraw;
-                               tmp = slurpfile(&size, filesets[n].names[i]);
+                               tmp = slurpfile(&size, "%s",
+                                               filesets[n].names[i]);
                                newraw = realloc(rawimage, oldsize + size);
                                if (!assert(newraw != NULL))
                                {
index cd06096eff693a357d8be878bbdc77bb9c14222c..2b1a21e4715b0d11a7980774555a6bf184c0674e 100644 (file)
@@ -120,7 +120,7 @@ DEFINE_TEST(test_read_extract)
        assertA(0 == archive_read_support_filter_all(a));
        assertA(0 == archive_read_open_memory(a, buff, BUFF_SIZE));
        /* Restore first entry with _EXTRACT_PERM. */
-       failure("Error reading first entry", i);
+       failure("Error reading first entry");
        assertA(0 == archive_read_next_header(a, &ae));
        assertA(0 == archive_read_extract(a, ae, ARCHIVE_EXTRACT_PERM));
        /* Rest of entries get restored with no flags. */
index 7ab13c1109a0282af1b83e258235979c55744bfa..6d15a4745f9ce7be0a8216df1008da7f60e0ae66 100644 (file)
@@ -214,8 +214,9 @@ verify_archive_file(const char *name, struct archive_contents *ac)
                                         * Any byte before the expected
                                         * data must be NULL.
                                         */
-                                       failure("%s: pad at offset %d "
-                                           "should be zero", name, actual.o);
+                                       failure("%s: pad at offset %jd "
+                                               "should be zero", name,
+                                               (intmax_t)actual.o);
                                        assertEqualInt(c, 0);
                                } else if (actual.o == expect.o) {
                                        /*
index 9afbfb6c58666103d09da1549edb03aa037fe954..04f7e98ccfcd26a4a807c7fba2bc2471d5847caf 100644 (file)
@@ -194,7 +194,7 @@ test_basic(void)
        verify_basic(a, 1);
 
        /* Verify with streaming reader. */
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
@@ -264,7 +264,7 @@ test_info_zip_ux(void)
        verify_info_zip_ux(a, 1);
 
        /* Verify with streaming reader. */
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
@@ -328,7 +328,7 @@ test_extract_length_at_end(void)
        verify_extract_length_at_end(a, 1);
 
        /* Verify extraction with streaming reader. */
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
@@ -347,7 +347,7 @@ test_symlink(void)
        struct archive_entry *ae;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* Symlinks can only be extracted with the seeking reader. */
        assert((a = archive_read_new()) != NULL);
index 7b78770aae4377d07754e8437e5e85e2946b2dfc..a0a510c8f29ba8dcfccd3f5b09de983401d7f6c1 100644 (file)
@@ -90,7 +90,7 @@ DEFINE_TEST(test_read_format_zip_utf8_paths)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
 
        /* Verify with streaming reader. */
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
index b92b2886cddaf8cd17f571c1024e6b531434d6aa..95df0107fecb91f0f9c400518ee26e1c499d4c63 100644 (file)
@@ -38,7 +38,7 @@ verify(const char *refname)
        struct archive_entry *ae;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* Symlinks can only be extracted with the seeking reader. */
        assert((a = archive_read_new()) != NULL);
index 54f7fa04ee89a199208423e43423fe0b0a3f8793..6e2f836f16e4e6f333a862fd745d1709460a473a 100644 (file)
@@ -80,7 +80,7 @@ DEFINE_TEST(test_read_format_zip_extra_padding)
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
        /* Verify with streaming reader. */
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
index 42faed378f6d951fcb21f2cb1e6c91dadad44def..16cfbb182893cd0423c0dc42e64466318887847b 100644 (file)
@@ -56,7 +56,7 @@ DEFINE_TEST(test_read_format_zip_high_compression)
        }
 
        extract_reference_file(refname);
-       p = slurpfile(&archive_size, refname);
+       p = slurpfile(&archive_size, "%s", refname);
 
        assert((a = archive_read_new()) != NULL);
         assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
index ffb520eb83c12d9f03227aaf4faf7ef6ef030759..912e6713770421c873a3db7a87aea9f7b684abc3 100644 (file)
@@ -40,7 +40,7 @@ DEFINE_TEST(test_read_format_zip_jar)
        char data[16];
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a));
index 99b7012328cbfbabc7c9d3c1e3b36bbbd8167152..3f2813cc98947d7874868abe263e3bbd07e39b3e 100644 (file)
@@ -76,7 +76,7 @@ DEFINE_TEST(test_read_format_zip_mac_metadata)
        };
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* Mac metadata can only be extracted with the seeking reader. */
        assert((a = archive_read_new()) != NULL);
index e14a3f5660daf0e82d6114e52f193d829db333bd..f1160648e759c9e2c5c07fd3bf0809a06c1eb661 100644 (file)
@@ -46,7 +46,7 @@ test_malformed1(void)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
 
        /* Verify with streaming reader. */
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
index 5f147d5577845c66d57db345140814c77c199c56..1867204bb6ec2b4cbf6927c939faff67e8270b2b 100644 (file)
@@ -103,7 +103,7 @@ DEFINE_TEST(test_read_format_zip_msdos)
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
        /* Verify with streaming reader. */
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
index 5f6edf2674430e1b616e64169019f89b81f571d4..4418fc4f25022772d7f50058a3958f42dce39c9f 100644 (file)
@@ -34,7 +34,7 @@ DEFINE_TEST(test_read_format_zip_nested)
        struct archive_entry *ae;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* Inspect outer Zip */
        assert((a = archive_read_new()) != NULL);
index b01afabe953bfe5a8d6ee31478cf7440a4ba66aa..b3260fa7563be05626a3b4c0693a0f0e1656fe45 100644 (file)
@@ -40,7 +40,7 @@ DEFINE_TEST(test_read_format_zip_nofiletype)
        char data[16];
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a));
index 2094eca3557ae24bc9c08efcf546fd354d72dcaf..d8c694bae5e257cdb99d002f926320b5dc77c522 100644 (file)
@@ -34,7 +34,7 @@ verify_padded_archive(const char *refname)
        struct archive_entry *ae;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a));
index dc76ef9b38266f44c77fc7337589659c6125b5ba..a33c1b808c567f48c72fd0db3e679ba088418105 100644 (file)
@@ -37,7 +37,7 @@ DEFINE_TEST(test_read_format_zip_sfx)
        struct archive_entry *ae;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* Symlinks can only be extracted with the seeking reader. */
        assert((a = archive_read_new()) != NULL);
index dc94f94f1571e6071216ac2cffb79c2c6cace3bc..aca8bed6094834f9959a2351c5f290b13be459da 100644 (file)
@@ -39,7 +39,7 @@ DEFINE_TEST(test_read_format_zip_with_invalid_traditional_eocd)
        struct archive_entry *ae;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a));
index ac3789f46b83c413e330633808d4aa25ff063946..bd2324e549b3cc0513d50a46360a083e75bca039 100644 (file)
@@ -88,7 +88,7 @@ DEFINE_TEST(test_read_format_zip_zip64a)
        size_t s;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* First read with seeking. */
        assert((a = archive_read_new()) != NULL);
@@ -112,7 +112,7 @@ DEFINE_TEST(test_read_format_zip_zip64b)
        size_t s;
 
        extract_reference_file(refname);
-       p = slurpfile(&s, refname);
+       p = slurpfile(&s, "%s", refname);
 
        /* First read with seeking. */
        assert((a = archive_read_new()) != NULL);
index bc5d74d5bdb8536fec2ee06a38ff80f470335338..1f6e78ace2027387197e5e98b89c9f556ece6696 100644 (file)
@@ -82,7 +82,7 @@ DEFINE_TEST(test_read_pax_truncated)
                        assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
                        goto wrap_up;
                } else {
-                       failure("Archive truncated to %d bytes", i);
+                       failure("Archive truncated to %zu bytes", i);
                        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
                }
 
@@ -91,7 +91,7 @@ DEFINE_TEST(test_read_pax_truncated)
                        assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, filedata, filedata_size));
                        goto wrap_up;
                } else {
-                       failure("Archive truncated to %d bytes", i);
+                       failure("Archive truncated to %zu bytes", i);
                        assertEqualIntA(a, filedata_size,
                            archive_read_data(a, filedata, filedata_size));
                }
@@ -103,7 +103,7 @@ DEFINE_TEST(test_read_pax_truncated)
                 * does not return an error if it can't consume
                 * it.) */
                if (i < 1536 + 512*((filedata_size + 511)/512) + 512) {
-                       failure("i=%d minsize=%d", i,
+                       failure("i=%zu minsize=%zu", i,
                            1536 + 512*((filedata_size + 511)/512) + 512);
                        assertEqualIntA(a, ARCHIVE_FATAL,
                            archive_read_next_header(a, &ae));
index 6cc91e347a2346ce026c84b98a92dc96ada0e81a..632638d6fe9286ecd67ee8626343b380e7219a0e 100644 (file)
@@ -83,7 +83,7 @@ test_truncation(const char *compression,
        for (i = 0; i < 100; i++) {
                sprintf(path, "%s%d", compression, i);
                archive_entry_copy_pathname(ae, path);
-               failure(path);
+               failure("%s", path);
                if (!assertEqualIntA(a, ARCHIVE_OK,
                    archive_write_header(a, ae))) {
                        archive_write_free(a);
@@ -94,7 +94,7 @@ test_truncation(const char *compression,
                for (j = 0; j < (int)datasize; ++j) {
                        data[j] = (char)(rand() % 256);
                }
-               failure(path);
+               failure("%s", path);
                if (!assertEqualIntA(a, datasize,
                    archive_write_data(a, data, datasize))) {
                        archive_write_free(a);
index 033c052db001200d4fa4c3442e8b9eb0de9ef93d..0fbb7f7bf467862e1c5bcdf794b8481a1c2620d7 100644 (file)
@@ -430,7 +430,7 @@ verify_sparse_file(struct archive *a, const char *path,
        assert(sparse->type == END);
        assertEqualInt(expected_offset, archive_entry_size(ae));
 
-       failure(path);
+       failure("%s", path);
        assertEqualInt(holes_seen, expected_holes);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
@@ -466,7 +466,7 @@ verify_sparse_file2(struct archive *a, const char *path,
        /* Verify the number of holes only, not its offset nor its
         * length because those alignments are deeply dependence on
         * its filesystem. */ 
-       failure(path);
+       failure("%s", path);
        assertEqualInt(blocks, archive_entry_sparse_count(ae));
        archive_entry_free(ae);
 }
index 60bcdc24edf5e9896217630d0314dc8e88a6d65b..e38dbc78ff4ea918ee80cf3a4d5dc15569eec459 100644 (file)
@@ -186,7 +186,7 @@ static void create_reg_file4(struct archive_entry *ae, const char *msg)
 #if !defined(_WIN32) || defined(__CYGWIN__)
        assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
 #endif
-       failure(msg);
+       failure("%s", msg);
        assertEqualInt(st.st_size, sizeof(data));
 }
 
index 60fb283401337cbbf044a9c369afe1a444f5748b..2ba415c7b987797b9164669ef989b5cf785a00b9 100644 (file)
@@ -64,7 +64,7 @@ DEFINE_TEST(test_write_format_cpio_empty)
        assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
        assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
-       failure("Empty cpio archive should be exactly 87 bytes, was %d.", used);
+       failure("Empty cpio archive should be exactly 87 bytes, was %zu.", used);
        assert(used == 87);
        failure("Empty cpio archive is incorrectly formatted.");
        assertEqualMem(buff, ref, 87);
index 03d70a3b5fa6a4517aee86bbfb43280d9ec89f9a..13794b02bb06aa700034f8d0e3bab665fe4ad542 100644 (file)
@@ -49,6 +49,6 @@ DEFINE_TEST(test_write_format_shar_empty)
        assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
        assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
-       failure("Empty shar archive should be exactly 0 bytes, was %d.", used);
+       failure("Empty shar archive should be exactly 0 bytes, was %zu.", used);
        assert(used == 0);
 }
index 3588e8fe2d948c65db0235315e838070069b44a3..a5ccdc0115bfa478ac60d02cafab5535762a5aa7 100644 (file)
@@ -81,7 +81,7 @@ DEFINE_TEST(test_write_format_tar)
 
                /* This calculation gives "the smallest multiple of
                 * the block size that is at least 2048 bytes". */
-               failure("blocksize=%d", blocksize);
+               failure("blocksize=%zu", blocksize);
                assertEqualInt(((2048 - 1)/blocksize+1)*blocksize, used);
 
                /*
index cc725a9a72ea58e6cb9ef8be900079a068e7dc3b..54ac00988e3d50c77f6ea14054384bea469bb719 100644 (file)
@@ -94,7 +94,7 @@ test_1(void)
 
                /* This calculation gives "the smallest multiple of
                 * the block size that is at least 11264 bytes". */
-               failure("blocksize=%d", blocksize);
+               failure("blocksize=%zu", blocksize);
                assertEqualInt(((11264 - 1)/blocksize+1)*blocksize, used);
 
                /*
@@ -229,7 +229,7 @@ test_2(void)
 
        /* This calculation gives "the smallest multiple of
         * the block size that is at least 11264 bytes". */
-       failure("blocksize=%d", blocksize);
+       failure("blocksize=%zu", blocksize);
        assertEqualInt(((11264 - 1)/blocksize+1)*blocksize, used);
 
        /*
index ebf5de814f5e5cbb1e6484ff70a011afa51bab3c..c663103b0b44ef4773c77322567a39a8c8977bc9 100644 (file)
 
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
                          (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
-#define        __LA_PRINTFLIKE(f,a)    __attribute__((__format__(__printf__, f, a)))
+# ifdef __MINGW_PRINTF_FORMAT
+#  define __LA_PRINTF_FORMAT __MINGW_PRINTF_FORMAT
+# else
+#  define __LA_PRINTF_FORMAT __printf__
+# endif
+# define __LA_PRINTFLIKE(f,a)  __attribute__((__format__(__LA_PRINTF_FORMAT, f, a)))
 #else
-#define        __LA_PRINTFLIKE(f,a)
+# define __LA_PRINTFLIKE(f,a)
 #endif
 
 void   lafe_warnc(int code, const char *fmt, ...) __LA_PRINTFLIKE(2, 3);
index 9bb966a0cf866745ac88f6f0e3cc1202ba95527c..b1c49834a45f2207b05df567d926220991f4206d 100644 (file)
@@ -96,7 +96,7 @@ run_tar(const char *target, const char *pack_options,
 
        /* Use the tar program to create an archive. */
        r = systemf("%s cf - %s %s >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target);
-       failure("Error invoking %s cf -", testprog, pack_options);
+       failure("Error invoking %s cf -%s", testprog, pack_options);
        assertEqualInt(r, 0);
 
        assertChdir(target);
index b828666b93fd62bacf5f344ac00513d090b0e471..d618e45ca36b136a881e9305bb1a5acaad575e62 100644 (file)
@@ -256,13 +256,13 @@ verify_tree(size_t limit)
                                        continue;
                                switch(dp[0]) {
                                case 'l': case 'm': case 'd':
-                                       failure("strlen(p)=%d", strlen(p));
+                                       failure("strlen(p)=%zu", strlen(p));
                                        assert(strlen(p) < limit);
                                        assertEqualString(p,
                                            filenames[strlen(p)]);
                                        break;
                                case 'f': case 's':
-                                       failure("strlen(p)=%d", strlen(p));
+                                       failure("strlen(p)=%zu", strlen(p));
                                        assert(strlen(p) < limit + 1);
                                        assertEqualString(p,
                                            filenames[strlen(p)]);
index dae985446892d3d933ec32c6d963e8495748dc31..538890f5817869c8adaf39e3602abc171fba0917 100644 (file)
@@ -117,7 +117,7 @@ DEFINE_TEST(test_option_C_upper)
        assertMakeDir("test6", 0755);
        assertChdir("test6");
        r = systemf("%s -cf archive.tar -C XXX -C ../d1 file1 2>write.err",
-           testprog, testworkdir);
+           testprog);
        assert(r != 0);
        assertNonEmptyFile("write.err");
        assertEqualInt(0,
index 09c72ee7d63d288be88685c9318ac4e4509bc923..fa799a295d01c969ca87c89265d3fe5be902e6d9 100644 (file)
@@ -92,10 +92,8 @@ DEFINE_TEST(test_option_s)
         * Test 5: Name-switching substitutions when extracting archive.
         */
        assertMakeDir("test5", 0755);
-       systemf("%s -cf test5.tar in/d1/foo in/d1/bar",
-           testprog, testprog);
-       systemf("%s -xf test5.tar -s /foo/bar/ -s }bar}foo} -C test5",
-           testprog, testprog);
+       systemf("%s -cf test5.tar in/d1/foo in/d1/bar", testprog);
+       systemf("%s -xf test5.tar -s /foo/bar/ -s }bar}foo} -C test5", testprog);
        assertFileContents("foo", 3, "test5/in/d1/bar");
        assertFileContents("bar", 3, "test5/in/d1/foo");
 
index 6604732066c1907cd6a98c8617a564bcc77c965c..80d54f0a450c82a5b578798fdf038f8a350bd715 100644 (file)
 #pragma warn -8068     /* Constant out of range in comparison. */
 #endif
 
+
+#if defined(__GNUC__) && (__GNUC__ > 2 || \
+                         (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
+# ifdef __MINGW_PRINTF_FORMAT
+#  define __LA_PRINTF_FORMAT __MINGW_PRINTF_FORMAT
+# else
+#  define __LA_PRINTF_FORMAT __printf__
+# endif
+# define __LA_PRINTFLIKE(f,a)  __attribute__((__format__(__LA_PRINTF_FORMAT, f, a)))
+#else
+# define __LA_PRINTFLIKE(f,a)
+#endif
+
 /* Haiku OS and QNX */
 #if defined(__HAIKU__) || defined(__QNXNTO__)
 /* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
   skipping_setup(__FILE__, __LINE__);test_skipping
 
 /* Function declarations.  These are defined in test_utility.c. */
-void failure(const char *fmt, ...);
+void failure(const char *fmt, ...) __LA_PRINTFLIKE(1, 2);
 int assertion_assert(const char *, int, int, const char *, void *);
 int assertion_chdir(const char *, int, const char *);
 int assertion_compare_fflags(const char *, int, const char *, const char *,
@@ -309,10 +322,10 @@ int assertion_utimes(const char *, int, const char *, long, long, long, long );
 int assertion_version(const char*, int, const char *, const char *);
 
 void skipping_setup(const char *, int);
-void test_skipping(const char *fmt, ...);
+void test_skipping(const char *fmt, ...) __LA_PRINTFLIKE(1, 2);
 
 /* Like sprintf, then system() */
-int systemf(const char * fmt, ...);
+int systemf(const char *fmt, ...) __LA_PRINTFLIKE(1, 2);
 
 /* Delay until time() returns a value after this. */
 void sleepUntilAfter(time_t);
@@ -375,7 +388,7 @@ void *sunacl_get(int cmd, int *aclcnt, int fd, const char *path);
 
 /* Suck file into string allocated via malloc(). Call free() when done. */
 /* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
-char *slurpfile(size_t *, const char *fmt, ...);
+char *slurpfile(size_t *, const char *fmt, ...) __LA_PRINTFLIKE(2, 3);
 
 /* Dump block of bytes to a file. */
 void dumpfile(const char *filename, void *, size_t);
index c34c0249fb7296f1a51d018eb3167ca6117195d8..7b8aa70fac2a3003c8bf50ad6f8269ba18fb525d 100644 (file)
@@ -388,7 +388,7 @@ static const char *refdir;
  */
 static int log_console = 0;
 static FILE *logfile;
-static void
+static void __LA_PRINTFLIKE(1, 0)
 vlogprintf(const char *fmt, va_list ap)
 {
 #ifdef va_copy
@@ -406,7 +406,7 @@ vlogprintf(const char *fmt, va_list ap)
 #endif
 }
 
-static void
+static void __LA_PRINTFLIKE(1, 2)
 logprintf(const char *fmt, ...)
 {
        va_list ap;
@@ -478,7 +478,7 @@ static struct line {
 const char *failed_filename;
 
 /* Count this failure, setup up log destination and handle initial report. */
-static void
+static void __LA_PRINTFLIKE(3, 4)
 failure_start(const char *filename, int line, const char *fmt, ...)
 {
        va_list ap;
@@ -751,7 +751,7 @@ static void strdump(const char *e, const char *p, int ewidth, int utf8)
                logprintf("]");
                logprintf(" (count %d", cnt);
                if (n < 0) {
-                       logprintf(",unknown %d bytes", len);
+                       logprintf(",unknown %zu bytes", len);
                }
                logprintf(")");
 
@@ -1167,7 +1167,7 @@ assertion_text_file_contents(const char *filename, int line, const char *buff, c
        logprintf("  file=\"%s\"\n", fn);
        if (n > 0) {
                hexdump(contents, buff, n, 0);
-               logprintf("  expected\n", fn);
+               logprintf("  expected\n");
                hexdump(buff, contents, s, 0);
        } else {
                logprintf("  File empty, contents should be:\n");
@@ -1497,7 +1497,7 @@ assertion_file_time(const char *file, int line,
                }
        } else if (filet != t || filet_nsec != nsec) {
                failure_start(file, line,
-                   "File %s has %ctime %lld.%09lld, expected %lld.%09lld",
+                   "File %s has %ctime %lld.%09lld, expected %ld.%09ld",
                    pathname, type, filet, filet_nsec, t, nsec);
                failure_finish(NULL);
                return (0);
@@ -1593,8 +1593,8 @@ assertion_file_nlinks(const char *file, int line,
        r = my_GetFileInformationByName(pathname, &bhfi);
        if (r != 0 && bhfi.nNumberOfLinks == (DWORD)nlinks)
                return (1);
-       failure_start(file, line, "File %s has %d links, expected %d",
-           pathname, bhfi.nNumberOfLinks, nlinks);
+       failure_start(file, line, "File %s has %jd links, expected %d",
+           pathname, (intmax_t)bhfi.nNumberOfLinks, nlinks);
        failure_finish(NULL);
        return (0);
 #else
@@ -1605,8 +1605,8 @@ assertion_file_nlinks(const char *file, int line,
        r = lstat(pathname, &st);
        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);
+       failure_start(file, line, "File %s has %jd links, expected %d",
+           pathname, (intmax_t)st.st_nlink, nlinks);
        failure_finish(NULL);
        return (0);
 #endif
@@ -3271,7 +3271,7 @@ assertion_entry_set_acls(const char *file, int line, struct archive_entry *ae,
                    acls[i].qual, acls[i].name);
                if (r != 0) {
                        ret = 1;
-                       failure_start(file, line, "type=%#010x, ",
+                       failure_start(file, line, "type=%#010x, "
                            "permset=%#010x, tag=%d, qual=%d name=%s",
                            acls[i].type, acls[i].permset, acls[i].tag,
                            acls[i].qual, acls[i].name);