options.c: fix msvc build error
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
@@ -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
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
@@ -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
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
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 expansionoptions.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().Reported-by Samuli Seppänen <[email protected]...>Signed-off-by Lev Stipakov <[email protected]...>--- src/openvpn/options.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)src/openvpn/options.c +0
-0@@ -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?