Skip to contentSkip to conversation

push.c: fix Visual Studio build

PATCH Superseded Lev Stipakov 3 participants 8 messages Oct 8, 2019 – Oct 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 push.c: fix Visual Studio build

From: Lev Stipakov <[email protected]...>

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

---
 src/openvpn/push.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/openvpn/push.c +2 -1
index 49b9d1b..213e2b6 100644
@@ -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 */
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 vcxproj: add missing source files

From: Lev Stipakov <[email protected]...>

Commit 1b9a88a has added new C source/header files which have to be added to VS project file.

---
 src/openvpn/openvpn.vcxproj         | 2 ++
 src/openvpn/openvpn.vcxproj.filters | 6 ++++++
 2 files changed, 8 insertions(+)
src/openvpn/openvpn.vcxproj +2 -0
index 92d7e32..3b0ee60 100644
@@ -124,6 +124,7 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="argv.c" />
+    <ClCompile Include="auth_token.c" />
     <ClCompile Include="base64.c" />
     <ClCompile Include="block_dns.c" />
     <ClCompile Include="buffer.c" />
@@ -199,6 +200,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="argv.h" />
+    <ClInclude Include="auth_token.h" />
     <ClInclude Include="base64.h" />
     <ClInclude Include="basic.h" />
     <ClInclude Include="block_dns.h" />
src/openvpn/openvpn.vcxproj.filters +6 -0
index 7a9aa63..e6068af 100644
@@ -234,6 +234,9 @@
     <ClCompile Include="run_command.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="auth_token.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="base64.h">
@@ -488,6 +491,9 @@
     <ClInclude Include="run_command.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="auth_token.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="openvpn_win32_resources.rc">
Signature · 1 line
2.7.4
Acked-by on v1 1/2
#2 lore raw
In reply to Lev Stipakov

Am 08.10.19 um 14:26 schrieb Lev Stipakov:

Quoted 17 lines

From: Lev Stipakov <[email protected]...>

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

---
 src/openvpn/push.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/openvpn/push.c +0 -0
index 49b9d1b..213e2b6 100644
@@ -504,9 +504,10 @@ void
 send_push_reply_auth_token(struct tls_multi *multi)

src/openvpn/push.c void · line 513

Quoted 10 lines
src/openvpn/push.c +2 -1
 {
     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

#3 lore raw

Hi,

Quoted 1 line · Arne Schwabe

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

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#4 lore raw

PATCH v2 1/2 push.c: fix Visual Studio build

From: Lev Stipakov <[email protected]...>

Visual Studio doesn't support empty designated initializers for C code, so use { 0 }. Also replace existing CLEAR() call with the new initializers.

---
 src/openvpn/push.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/openvpn/push.c +2 -4
index 49b9d1b..368b692 100644
@@ -504,9 +504,8 @@ void
 send_push_reply_auth_token(struct tls_multi *multi)
 {
     struct gc_arena gc = gc_new();
+    struct push_list push_list = { 0 };
 
-
-    struct push_list push_list = {};
     prepare_auth_token_push_reply(multi, &gc, &push_list);
 
     /* prepare auth token should always add the auth-token option */
@@ -734,10 +733,9 @@ process_incoming_push_request(struct context *c)
         else
         {
             /* per-client push options - peer-id, cipher, ifconfig, ipv6-ifconfig */
-            struct push_list push_list;
+            struct push_list push_list = { 0 };
             struct gc_arena gc = gc_new();
 
-            CLEAR(push_list);
             if (prepare_push_reply(c, &gc, &push_list)
                 && send_push_reply(c, &push_list))
             {
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 2/2 vcxproj: add missing source files

From: Lev Stipakov <[email protected]...>

Commit 1b9a88a has added new C source/header files which have to be added to VS project file.

---
 src/openvpn/openvpn.vcxproj         | 2 ++
 src/openvpn/openvpn.vcxproj.filters | 6 ++++++
 2 files changed, 8 insertions(+)
src/openvpn/openvpn.vcxproj +2 -0
index 92d7e32..3b0ee60 100644
@@ -124,6 +124,7 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="argv.c" />
+    <ClCompile Include="auth_token.c" />
     <ClCompile Include="base64.c" />
     <ClCompile Include="block_dns.c" />
     <ClCompile Include="buffer.c" />
@@ -199,6 +200,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="argv.h" />
+    <ClInclude Include="auth_token.h" />
     <ClInclude Include="base64.h" />
     <ClInclude Include="basic.h" />
     <ClInclude Include="block_dns.h" />
src/openvpn/openvpn.vcxproj.filters +6 -0
index 7a9aa63..e6068af 100644
@@ -234,6 +234,9 @@
     <ClCompile Include="run_command.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="auth_token.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="base64.h">
@@ -488,6 +491,9 @@
     <ClInclude Include="run_command.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="auth_token.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="openvpn_win32_resources.rc">
Signature · 1 line
2.7.4
Acked-by on v2 2/2
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: vcxproj: add missing source files

I do not have any idea about MSVC or project files, but this looks like a trivial extrapolation of "what is there". And if you say it's needed, fine.

Your patch has been applied to the master branch.

commit a933d21a902adfaa3893bd0f6097a1696d5ccf69

Author: Lev Stipakov
Date:   Tue Oct 8 15:52:34 2019 +0300
     vcxproj: add missing source files

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg18903.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

Acked-by on v2 1/2
#7 lore raw
In reply to Lev Stipakov

Arne has already ACKed the first one, but this is more in line with what we've done in "more recent code" - and also thanks for changing the other occurrence.

"Stared at code" and lightly tested on Linux and FreeBSD.

Your patch has been applied to the master branch.

commit 4431d0903d4e23ef01a5582960990b77e9522ab2

Author: Lev Stipakov
Date:   Tue Oct 8 15:52:33 2019 +0300
     push.c: fix Visual Studio build

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg18904.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering