From 27b490a83d2667727f2b1afde72d94818c88cc40 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Sat, 28 Dec 2024 16:29:47 -0800 Subject: [PATCH] Add straightforward casts for %o and %x (#2458) (cherry picked from commit 14221c7ba20d50598b56f455a6d613ed186e3510) --- libarchive/test/test_acl_pax.c | 8 ++++---- libarchive/test/test_acl_platform_nfs4.c | 8 +++++--- libarchive/test/test_acl_platform_posix1e.c | 3 ++- libarchive/test/test_acl_posix1e.c | 8 ++++---- libarchive/test/test_compat_solaris_tar_acl.c | 4 ++-- libarchive/test/test_compat_star_acl.c | 6 +++--- test_utils/test_main.c | 9 ++++++--- 7 files changed, 26 insertions(+), 20 deletions(-) diff --git a/libarchive/test/test_acl_pax.c b/libarchive/test/test_acl_pax.c index 659073170..3e0c3d7c0 100644 --- a/libarchive/test/test_acl_pax.c +++ b/libarchive/test/test_acl_pax.c @@ -287,7 +287,7 @@ DEFINE_TEST(test_acl_pax_posix1e) failure("Basic ACLs shouldn't be stored as extended ACLs"); assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* Second item has a few ACLs */ @@ -297,7 +297,7 @@ DEFINE_TEST(test_acl_pax_posix1e) assertEntryCompareAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142); failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* Third item has pretty extensive ACLs */ @@ -307,7 +307,7 @@ DEFINE_TEST(test_acl_pax_posix1e) assertEntryCompareAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543); failure("Basic ACLs should set mode to 0543, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0543); /* Fourth item has no ACLs */ @@ -315,7 +315,7 @@ DEFINE_TEST(test_acl_pax_posix1e) failure("Basic ACLs shouldn't be stored as extended ACLs"); assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* Close the archive. */ diff --git a/libarchive/test/test_acl_platform_nfs4.c b/libarchive/test/test_acl_platform_nfs4.c index 18f047b14..6e19bca4f 100644 --- a/libarchive/test/test_acl_platform_nfs4.c +++ b/libarchive/test/test_acl_platform_nfs4.c @@ -772,7 +772,8 @@ compare_acls( failure(" ACL entry %d missing from %s: " "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n", marker[i], filename, - myacls[marker[i]].type, myacls[marker[i]].permset, + (unsigned int)myacls[marker[i]].type, + (unsigned int)myacls[marker[i]].permset, myacls[marker[i]].tag, myacls[marker[i]].qual, myacls[marker[i]].name); assert(0); /* Record this as a failure. */ @@ -824,7 +825,7 @@ compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char failure("ACL entry on file that shouldn't be there: " "type=%#010x,permset=%#010x,tag=%d,qual=%d", - type,permset,tag,qual); + (unsigned int)type, (unsigned int)permset, tag, qual); assert(matched == 1); } @@ -833,7 +834,8 @@ compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char failure(" ACL entry %d missing from %s: " "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n", marker[i], filename, - myacls[marker[i]].type, myacls[marker[i]].permset, + (unsigned int)myacls[marker[i]].type, + (unsigned int)myacls[marker[i]].permset, myacls[marker[i]].tag, myacls[marker[i]].qual, myacls[marker[i]].name); assert(0); /* Record this as a failure. */ diff --git a/libarchive/test/test_acl_platform_posix1e.c b/libarchive/test/test_acl_platform_posix1e.c index f23eec0d3..ef1b08541 100644 --- a/libarchive/test/test_acl_platform_posix1e.c +++ b/libarchive/test/test_acl_platform_posix1e.c @@ -274,7 +274,8 @@ compare_acls( for (i = 0; i < n; ++i) { failure(" ACL entry missing from file: " "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n", - myacls[marker[i]].type, myacls[marker[i]].permset, + (unsigned int)myacls[marker[i]].type, + (unsigned int)myacls[marker[i]].permset, myacls[marker[i]].tag, myacls[marker[i]].qual, myacls[marker[i]].name); assert(0); /* Record this as a failure. */ diff --git a/libarchive/test/test_acl_posix1e.c b/libarchive/test/test_acl_posix1e.c index 3f9c9850f..025ef6afd 100644 --- a/libarchive/test/test_acl_posix1e.c +++ b/libarchive/test/test_acl_posix1e.c @@ -119,7 +119,7 @@ DEFINE_TEST(test_acl_posix1e) failure("Basic ACLs shouldn't be stored as extended ACLs"); assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* With any extended ACL entry, we should read back a full set. */ @@ -136,7 +136,7 @@ DEFINE_TEST(test_acl_posix1e) assertEntryCompareAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142); failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); @@ -146,7 +146,7 @@ DEFINE_TEST(test_acl_posix1e) assertEntryCompareAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543); failure("Basic ACLs should set mode to 0543, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0543); /* @@ -157,7 +157,7 @@ DEFINE_TEST(test_acl_posix1e) failure("Basic ACLs shouldn't be stored as extended ACLs"); assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* diff --git a/libarchive/test/test_compat_solaris_tar_acl.c b/libarchive/test/test_compat_solaris_tar_acl.c index df7435c7c..afdeddf07 100644 --- a/libarchive/test/test_compat_solaris_tar_acl.c +++ b/libarchive/test/test_compat_solaris_tar_acl.c @@ -229,7 +229,7 @@ DEFINE_TEST(test_compat_solaris_tar_acl) assertEntryCompareAcls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0644); failure("Basic ACLs should set mode to 0644, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0644); /* Second item has default and access ACLs */ @@ -239,7 +239,7 @@ DEFINE_TEST(test_compat_solaris_tar_acl) assertEntryCompareAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0750); failure("Basic ACLs should set mode to 0750, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0750); assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); diff --git a/libarchive/test/test_compat_star_acl.c b/libarchive/test/test_compat_star_acl.c index 749f5ce34..8e205c22c 100644 --- a/libarchive/test/test_compat_star_acl.c +++ b/libarchive/test/test_compat_star_acl.c @@ -251,7 +251,7 @@ DEFINE_TEST(test_compat_star_acl_posix1e) assertEntryCompareAcls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142); failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* Second item has pretty extensive ACLs */ @@ -261,7 +261,7 @@ DEFINE_TEST(test_compat_star_acl_posix1e) assertEntryCompareAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543); failure("Basic ACLs should set mode to 0543, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0543); /* Third item has default ACLs */ @@ -271,7 +271,7 @@ DEFINE_TEST(test_compat_star_acl_posix1e) assertEntryCompareAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0142); failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); + (unsigned int)archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* Close the archive. */ diff --git a/test_utils/test_main.c b/test_utils/test_main.c index 60b1dc8c6..de6a6107a 100644 --- a/test_utils/test_main.c +++ b/test_utils/test_main.c @@ -3319,7 +3319,8 @@ assertion_entry_set_acls(const char *file, int line, struct archive_entry *ae, ret = 1; failure_start(file, line, "type=%#010x, " "permset=%#010x, tag=%d, qual=%d name=%s", - acls[i].type, acls[i].permset, acls[i].tag, + (unsigned int)acls[i].type, + (unsigned int)acls[i].permset, acls[i].tag, acls[i].qual, acls[i].name); failure_finish(NULL); } @@ -3451,7 +3452,8 @@ assertion_entry_compare_acls(const char *file, int line, } else if (matched != 1) { failure_start(file, line, "Could not find match for " "ACL (type=%#010x,permset=%#010x,tag=%d,qual=%d," - "name=``%s'')", type, permset, tag, qual, name); + "name=``%s'')", (unsigned int)type, + (unsigned int)permset, tag, qual, name); failure_finish(NULL); ret = 1; } @@ -3471,7 +3473,8 @@ assertion_entry_compare_acls(const char *file, int line, if (n != 0) { failure_start(file, line, "Could not find match for ACL " "(type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s'')", - acls[marker[0]].type, acls[marker[0]].permset, + (unsigned int)acls[marker[0]].type, + (unsigned int)acls[marker[0]].permset, acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); failure_finish(NULL); -- 2.47.3