Skip to contentSkip to conversation

options.c: fix msvc build error

PATCH Superseded Lev Stipakov 3 participants 4 messages Jun 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 options.c: fix msvc build error

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

Commit b7fe49c ("Do not require CA when peer-fingerprint is used") broke msvc build by adding #ifdef within msg() macro call.

options.c(2074,1): error C2121: '#': invalid character: possibly the result of a macro expansion options.c(2074,1): error C2146: syntax error: missing ')' before identifier 'ifndef' options.c(2074,1): error C2059: syntax error: ')'

Fix by moving #ifdef outside of msg().

---
 src/openvpn/options.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
src/openvpn/options.c +3 -2
index 6bbe5c15..606e6903 100644
@@ -2067,11 +2067,12 @@ check_ca_required(const struct options *options)
         return;
     }
 
-    msg(M_USAGE, "You must define CA file (--ca)"
+    const char* str = "You must define CA file (--ca)"
 #ifndef ENABLE_CRYPTO_MBEDTLS
         " or CA path (--capath)"
 #endif
-        " and/or peer fingeprint verification " "(--peer-fingerprint)");
+        " and/or peer fingeprint verification " "(--peer-fingerprint)";
+    msg(M_USAGE, str);
 }
 
 static void
Signature · 1 line
2.23.0.windows.1
#1 lore raw

PATCH v2 1/1 options.c: fix msvc build error

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

Commit b7fe49c ("Do not require CA when peer-fingerprint is used") broke msvc build by adding #ifdef within msg() macro call.

options.c(2074,1): error C2121: '#': invalid character: possibly the result of a macro expansion options.c(2074,1): error C2146: syntax error: missing ')' before identifier 'ifndef' options.c(2074,1): error C2059: syntax error: ')'

Fix by moving #ifdef outside of msg().

---

v2:
- fix typo in "fingerprint"
- remove unneeded quotation marks

 src/openvpn/options.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
src/openvpn/options.c +3 -2
index 6bbe5c15..a36d270e 100644
@@ -2067,11 +2067,12 @@ check_ca_required(const struct options *options)
         return;
     }
 
-    msg(M_USAGE, "You must define CA file (--ca)"
+    const char* str = "You must define CA file (--ca)"
 #ifndef ENABLE_CRYPTO_MBEDTLS
         " or CA path (--capath)"
 #endif
-        " and/or peer fingeprint verification " "(--peer-fingerprint)");
+        " and/or peer fingerprint verification (--peer-fingerprint)";
+    msg(M_USAGE, str);
 }
 
 static void
Signature · 1 line
2.23.0.windows.1
Acked-by on v1 1/1
#3 lore raw
In reply to Lev Stipakov
Quoted 25 lines · Lev Stipakov

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

Commit b7fe49c ("Do not require CA when peer-fingerprint is used") broke msvc build by adding #ifdef within msg() macro call.

options.c(2074,1): error C2121: '#': invalid character: possibly the result of a macro expansion options.c(2074,1): error C2146: syntax error: missing ')' before identifier 'ifndef' options.c(2074,1): error C2059: syntax error: ')'

Fix by moving #ifdef outside of msg().

---
 src/openvpn/options.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
src/openvpn/options.c +0 -0
index 6bbe5c15..606e6903 100644
@@ -2067,11 +2067,12 @@ check_ca_required(const struct options *options)
         return;
     }

src/openvpn/options.c check_ca_required(const struct options *options) · line 2076

Quoted 10 lines
src/openvpn/options.c +3 -2
 
-    msg(M_USAGE, "You must define CA file (--ca)"
+    const char* str = "You must define CA file (--ca)"
 #ifndef ENABLE_CRYPTO_MBEDTLS
         " or CA path (--capath)"
 #endif
-        " and/or peer fingeprint verification " "(--peer-fingerprint)");
+        " and/or peer fingeprint verification " "(--peer-fingerprint)";
+    msg(M_USAGE, str);
 }

I forgot msg was a macro... Surprisingly, gcc preprocessor can handle this.

Let's also use this opportunity to fix the typo "fingeprint" and remove the unneeded " " before (--peer-fingerprint). If it could be done at commit time?

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

Yeah, windows... sorry for breaking MSVC again, thanks for fixing the typo :-) - only compile-tested on FreeBSD.

(Adding Selva's ACK on v1, for good measure)

Your patch has been applied to the master branch.

commit 88395a8307964ad48c3841c0b2fb60dce826ebf1

Author: Lev Stipakov
Date:   Mon Jun 7 21:48:20 2021 +0300
     options.c: fix msvc build error

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

--
kind regards,

Gert Doering