From: "cron2 (Code Review)" Date: Wed, 24 Sep 2025 13:16:35 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="3dEmnrHzous="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Make unit tests -Wconversion clean List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --3dEmnrHzous= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/12= 05?usp=3Demail ) Change subject: Make unit tests -Wconversion clean ...................................................................... Make unit tests -Wconversion clean Only trivial problems left after the other patches have been merged. Change-Id: Iab9e780d9649d7581e5f6aa4b23e72bbed5e145b Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1205 Message-Id: <20250924124154.15963-1-gert@...1296...> URL: https://sourceforge.net/p/openvpn/mailman/message/59238128/ Signed-off-by: Gert Doering --- M tests/unit_tests/openvpn/test_crypto.c M tests/unit_tests/openvpn/test_ssl.c 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/tests/unit_tests/openvpn/test_crypto.c b/tests/unit_tests/open= vpn/test_crypto.c index 22e6912..93dfa42 100644 --- a/tests/unit_tests/openvpn/test_crypto.c +++ b/tests/unit_tests/openvpn/test_crypto.c @@ -674,15 +674,10 @@ struct crypto_options co; }; -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static int crypto_test_epoch_setup(void **state) { - int *num_future_keys =3D (int *)*state; + uint16_t *num_future_keys =3D (uint16_t *)*state; struct epoch_test_state *data =3D calloc(1, sizeof(struct epoch_test_s= tate)); data->gc =3D gc_new(); @@ -699,10 +694,6 @@ return 0; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static int crypto_test_epoch_teardown(void **state) { @@ -906,9 +897,9 @@ int main(void) { - int prestate_num13 =3D 13; - int prestate_num16 =3D 16; - int prestate_num32 =3D 32; + uint16_t prestate_num13 =3D 13; + uint16_t prestate_num16 =3D 16; + uint16_t prestate_num32 =3D 32; openvpn_unit_test_setup(); const struct CMUnitTest tests[] =3D { diff --git a/tests/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn= /test_ssl.c index ed40a7d..8dc9b66 100644 --- a/tests/unit_tests/openvpn/test_ssl.c +++ b/tests/unit_tests/openvpn/test_ssl.c @@ -133,11 +133,6 @@ const char *keyfile; } global_state; -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static int init(void **state) { @@ -152,17 +147,16 @@ { fail_msg("make tmpfile for certificate or key data failed (error = =3D %d)", errno); } - assert_int_equal(write(certfd, unittest_cert, strlen(unittest_cert)), = strlen(unittest_cert)); - assert_int_equal(write(keyfd, unittest_key, strlen(unittest_key)), str= len(unittest_key)); + /* Awkward casts required for MinGW with -O0 only */ + assert_int_equal(write(certfd, unittest_cert, (unsigned int)strlen(uni= ttest_cert)), + strlen(unittest_cert)); + assert_int_equal(write(keyfd, unittest_key, (unsigned int)strlen(unitt= est_key)), + strlen(unittest_key)); close(certfd); close(keyfd); return 0; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static int cleanup(void **state) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1205?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: Iab9e780d9649d7581e5f6aa4b23e72bbed5e145b Gerrit-Change-Number: 1205 Gerrit-PatchSet: 6 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --3dEmnrHzous= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Make unit tests -Wconversion clean

Onl= y trivial problems left after the other patches
have been merged.
Change-Id: Iab9e780d9649d7581e5f6aa4b23e72bbed5e145b
Signed-off-by: Fra= nk Lichtenheld <frank@...2641...>
Acked-by: Gert Doering <gert@= ...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1205Message-Id: <20250924124154.15963-1-gert@...1296...>
URL: https:= //sourceforge.net/p/openvpn/mailman/message/59238128/
Signed-off-by: Ger= t Doering <gert@...1296...>
---
M tests/unit_tests/openvpn/test= _crypto.c
M tests/unit_tests/openvpn/test_ssl.c
2 files changed, 9 in= sertions(+), 24 deletions(-)

diff --git a/tests/unit_tests/openvpn/test_crypto.c b/tests/unit_tests/o=
penvpn/test_crypto.c
index 22e6912..93dfa42 100644--- a/tests/unit_tests/openvpn/test_crypto.c
+++ b/= tests/unit_tests/openvpn/test_crypto.c
@@ -674,15 +674,10 @= @
struct crypto_options co;
};=

-#if define= d(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
static int crypto_test_epoch_setup(void **state)
{
= - int *num_future_keys =3D (in= t *)*state;
+ uint= 16_t *num_future_keys =3D (uint16_t *)*state;
struct e= poch_test_state *data =3D calloc(1, sizeof(struct epoch_test_state));

data->gc =3D gc_new();
@@ -699,10 +694,6 @@

return 0;
}


-#if def= ined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
static int
crypto_test_epoch_teardo= wn(void **state)
{
@@ -906,9 +897,9 @@
int
main(void)
{
= - int prestate_num13 =3D 13;
- int prestate_num16 = =3D 16;
- int presta= te_num32 =3D 32;
+ = uint16_t prestate_num13 =3D 13;
+ uint16_t prestate_num16 =3D 16;
+ uint16_t prestate_num32 =3D 32;
=
openvpn_unit_test_setup();
= const struct CMUnitTest tests[] =3D {
diff --git a/tests/= unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn/test_ssl.c<= br>index ed40a7d..8dc9b66 100644
--- a/tests/unit_tes= ts/openvpn/test_ssl.c
+++ b/tests/unit_tests/openvpn/test_s= sl.c
@@ -133,11 +133,6 @@
const char *= keyfile;
} global_state;

-#if defined(__GNUC__) || defined(__cl= ang__)

-#pragma GCC dia= gnostic push
-#pragma G= CC diagnostic ignored "-Wconversion"
-#endif
-
static int
init(void **state)<= /span>
{
@@ -152,17 +147,16 @@
= {
fail_msg("make tmpfile for certificate o= r key data failed (error =3D %d)", errno);
}
- assert_int_equal(write= (certfd, unittest_cert, strlen(unittest_cert)), strlen(unittest_cert));
- assert_int_equal(writ= e(keyfd, unittest_key, strlen(unittest_key)), strlen(unittest_key));=
+ /* Awkward casts requi= red for MinGW with -O0 only */
+ assert_int_equal(write(certfd, unittest_cert, (unsigned int)= strlen(unittest_cert)),
+ strlen(unittest_cert));
+ assert_int_equal(write(keyfd, unittest_key= , (unsigned int)strlen(unittest_key)),
+ strlen(unittest_key));
close(certfd);

close(keyfd);
= return 0;
}

-#if defined(__GNUC__) || defined(__clang__)=
-#pragma GCC diagnosti= c pop
-#endif-
static int
cleanup(void **state)
{

To view, visit change 1205. To unsubscribe, or for help writin= g mail filters, visit settin= gs.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iab9e780d9649d7581e5f6aa4b23= e72bbed5e145b
Gerrit-Change-Number: 1205
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--3dEmnrHzous=--