]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix compiler nitpicks (#2465)
authorGraham Percival <gperciva@tarsnap.com>
Mon, 30 Dec 2024 16:30:42 +0000 (08:30 -0800)
committerMartin Matuska <martin@matuska.de>
Tue, 11 Mar 2025 09:30:27 +0000 (10:30 +0100)
(cherry picked from commit edcae6c164717df48c59e6c2dc3e2510fa34ad87)

cpio/test/test_option_c.c
libarchive/archive_read_support_format_rar5.c
libarchive/test/test_write_format_tar_sparse.c
tar/test/test_stdio.c
test_utils/test_main.c

index e8748449514bd5a42e9df14cda198d38802add52..211f2142dbf5ee79a78c2f020f61696281f1d573 100644 (file)
@@ -117,7 +117,7 @@ DEFINE_TEST(test_option_c)
        gid = (int)from_octal(e + 30, 6);
        assertEqualMem(e + 36, "000001", 6); /* nlink */
        failure("file entries should not have rdev set (dev field was 0%o)",
-           dev);
+           (unsigned int)dev);
        assertEqualMem(e + 42, "000000", 6); /* rdev */
        t = from_octal(e + 48, 11); /* mtime */
        assert(t <= now); /* File wasn't created in future. */
index aceb8501e63738cdbc9542d8954bfff1c79f2013..1dd0d88d67f86a2b101347912744e1353c51bdfc 100644 (file)
@@ -1294,7 +1294,7 @@ static int parse_file_extra_hash(struct archive_read* a, struct rar5* rar,
                *extra_data_size -= hash_size;
        } else {
                archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-                   "Unsupported hash type (0x%x)", (int) hash_type);
+                   "Unsupported hash type (0x%jx)", (uintmax_t)hash_type);
                return ARCHIVE_FATAL;
        }
 
@@ -1897,7 +1897,8 @@ static int process_head_file(struct archive_read* a, struct rar5* rar,
        } else {
                /* Unknown host OS */
                archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-                               "Unsupported Host OS: 0x%x", (int) host_os);
+                               "Unsupported Host OS: 0x%jx",
+                               (uintmax_t)host_os);
 
                return ARCHIVE_FATAL;
        }
@@ -2105,8 +2106,8 @@ static int process_head_main(struct archive_read* a, struct rar5* rar,
                default:
                        archive_set_error(&a->archive,
                            ARCHIVE_ERRNO_FILE_FORMAT,
-                           "Unsupported extra type (0x%x)",
-                           (int) extra_field_id);
+                           "Unsupported extra type (0x%jx)",
+                           (uintmax_t)extra_field_id);
                        return ARCHIVE_FATAL;
        }
 
index 1568b0eadc298852084b3511b9866dbbf898d337..2e69f2239934f91e8bd2605bba9e2cd67bb1c31a 100644 (file)
@@ -38,7 +38,7 @@ test_1(void)
        char *buff2;
        size_t buff2_size = 0x13000;
        char buff3[1024];
-       long i;
+       unsigned long i;
 
        assert((buff2 = malloc(buff2_size)) != NULL);
        /* Repeat the following for a variety of odd blocksizes. */
@@ -181,7 +181,7 @@ test_2(void)
        char *buff2;
        size_t buff2_size = 0x11000;
        char buff3[1024];
-       long i;
+       unsigned long i;
 
        assert((buff2 = malloc(buff2_size)) != NULL);
        /* Create a new archive in memory. */
index 95f6f8db9e9761d9e45d86071a90fbf70627e856..239f3815fb715d85ac27411dd8b091b2c5d6cd9e 100644 (file)
@@ -26,7 +26,7 @@ static const char *xvf_err =
  * This string should appear in the verbose listing regardless of platform,
  * locale, username, or groupname.
  */
-const char * tvf_contains = "l link to f";
+static const char * tvf_contains = "l link to f";
 
 DEFINE_TEST(test_stdio)
 {
index b2eae6381f8acbbba4ca1054c932b9c54eeb6a0b..1a0c2e0eb18598808f0018925145efc47211ec7c 100644 (file)
@@ -629,8 +629,10 @@ assertion_equal_int(const char *file, int line,
        if (v1 == v2)
                return (1);
        failure_start(file, line, "%s != %s", e1, e2);
-       logprintf("      %s=%lld (0x%llx, 0%llo)\n", e1, v1, v1, v1);
-       logprintf("      %s=%lld (0x%llx, 0%llo)\n", e2, v2, v2, v2);
+       logprintf("      %s=%lld (0x%llx, 0%llo)\n", e1, v1,
+           (unsigned long long)v1, (unsigned long long)v1);
+       logprintf("      %s=%lld (0x%llx, 0%llo)\n", e2, v2,
+           (unsigned long long)v2, (unsigned long long)v2);
        failure_finish(extra);
        return (0);
 }
@@ -899,7 +901,7 @@ hexdump(const char *p, const char *ref, size_t l, size_t offset)
                for (j = 0; j < 16 && i + j < l; j++) {
                        if (ref != NULL && p[i + j] != ref[i + j])
                                sep = '_';
-                       logprintf("%c%02x", sep, 0xff & (int)p[i+j]);
+                       logprintf("%c%02x", sep, 0xff & (unsigned int)p[i+j]);
                        if (ref != NULL && p[i + j] == ref[i + j])
                                sep = ' ';
                }