[Openvpn-devel,v2] tls_crypt_v2_write_client_key_file: Fix missing-field-initializers compiler warning

Message ID 20250125100838.20796-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v2] tls_crypt_v2_write_client_key_file: Fix missing-field-initializers compiler warning | expand

Commit Message

Gert Doering Jan. 25, 2025, 10:08 a.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

GCC wants us to be more explicit here.

Change-Id: Iaaf80c688ddff79ac9472d7237003713637c140b
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/867
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering Jan. 25, 2025, 10:17 a.m. UTC | #1
Not sure why the compiler is more picky here than on other inits, but
maybe it's "... = {2}" vs "... = {0}" (which means "all is 0", so the
actual element first in the struct does not matter).  Anyway, ".n = 2"
is what we want so there is no harm in writing that done :-) - and
the buildbots agree that all platform compilers are fine with it.

Your patch has been applied to the master branch.

commit 2a50daf5fe6c924c8d945b3d0455c9e282cd769f
Author: Frank Lichtenheld
Date:   Sat Jan 25 11:08:38 2025 +0100

     tls_crypt_v2_write_client_key_file: Fix missing-field-initializers compiler warning

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20250125100838.20796-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30588.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/tls_crypt.c b/src/openvpn/tls_crypt.c
index 24df930..4c421aa 100644
--- a/src/openvpn/tls_crypt.c
+++ b/src/openvpn/tls_crypt.c
@@ -691,7 +691,7 @@ 
     struct buffer client_key_pem = { 0 };
     struct buffer dst = alloc_buf_gc(TLS_CRYPT_V2_CLIENT_KEY_LEN
                                      + TLS_CRYPT_V2_MAX_WKC_LEN, &gc);
-    struct key2 client_key = { 2 };
+    struct key2 client_key = { .n = 2 };
 
     if (!rand_bytes((void *)client_key.keys, sizeof(client_key.keys)))
     {