From: "flichtenheld (Code Review)"
Date: Tue, 27 Jan 2026 11:16:18 +0000
References:
Reply-To: frank@...2641..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net
Message-ID:
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="boUP6Sa9aDI="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: cryptoapi: Change
signature of parse_hexstring to match code
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: plaisthos
Cc: openvpn-devel
--boUP6Sa9aDI=
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/+/1492?usp=3Demail
to review the following change.
Change subject: cryptoapi: Change signature of parse_hexstring to match code
......................................................................
cryptoapi: Change signature of parse_hexstring to match code
parse_hexdigest is a function that is used in
exactly one place (not counting tests). So
change the types in a way that they match what
the caller actually wants (DWORD) and so we
do not have any unnecessary conversions.
Change-Id: I525a5b1b9b6f173cdf12341aefc44d58f0d43aed
Signed-off-by: Frank Lichtenheld
---
M src/openvpn/cryptoapi.c
M tests/unit_tests/openvpn/test_cryptoapi.c
2 files changed, 6 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1492/1
diff --git a/src/openvpn/cryptoapi.c b/src/openvpn/cryptoapi.c
index b74320d..e17936a 100644
--- a/src/openvpn/cryptoapi.c
+++ b/src/openvpn/cryptoapi.c
@@ -61,7 +61,7 @@
return 0;
}
-#else /* HAVE_XKEY_PROVIDER */
+#else /* HAVE_XKEY_PROVIDER */
static XKEY_EXTERNAL_SIGN_fn xkey_cng_sign;
@@ -145,11 +145,6 @@
free(cd);
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
/**
* Parse a hex string with optional embedded spaces into
* a byte array.
@@ -158,10 +153,10 @@
* @param capacity capacity of the byte array arr
* @returns the number of bytes parsed or 0 on error
*/
-int
-parse_hexstring(const char *p, unsigned char *arr, size_t capacity)
+static DWORD
+parse_hexstring(const char *p, unsigned char *arr, DWORD capacity)
{
- int i =3D 0;
+ DWORD i =3D 0;
for (; *p && i < capacity; p +=3D 2)
{
/* skip spaces */
@@ -182,10 +177,6 @@
return i;
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
static void *
decode_object(struct gc_arena *gc, LPCSTR struct_type, const CRYPT_OBJID_B=
LOB *val, DWORD flags,
DWORD *cb)
diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_tests/o=
penvpn/test_cryptoapi.c
index ce527d7..59a356d 100644
--- a/tests/unit_tests/openvpn/test_cryptoapi.c
+++ b/tests/unit_tests/openvpn/test_cryptoapi.c
@@ -469,7 +469,7 @@
for (size_t i =3D 0; i < _countof(valid_str); i++)
{
- int len =3D parse_hexstring(valid_str[i], hash, _countof(hash));
+ DWORD len =3D parse_hexstring(valid_str[i], hash, _countof(hash));
assert_int_equal(len, sizeof(test_hash));
assert_memory_equal(hash, test_hash, sizeof(test_hash));
memset(hash, 0, _countof(hash));
@@ -477,7 +477,7 @@
for (size_t i =3D 0; i < _countof(invalid_str); i++)
{
- int len =3D parse_hexstring(invalid_str[i], hash, _countof(hash));
+ DWORD len =3D parse_hexstring(invalid_str[i], hash, _countof(hash)=
);
assert_int_equal(len, 0);
}
}
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1492?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings?usp=3Demail
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I525a5b1b9b6f173cdf12341aefc44d58f0d43aed
Gerrit-Change-Number: 1492
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
--boUP6Sa9aDI=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is cur=
rently required from: plaisthos.
flichtenheld would like plaisthos to review this change.
V=
iew Change
cryptoapi: Change signature of parse_hexstr=
ing to match code
parse_hexdigest is a function that is used in
e=
xactly one place (not counting tests). So
change the types in a way that=
they match what
the caller actually wants (DWORD) and so we
do not h=
ave any unnecessary conversions.
Change-Id: I525a5b1b9b6f173cdf12341=
aefc44d58f0d43aed
Signed-off-by: Frank Lichtenheld <frank@...2641...&=
gt;
---
M src/openvpn/cryptoapi.c
M tests/unit_tests/openvpn/test_=
cryptoapi.c
2 files changed, 6 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/chang=
es/92/1492/1
diff --git a/src/openvpn/cryptoapi.c b/src/openvpn/cry=
ptoapi.c
index b74320d..e17936a 100644
--- =
a/src/openvpn/cryptoapi.c
+++ b/src/openvpn/cryptoapi.c
@@ -61,7 +61,7 @@
return 0;
}
-#else /* HAVE_XKEY_PROVIDER */
+#else /* HAVE_XKEY_PROVIDER */
static XKEY_EXTERNAL_SIGN_fn xkey_cng_sign;
@@ -145,11 +145,6 @@
free(cd);
}
-=
#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-com=
pare"
-#endif
-
/**
* Parse a hex string with optional embedded spaces into
* a byte array.
@@ -158,10 +153,10 @@ * @param capacity capacity of the byte array arr
* @returns the number of bytes parsed or 0 on error
*/=
-int
-parse_hexstring(const char *p, unsigned=
char *arr, size_t capacity)
+static DWORD
+parse_hexstring(const char *p, unsigned char *arr, DWORD capacity)=
{
- int i=
=3D 0;
+ DWORD i =
=3D 0;
for (; *p && i < capacity; p +=3D 2)=
{
/* skip spaces */@@ -182,10 +177,6 @@
return i;
}
-=
#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
static void *
decode_object(=
struct gc_arena *gc, LPCSTR struct_type, const CRYPT_OBJID_BLOB *val, DWORD=
flags,
DWORD *cb)
diff --gi=
t a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_tests/openvpn/te=
st_cryptoapi.c
index ce527d7..59a356d 100644
--- a/tests/unit_tests/openvpn/test_cryptoapi.c
+++ b/tes=
ts/unit_tests/openvpn/test_cryptoapi.c
@@ -469,7 +469,7 @@<=
/span>
for (size_t i =3D 0; i < _countof=
(valid_str); i++)
{
- int len =3D parse_hexstring(valid_str[i], hash, =
_countof(hash));
+ =
DWORD len =3D parse_hexstring(valid_str[i], hash, _countof(hash));
assert_int_equal(len, sizeof(test_hash));
<=
span> assert_memory_equal(hash, test_hash, sizeof(test_hash));
memset(hash, 0, _countof(hash));
@@ -4=
77,7 +477,7 @@
for (size_t i =3D 0; =
i < _countof(invalid_str); i++)
{
- int len =3D parse_hexstring(inv=
alid_str[i], hash, _countof(hash));
+ DWORD len =3D parse_hexstring(invalid_str[i], hash,=
_countof(hash));
assert_int_equal(len, 0);=
}
}
To =
view, visit change 1492. To unsubscribe, or for help writing mail filters, visi=
t settings.<=
/p>
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I525a5b1b9b6f173cdf12341aefc=
44d58f0d43aed
Gerrit-Change-Number: 1492
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...>
=
--boUP6Sa9aDI=--