]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
libarchive/test: fix build when memcpy() is a macro 2660/head
authorKyle Evans <kevans@FreeBSD.org>
Tue, 3 Jun 2025 02:43:28 +0000 (21:43 -0500)
committerKyle Evans <kevans@FreeBSD.org>
Tue, 3 Jun 2025 02:46:28 +0000 (21:46 -0500)
After importing the latest libarchive into FreeBSD, Shawn Webb @
HardenedBSD noted that the test build is broken when FORTIFY_SOURCE=2
while building the base system.  Braced initializer lists are a special
case that need some extra fun parentheses when we're dealing with the
preprocessor.

While it's not a particularly common setup, the extra parentheses don't
really hurt readability all that much so it's worth fixing for wider
compatibility.

Fixes: libarchive/libarchive#2657
libarchive/test/test_write_format_mtree_preset_digests.c

index cdf789b4b0025bbfc9f133a61ef9c4239b383f11..bb8ddf49431b5106062464caccb2fca583ddf9c2 100644 (file)
@@ -326,10 +326,10 @@ DEFINE_TEST(test_write_format_mtree_digests_md5_digest_set_no_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.md5, (unsigned char[]) {
+       memcpy(ed.md5, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
-       }, sizeof(ed.md5));
+       }), sizeof(ed.md5));
 
 #ifdef ARCHIVE_HAS_RMD160
        assertEqualInt(ARCHIVE_OK, archive_rmd160_init(&expectedRmd160Ctx));
@@ -419,10 +419,10 @@ DEFINE_TEST(test_write_format_mtree_digests_md5_digest_set_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.md5, (unsigned char[]) {
+       memcpy(ed.md5, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
-       }, sizeof(ed.md5));
+       }), sizeof(ed.md5));
 
 #ifdef ARCHIVE_HAS_RMD160
        assertEqualInt(ARCHIVE_OK, archive_rmd160_init(&expectedRmd160Ctx));
@@ -519,10 +519,10 @@ DEFINE_TEST(test_write_format_mtree_digests_md5_digest_set_non_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.md5, (unsigned char[]) {
+       memcpy(ed.md5, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
-       }, sizeof(ed.md5));
+       }), sizeof(ed.md5));
 
 #ifdef ARCHIVE_HAS_RMD160
        assertEqualInt(ARCHIVE_OK, archive_rmd160_init(&expectedRmd160Ctx));
@@ -710,10 +710,10 @@ DEFINE_TEST(test_write_format_mtree_digests_rmd160_digest_set_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.rmd160, (unsigned char[]) {
+       memcpy(ed.rmd160, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.rmd160));
+       }), sizeof(ed.rmd160));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -810,10 +810,10 @@ DEFINE_TEST(test_write_format_mtree_digests_rmd160_digest_set_non_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.rmd160, (unsigned char[]) {
+       memcpy(ed.rmd160, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.rmd160));
+       }), sizeof(ed.rmd160));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -910,10 +910,10 @@ DEFINE_TEST(test_write_format_mtree_digests_sha1_digest_set_no_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha1, (unsigned char[]) {
+       memcpy(ed.sha1, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha1));
+       }), sizeof(ed.sha1));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1003,10 +1003,10 @@ DEFINE_TEST(test_write_format_mtree_digests_sha1_digest_set_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha1, (unsigned char[]) {
+       memcpy(ed.sha1, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha1));
+       }), sizeof(ed.sha1));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1103,10 +1103,10 @@ DEFINE_TEST(test_write_format_mtree_digests_sha1_digest_set_non_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha1, (unsigned char[]) {
+       memcpy(ed.sha1, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha1));
+       }), sizeof(ed.sha1));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1203,12 +1203,12 @@ DEFINE_TEST(test_write_format_mtree_digests_sha256_digest_set_no_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha256, (unsigned char[]) {
+       memcpy(ed.sha256, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed
-       }, sizeof(ed.sha256));
+       }), sizeof(ed.sha256));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1298,12 +1298,12 @@ DEFINE_TEST(test_write_format_mtree_digests_sha256_digest_set_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha256, (unsigned char[]) {
+       memcpy(ed.sha256, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed
-       }, sizeof(ed.sha256));
+       }), sizeof(ed.sha256));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1400,12 +1400,12 @@ DEFINE_TEST(test_write_format_mtree_digests_sha256_digest_set_non_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha256, (unsigned char[]) {
+       memcpy(ed.sha256, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed
-       }, sizeof(ed.sha256));
+       }), sizeof(ed.sha256));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1502,13 +1502,13 @@ DEFINE_TEST(test_write_format_mtree_digests_sha384_digest_set_no_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha384, (unsigned char[]) {
+       memcpy(ed.sha384, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha384));
+       }), sizeof(ed.sha384));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1598,13 +1598,13 @@ DEFINE_TEST(test_write_format_mtree_digests_sha384_digest_set_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha384, (unsigned char[]) {
+       memcpy(ed.sha384, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha384));
+       }), sizeof(ed.sha384));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1701,13 +1701,13 @@ DEFINE_TEST(test_write_format_mtree_digests_sha384_digest_set_non_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha384, (unsigned char[]) {
+       memcpy(ed.sha384, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha384));
+       }), sizeof(ed.sha384));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1804,7 +1804,7 @@ DEFINE_TEST(test_write_format_mtree_digests_sha512_digest_set_no_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha512, (unsigned char[]) {
+       memcpy(ed.sha512, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
@@ -1812,7 +1812,7 @@ DEFINE_TEST(test_write_format_mtree_digests_sha512_digest_set_no_data)
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha512));
+       }), sizeof(ed.sha512));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -1903,7 +1903,7 @@ DEFINE_TEST(test_write_format_mtree_digests_sha512_digest_set_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha512, (unsigned char[]) {
+       memcpy(ed.sha512, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
@@ -1911,7 +1911,7 @@ DEFINE_TEST(test_write_format_mtree_digests_sha512_digest_set_empty_data)
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha512));
+       }), sizeof(ed.sha512));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));
@@ -2009,7 +2009,7 @@ DEFINE_TEST(test_write_format_mtree_digests_sha512_digest_set_non_empty_data)
        struct archive_entry *entry;
        struct expected_digests ed;
 
-       memcpy(ed.sha512, (unsigned char[]) {
+       memcpy(ed.sha512, ((unsigned char[]) {
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
@@ -2017,7 +2017,7 @@ DEFINE_TEST(test_write_format_mtree_digests_sha512_digest_set_non_empty_data)
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed, 0xfe, 0xed,
                0xfe, 0xed, 0xfe, 0xed
-       }, sizeof(ed.sha512));
+       }), sizeof(ed.sha512));
 
 #ifdef ARCHIVE_HAS_MD5
        assertEqualInt(ARCHIVE_OK, archive_md5_init(&expectedMd5Ctx));