From: "flichtenheld (Code Review)" Date: Tue, 23 Sep 2025 12:02:39 +0000 In-Reply-To: References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <9060816f83f698107cf563693ecf1e2963bcbd6b-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Hce2SKqjgDc="; 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: plaisthos Cc: openvpn-devel --Hce2SKqjgDc= 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 reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1205?usp=3Demail to look at the new patch set (#2). 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 --- M tests/unit_tests/openvpn/test_crypto.c M tests/unit_tests/openvpn/test_ssl.c 2 files changed, 9 insertions(+), 24 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/05/1205/2 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: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newpatchset --Hce2SKqjgDc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld uploaded patch set #2 to this change.

<= p>View C= hange

Make unit tests -Wconversion clean

Only trivial problems l= eft after the other patches
have been merged.

Change-Id: Iab9e780= d9649d7581e5f6aa4b23e72bbed5e145b
Signed-off-by: Frank Lichtenheld <f= rank@...2641...>
---
M tests/unit_tests/openvpn/test_crypto.c
M= tests/unit_tests/openvpn/test_ssl.c
2 files changed, 9 insertions(+), 2= 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn re=
fs/changes/05/1205/2
diff --git a/tests/unit_tests/openvpn/test_cry=
pto.c b/tests/unit_tests/openvpn/test_crypto.c
index 22e691= 2..93dfa42 100644
--- a/tests/unit_tests/openvpn/test_crypt= o.c
+++ b/tests/unit_tests/openvpn/test_crypto.c
= @@ -674,15 +674,10 @@
struct crypto_options co;<= /span>
};

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored = "-Wconversion"
-
<= span> static int
crypto_test_epoch_setup(void **state)
{
- in= t *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_state));

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

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
<= br>-#endif
-
static int
crypto_test_epoch_teardown(void **state)

{
@@ -906,9 +897,9 @@
int
main(void)

{
- i= nt 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 presta= te_num32 =3D 32;

openvpn_unit_test_s= etup();
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/test= s/unit_tests/openvpn/test_ssl.c
@@ -133,11 +133,6 @@=
const char *keyfile;
} global_state;=

-#if define= d(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
static int init(void **state)
{
@@ -152,17 +1= 47,16 @@
{
fail_msg("mak= e tmpfile for certificate or key data failed (error =3D %d)", errno);<= /span>
}
= - assert_int_equal(write(certfd, unittest_cert, strlen(unittest_cert)), = strlen(unittest_cert));
- assert_int_equal(write(keyfd, unittest_key, strlen(unittest_key)), st= rlen(unittest_key));
= + /* Awkward casts required for MinGW with -O0 only */
+ assert_int_equal(write(certfd, un= ittest_cert, (unsigned int)strlen(unittest_cert)),
+ strlen(unittest_cert));=
+ assert_int_equa= l(write(keyfd, unittest_key, (unsigned int)strlen(unittest_key)),+ strlen(u= nittest_key));
close(certfd);
clo= se(keyfd);
return 0;
}

-#if defined(__GNUC= __) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-

static int
cleanup(void **state)
{

To view, visit change 1205. To unsubs= cribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iab9e780d9649d7581e5f6aa4b23= e72bbed5e145b
Gerrit-Change-Number: 1205
Gerrit-PatchSet: 2
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: newpatchset
--Hce2SKqjgDc=--