From: "flichtenheld (Code Review)" Date: Fri, 28 Mar 2025 14:18:11 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <5caccc1f9db32ffeba9640cd2f082e7a8a9aad7a-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="nwfeAZfDAyI="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: CMake: Sync list of compiler flags with configure.ac List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --nwfeAZfDAyI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/923?usp=3Demail to review the following change. Change subject: CMake: Sync list of compiler flags with configure.ac ...................................................................... CMake: Sync list of compiler flags with configure.ac Also fix one issue reported by the build. Change-Id: I28af9eac2e9fb615903a82c8f4087602b72c134d Signed-off-by: Frank Lichtenheld --- M CMakeLists.txt M tests/unit_tests/openvpn/test_cryptoapi.c 2 files changed, 11 insertions(+), 6 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/923/1 diff --git a/CMakeLists.txt b/CMakeLists.txt index b04adce..ba11056 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,13 @@ CACHE STRING "Flags used by the C++ compiler during AddressSanitizer b= uilds." FORCE) +function(check_and_add_compiler_flag flag variable) + check_c_compiler_flag(${flag} ${variable}) + if (${variable}) + add_compile_options(${flag}) + endif() +endfunction() + if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE = -D_WINSOCK_DEPRECATED_NO_WARNINGS) if (USE_WERROR) @@ -96,11 +103,9 @@ endif() else () add_compile_options(-Wall -Wuninitialized) - check_c_compiler_flag(-Wno-stringop-truncation NoStringOpTruncation) - - if (${NoStringOpTruncation}) - add_compile_options(-Wno-stringop-truncation) - endif() + check_and_add_compiler_flag(-Wno-stringop-truncation NoStringOpTruncat= ion) + check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes) + check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition) # We are not ready for this #add_compile_options(-Wconversion -Wno-sign-conversion -Wsign-compare) if (USE_WERROR) diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_tests/o= penvpn/test_cryptoapi.c index 98102ef..478995f 100644 --- a/tests/unit_tests/openvpn/test_cryptoapi.c +++ b/tests/unit_tests/openvpn/test_cryptoapi.c @@ -116,7 +116,7 @@ /* Fill-in certs[] array */ void -init_cert_data() +init_cert_data(void) { struct test_cert certs_local[] =3D { {cert1, key1, cname1, "OVPN TEST CA1", "OVPN Test Cert 1", ha= sh1, 1}, -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/923?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I28af9eac2e9fb615903a82c8f4087602b72c134d Gerrit-Change-Number: 923 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --nwfeAZfDAyI= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

Vi= ew Change

CMake: Sync list of compiler flags with configure.ac

A= lso fix one issue reported by the build.

Change-Id: I28af9eac2e9fb61= 5903a82c8f4087602b72c134d
Signed-off-by: Frank Lichtenheld <frank@...493...= 2641...>
---
M CMakeLists.txt
M tests/unit_tests/openvpn/test_c= ryptoapi.c
2 files changed, 11 insertions(+), 6 deletions(-)

g=
it pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/923/1
<= pre style=3D"font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/CMakeLists.txt b/CMakeLists.txt
index b04adc= e..ba11056 100644
--- a/CMakeLists.txt
+++ = b/CMakeLists.txt
@@ -66,6 +66,13 @@
CA= CHE STRING "Flags used by the C++ compiler during AddressSanitizer bui= lds."
FORCE)

+function(check_and_add_compiler_flag f= lag variable)
+ ch= eck_c_compiler_flag(${flag} ${variable})
+ if (${variable})
+ add_compile_options(${flag})
+ endif()
+endfunction()
+
if (MSVC)
a= dd_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN= SOCK_DEPRECATED_NO_WARNINGS)
if (USE_WERROR)@@ -96,11 +103,9 @@
endif()
el= se ()
add_compile_options(-Wall -Wuninitialized)
- check_c_compiler_flag(-= Wno-stringop-truncation NoStringOpTruncation)
-
- add_compile_options(-Wno-stringop-truncation)<= br>- endif()
+ check_and_add_compiler_flag(-Wno-= stringop-truncation NoStringOpTruncation)
+ check_and_add_compiler_flag(-Wstrict-prototypes S= trictPrototypes)
+ = check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition)
# We are not ready for this
#add_com= pile_options(-Wconversion -Wno-sign-conversion -Wsign-compare)
if (USE_WERROR)

diff --git a/tests/unit_tests/open= vpn/test_cryptoapi.c b/tests/unit_tests/openvpn/test_cryptoapi.c
= index 98102ef..478995f 100644
--- a/tests/unit_tests/= openvpn/test_cryptoapi.c
+++ b/tests/unit_tests/openvpn/tes= t_cryptoapi.c
@@ -116,7 +116,7 @@
<= br> /* Fill-in certs[] array */
void
-init_cert_data()

+init_cert_data(void)
{<= /span>
struct test_cert certs_local[] =3D {
= {cert1, key1, cname1, "OVPN TEST CA1", "OVPN Tes= t Cert 1", hash1, 1},

To view, v= isit chan= ge 923. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I28af9eac2e9fb615903a82c8f40= 87602b72c134d
Gerrit-Change-Number: 923
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-MessageType: newchange
--nwfeAZfDAyI=--