]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
bio_dgram_test.c: Fix warning from older clang compilers
authorTomas Mraz <tomas@openssl.org>
Wed, 7 Sep 2022 06:41:05 +0000 (08:41 +0200)
committerPauli <pauli@openssl.org>
Thu, 8 Sep 2022 22:56:41 +0000 (08:56 +1000)
Older clang compilers warn about the initializer:

test/bio_dgram_test.c:107:29: error: suggest braces around initialization
 of subobject [-Werror,-Wmissing-braces]
    struct in6_addr ina6 = {0};
                            ^
                            {}

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19152)

test/bio_dgram_test.c

index 4fcc49eb673da4e4c5165d8738e2518ac4cf2d33..15731cb6479de8245cd42ead53cd12f2dfddcf31 100644 (file)
@@ -102,9 +102,9 @@ static int test_bio_dgram_impl(int af, int use_local)
     int fd1 = -1, fd2 = -1;
     BIO_ADDR *addr1 = NULL, *addr2 = NULL, *addr3 = NULL, *addr4 = NULL,
              *addr5 = NULL, *addr6 = NULL;
-    struct in_addr ina = {0};
+    struct in_addr ina;
 #if defined(OPENSSL_USE_IPV6)
-    struct in6_addr ina6 = {0};
+    struct in6_addr ina6;
 #endif
     void *pina;
     size_t inal, i;
@@ -114,9 +114,6 @@ static int test_bio_dgram_impl(int af, int use_local)
     char tx_buf[128];
     size_t num_processed = 0;
 
-    ina.s_addr = htonl(0x7f000001UL);
-    ina6.s6_addr[15] = 1;
-
     if (af == AF_INET) {
         TEST_info("# Testing with AF_INET, local=%d\n", use_local);
         pina = &ina;
@@ -133,6 +130,10 @@ static int test_bio_dgram_impl(int af, int use_local)
         goto err;
     }
 
+    memset(pina, 0, inal);
+    ina.s_addr = htonl(0x7f000001UL);
+    ina6.s6_addr[15] = 1;
+
     addr1 = BIO_ADDR_new();
     if (!TEST_ptr(addr1))
         goto err;