Message ID | 20230307235737.3595130-1-arne@rfc2549.org |
---|---|
State | Superseded |
Headers | show |
Series | [Openvpn-devel] Avoid warning about missing braces when initialising key struct | expand |
Hi, On 08/03/2023 00:57, Arne Schwabe wrote: > This avoids the warning from gcc about initialising the key2 struct > > Change-Id: Ia73d24923b1efd99263f33ce13d90e04b59bd980 > Signed-off-by: Arne Schwabe <arne@rfc2549.org> > --- > src/openvpn/tls_crypt.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/openvpn/tls_crypt.c b/src/openvpn/tls_crypt.c > index 81098355e..e84d979e9 100644 > --- a/src/openvpn/tls_crypt.c > +++ b/src/openvpn/tls_crypt.c > @@ -348,7 +348,8 @@ tls_crypt_v2_init_client_key(struct key_ctx_bi *key, struct key2 *original_key, > msg(M_FATAL, "ERROR: invalid tls-crypt-v2 client key format"); > } > > - struct key2 key2 = { .n = 2, .keys = { 0 } }; > + struct key2 key2 = { .n = 2, .keys = {{{ 0 }}} }; why not just struct key2 key2 = { .n = 2 } ? Cheers, > + > if (!buf_read(&client_key, &key2.keys, sizeof(key2.keys))) > { > msg(M_FATAL, "ERROR: not enough data in tls-crypt-v2 client key");
Am 08.03.23 um 11:03 schrieb Antonio Quartulli: > Hi, > > On 08/03/2023 00:57, Arne Schwabe wrote: >> This avoids the warning from gcc about initialising the key2 struct >> >> Change-Id: Ia73d24923b1efd99263f33ce13d90e04b59bd980 >> Signed-off-by: Arne Schwabe <arne@rfc2549.org> >> --- >> src/openvpn/tls_crypt.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/src/openvpn/tls_crypt.c b/src/openvpn/tls_crypt.c >> index 81098355e..e84d979e9 100644 >> --- a/src/openvpn/tls_crypt.c >> +++ b/src/openvpn/tls_crypt.c >> @@ -348,7 +348,8 @@ tls_crypt_v2_init_client_key(struct key_ctx_bi >> *key, struct key2 *original_key, >> msg(M_FATAL, "ERROR: invalid tls-crypt-v2 client key format"); >> } >> - struct key2 key2 = { .n = 2, .keys = { 0 } }; >> + struct key2 key2 = { .n = 2, .keys = {{{ 0 }}} }; > > why not just struct key2 key2 = { .n = 2 } ? That will initialise the whole struct to 2 including the key material, which I would like to avoid. Arne
diff --git a/src/openvpn/tls_crypt.c b/src/openvpn/tls_crypt.c index 81098355e..e84d979e9 100644 --- a/src/openvpn/tls_crypt.c +++ b/src/openvpn/tls_crypt.c @@ -348,7 +348,8 @@ tls_crypt_v2_init_client_key(struct key_ctx_bi *key, struct key2 *original_key, msg(M_FATAL, "ERROR: invalid tls-crypt-v2 client key format"); } - struct key2 key2 = { .n = 2, .keys = { 0 } }; + struct key2 key2 = { .n = 2, .keys = {{{ 0 }}} }; + if (!buf_read(&client_key, &key2.keys, sizeof(key2.keys))) { msg(M_FATAL, "ERROR: not enough data in tls-crypt-v2 client key");
This avoids the warning from gcc about initialising the key2 struct Change-Id: Ia73d24923b1efd99263f33ce13d90e04b59bd980 Signed-off-by: Arne Schwabe <arne@rfc2549.org> --- src/openvpn/tls_crypt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)