From a17bded84a6d3e4ffd2a6c0e587b0b78b9ba3299 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Tue, 24 Dec 2024 15:27:26 -0800 Subject: [PATCH] Fix %d -> %u for unsigned int from i4le() (#2448) `i4le()` returns an unsigned int, so `'%d'` is incorrect. Reported by `clang -Wformat`. (Many more such fixes to come, but this is the simplest set of them.) --- libarchive/test/test_write_format_zip64_stream.c | 2 +- libarchive/test/test_write_format_zip_compression_bzip2.c | 4 ++-- libarchive/test/test_write_format_zip_compression_lzmaxz.c | 4 ++-- libarchive/test/test_write_format_zip_compression_store.c | 4 ++-- libarchive/test/test_write_format_zip_compression_zstd.c | 4 ++-- libarchive/test/test_write_format_zip_file.c | 2 +- libarchive/test/test_write_format_zip_file_zip64.c | 2 +- libarchive/test/test_write_format_zip_stream.c | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libarchive/test/test_write_format_zip64_stream.c b/libarchive/test/test_write_format_zip64_stream.c index 208406b30..5f650bccb 100644 --- a/libarchive/test/test_write_format_zip64_stream.c +++ b/libarchive/test/test_write_format_zip64_stream.c @@ -124,7 +124,7 @@ DEFINE_TEST(test_write_format_zip64_stream) /* Get address of first entry in central directory. */ central_header = p = buff + i4le(buffend - 6); - failure("Central file record at offset %d should begin with" + failure("Central file record at offset %u should begin with" " PK\\001\\002 signature", i4le(buffend - 10)); diff --git a/libarchive/test/test_write_format_zip_compression_bzip2.c b/libarchive/test/test_write_format_zip_compression_bzip2.c index cf1621dad..969c4ddd9 100644 --- a/libarchive/test/test_write_format_zip_compression_bzip2.c +++ b/libarchive/test/test_write_format_zip_compression_bzip2.c @@ -130,7 +130,7 @@ static void verify_bzip2_contents(const char *buff, size_t used) assertEqualInt(i2le(p + 6), 0); failure("All central dir entries are on this disk"); assertEqualInt(i2le(p + 8), i2le(p + 10)); - failure("CD start (%d) + CD length (%d) should == archive size - 22", + failure("CD start (%u) + CD length (%u) should == archive size - 22", i4le(p + 12), i4le(p + 16)); assertEqualInt(i4le(p + 12) + i4le(p + 16), used - 22); failure("no zip comment"); @@ -138,7 +138,7 @@ static void verify_bzip2_contents(const char *buff, size_t used) /* Get address of first entry in central directory. */ p = buff + i4le(buffend - 6); - failure("Central file record at offset %d should begin with" + failure("Central file record at offset %u should begin with" " PK\\001\\002 signature", i4le(buffend - 10)); diff --git a/libarchive/test/test_write_format_zip_compression_lzmaxz.c b/libarchive/test/test_write_format_zip_compression_lzmaxz.c index ad24e1409..4b5be2913 100644 --- a/libarchive/test/test_write_format_zip_compression_lzmaxz.c +++ b/libarchive/test/test_write_format_zip_compression_lzmaxz.c @@ -105,7 +105,7 @@ static void verify_xz_lzma(const char *buff, size_t used, uint16_t id, assertEqualInt(i2le(p + 6), 0); failure("All central dir entries are on this disk"); assertEqualInt(i2le(p + 8), i2le(p + 10)); - failure("CD start (%d) + CD length (%d) should == archive size - 22", + failure("CD start (%u) + CD length (%u) should == archive size - 22", i4le(p + 12), i4le(p + 16)); assertEqualInt(i4le(p + 12) + i4le(p + 16), used - 22); failure("no zip comment"); @@ -113,7 +113,7 @@ static void verify_xz_lzma(const char *buff, size_t used, uint16_t id, /* Get address of first entry in central directory. */ p = buff + i4le(buffend - 6); - failure("Central file record at offset %d should begin with" + failure("Central file record at offset %u should begin with" " PK\\001\\002 signature", i4le(buffend - 10)); diff --git a/libarchive/test/test_write_format_zip_compression_store.c b/libarchive/test/test_write_format_zip_compression_store.c index afd517eb2..495509c05 100644 --- a/libarchive/test/test_write_format_zip_compression_store.c +++ b/libarchive/test/test_write_format_zip_compression_store.c @@ -142,7 +142,7 @@ static void verify_uncompressed_contents(const char *buff, size_t used) assertEqualInt(i2le(p + 6), 0); failure("All central dir entries are on this disk"); assertEqualInt(i2le(p + 8), i2le(p + 10)); - failure("CD start (%d) + CD length (%d) should == archive size - 22", + failure("CD start (%u) + CD length (%u) should == archive size - 22", i4le(p + 12), i4le(p + 16)); assertEqualInt(i4le(p + 12) + i4le(p + 16), used - 22); failure("no zip comment"); @@ -150,7 +150,7 @@ static void verify_uncompressed_contents(const char *buff, size_t used) /* Get address of first entry in central directory. */ p = buff + i4le(buffend - 6); - failure("Central file record at offset %d should begin with" + failure("Central file record at offset %u should begin with" " PK\\001\\002 signature", i4le(buffend - 10)); diff --git a/libarchive/test/test_write_format_zip_compression_zstd.c b/libarchive/test/test_write_format_zip_compression_zstd.c index cc71e5cb8..aeef35535 100644 --- a/libarchive/test/test_write_format_zip_compression_zstd.c +++ b/libarchive/test/test_write_format_zip_compression_zstd.c @@ -130,7 +130,7 @@ static void verify_zstd_contents(const char *buff, size_t used) assertEqualInt(i2le(p + 6), 0); failure("All central dir entries are on this disk"); assertEqualInt(i2le(p + 8), i2le(p + 10)); - failure("CD start (%d) + CD length (%d) should == archive size - 22", + failure("CD start (%u) + CD length (%u) should == archive size - 22", i4le(p + 12), i4le(p + 16)); assertEqualInt(i4le(p + 12) + i4le(p + 16), used - 22); failure("no zip comment"); @@ -138,7 +138,7 @@ static void verify_zstd_contents(const char *buff, size_t used) /* Get address of first entry in central directory. */ p = buff + i4le(buffend - 6); - failure("Central file record at offset %d should begin with" + failure("Central file record at offset %u should begin with" " PK\\001\\002 signature", i4le(buffend - 10)); diff --git a/libarchive/test/test_write_format_zip_file.c b/libarchive/test/test_write_format_zip_file.c index 7796b06a2..24b238436 100644 --- a/libarchive/test/test_write_format_zip_file.c +++ b/libarchive/test/test_write_format_zip_file.c @@ -138,7 +138,7 @@ DEFINE_TEST(test_write_format_zip_file) /* Get address of first entry in central directory. */ central_header = p = buff + i4le(buffend - 6); - failure("Central file record at offset %d should begin with" + failure("Central file record at offset %u should begin with" " PK\\001\\002 signature", i4le(buffend - 10)); diff --git a/libarchive/test/test_write_format_zip_file_zip64.c b/libarchive/test/test_write_format_zip_file_zip64.c index da0428a82..9d1bdffbe 100644 --- a/libarchive/test/test_write_format_zip_file_zip64.c +++ b/libarchive/test/test_write_format_zip_file_zip64.c @@ -139,7 +139,7 @@ DEFINE_TEST(test_write_format_zip_file_zip64) /* Get address of first entry in central directory. */ central_header = p = buff + i4le(buffend - 6); - failure("Central file record at offset %d should begin with" + failure("Central file record at offset %u should begin with" " PK\\001\\002 signature", i4le(buffend - 10)); diff --git a/libarchive/test/test_write_format_zip_stream.c b/libarchive/test/test_write_format_zip_stream.c index ff4344e14..c9d2db0b0 100644 --- a/libarchive/test/test_write_format_zip_stream.c +++ b/libarchive/test/test_write_format_zip_stream.c @@ -127,7 +127,7 @@ DEFINE_TEST(test_write_format_zip_stream) /* Get address of first entry in central directory. */ central_header = p = buff + i4le(buffend - 6); - failure("Central file record at offset %d should begin with" + failure("Central file record at offset %u should begin with" " PK\\001\\002 signature", i4le(buffend - 10)); -- 2.47.2