[Openvpn-devel,1/2] push.c: fix Visual Studio build

Message ID 1570537606-29323-1-git-send-email-lstipakov@gmail.com
State Superseded
Headers show
Series
  • [Openvpn-devel,1/2] push.c: fix Visual Studio build
Related show

Commit Message

Lev Stipakov Oct. 8, 2019, 12:26 p.m.
From: Lev Stipakov <lev@openvpn.net>

Visual Studio doesn't support designated initializers
for C code, so replace it with CLEAR() macro.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
---
 src/openvpn/push.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Arne Schwabe Oct. 8, 2019, 12:36 p.m. | #1
Am 08.10.19 um 14:26 schrieb Lev Stipakov:
> From: Lev Stipakov <lev@openvpn.net>
> 
> Visual Studio doesn't support designated initializers
> for C code, so replace it with CLEAR() macro.
> 
> Signed-off-by: Lev Stipakov <lev@openvpn.net>
> ---
>  src/openvpn/push.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/openvpn/push.c b/src/openvpn/push.c
> index 49b9d1b..213e2b6 100644
> --- a/src/openvpn/push.c
> +++ b/src/openvpn/push.c
> @@ -504,9 +504,10 @@ void
>  send_push_reply_auth_token(struct tls_multi *multi)
>  {
>      struct gc_arena gc = gc_new();
> +    struct push_list push_list;
>  
> +    CLEAR(push_list);
>  
> -    struct push_list push_list = {};
>      prepare_auth_token_push_reply(multi, &gc, &push_list);
>  
>      /* prepare auth token should always add the auth-token option */
> 

Acked-By: Arne Schwabe

I thought we had those in other places. But I guess I was wrong.

Arne
Gert Doering Oct. 8, 2019, 12:42 p.m. | #2
Hi,

On Tue, Oct 08, 2019 at 02:36:28PM +0200, Arne Schwabe wrote:
> I thought we had those in other places. But I guess I was wrong.

We do, but never with {}.

Our "new style with C99" seems to be "go away from CLEAR() for
local structs", so this is a step back.

Assigning {0} should be fine with MSVC - we use this in lots of 
other places and it does not fail.

gert

Patch

diff --git a/src/openvpn/push.c b/src/openvpn/push.c
index 49b9d1b..213e2b6 100644
--- a/src/openvpn/push.c
+++ b/src/openvpn/push.c
@@ -504,9 +504,10 @@  void
 send_push_reply_auth_token(struct tls_multi *multi)
 {
     struct gc_arena gc = gc_new();
+    struct push_list push_list;
 
+    CLEAR(push_list);
 
-    struct push_list push_list = {};
     prepare_auth_token_push_reply(multi, &gc, &push_list);
 
     /* prepare auth token should always add the auth-token option */