Change in openvpn[master]: win32-util: Handle return value from WideCharToMultiByte better
A message that is not in the archive (sent off-list or not yet received): gerrit.1769513463000.I4ff7983a33426fda9a138fe6e56a1c03522836d3@...2715...
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/+/1495?usp=email
to review the following change.
Change subject: win32-util: Handle return value from WideCharToMultiByte better
......................................................................
win32-util: Handle return value from WideCharToMultiByte better
Handle the case where the return value is zero
and avoid sign-compare warning.
---
M src/openvpn/win32-util.c
1 file changed, 8 insertions(+), 9 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1495/1
src/openvpn/win32-util.c +8 -9
@@ -146,11 +146,6 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -const char *win_get_tempdir (void ) {
@@ -162,7 +157,14 @@return NULL ; } -if (WideCharToMultiByte (CP_UTF8 ,0 , wtmpdir,-1 ,NULL ,0 ,NULL ,NULL ) >sizeof (tmpdir)) +int ret =WideCharToMultiByte (CP_UTF8 ,0 , wtmpdir,-1 ,NULL ,0 ,NULL ,NULL ); +/* According to documentation ret is never < 0, but include it here just in case */ +if (ret <=0 ) + { +msg (M_WARN |M_ERRNO ,"Conversion of path name failed." ); +return NULL ; + } +if ((unsigned int )ret >sizeof (tmpdir)) {msg (M_WARN ,"Could not get temporary directory. Path is too long." " Consider using --tmp-dir" );
@@ -173,7 +175,4 @@ return tmpdir; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif #endif /* _WIN32 */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1495?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4ff7983a33426fda9a138fe6e56a1c03522836d3
Gerrit-Change-Number: 1495
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1495?usp=email )
Change subject: win32-util: Handle return value from WideCharToMultiByte better
......................................................................
Patch Set 5: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1495?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4ff7983a33426fda9a138fe6e56a1c03522836d3
Gerrit-Change-Number: 1495
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 02 Mar 2026 15:35:47 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v5 1/1 win32-util: Handle return value from WideCharToMultiByte better
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
Handle the case where the return value is zero
and avoid sign-compare warning.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1495
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1495
This mail reflects revision 5 of this Change.
Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
src/openvpn/win32-util.c +8 -9
@@ -146,11 +146,6 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -const char *win_get_tempdir (void ) {
@@ -162,7 +157,14 @@return NULL ; } -if (WideCharToMultiByte (CP_UTF8 ,0 , wtmpdir,-1 ,NULL ,0 ,NULL ,NULL ) >sizeof (tmpdir)) +int ret =WideCharToMultiByte (CP_UTF8 ,0 , wtmpdir,-1 ,NULL ,0 ,NULL ,NULL ); +/* According to documentation ret is never < 0, but include it here just in case */ +if (ret <=0 ) + { +msg (M_WARN |M_ERRNO ,"Conversion of path name failed." ); +return NULL ; + } +if ((unsigned int )ret >sizeof (tmpdir)) {msg (M_WARN ,"Could not get temporary directory. Path is too long." " Consider using --tmp-dir" );
@@ -173,7 +175,4 @@ return tmpdir; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif #endif /* _WIN32 */
[Openvpn-devel] [PATCH applied] Re: win32-util: Handle return value from WideCharToMultiByte better
Makes sense, appeases the compiler, increases readability *and* has an ACK from Arne (plus green BB) ;-)
Your patch has been applied to the master branch.
commit 71c6729c403a17492a68ce70b0f6fd17c07e3de0
Author: Frank Lichtenheld Date: Wed Mar 4 17:49:22 2026 +0100
win32-util: Handle return value from WideCharToMultiByte better
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1495
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35906.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#6) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1495?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by plaisthos
Change subject: win32-util: Handle return value from WideCharToMultiByte better
......................................................................
win32-util: Handle return value from WideCharToMultiByte better
Handle the case where the return value is zero
and avoid sign-compare warning.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1495
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35906.html
---
M src/openvpn/win32-util.c
1 file changed, 8 insertions(+), 9 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1495/6
src/openvpn/win32-util.c +8 -9
@@ -146,11 +146,6 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -const char *win_get_tempdir (void ) {
@@ -162,7 +157,14 @@return NULL ; } -if (WideCharToMultiByte (CP_UTF8 ,0 , wtmpdir,-1 ,NULL ,0 ,NULL ,NULL ) >sizeof (tmpdir)) +int ret =WideCharToMultiByte (CP_UTF8 ,0 , wtmpdir,-1 ,NULL ,0 ,NULL ,NULL ); +/* According to documentation ret is never < 0, but include it here just in case */ +if (ret <=0 ) + { +msg (M_WARN |M_ERRNO ,"Conversion of path name failed." ); +return NULL ; + } +if ((unsigned int )ret >sizeof (tmpdir)) {msg (M_WARN ,"Could not get temporary directory. Path is too long." " Consider using --tmp-dir" );
@@ -173,7 +175,4 @@ return tmpdir; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif #endif /* _WIN32 */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1495?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4ff7983a33426fda9a138fe6e56a1c03522836d3
Gerrit-Change-Number: 1495
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1495?usp=email )
Change subject: win32-util: Handle return value from WideCharToMultiByte better
......................................................................
win32-util: Handle return value from WideCharToMultiByte better
Handle the case where the return value is zero
and avoid sign-compare warning.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1495
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35906.html
---
M src/openvpn/win32-util.c
1 file changed, 8 insertions(+), 9 deletions(-)
src/openvpn/win32-util.c +8 -9
@@ -146,11 +146,6 @@return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif -const char *win_get_tempdir (void ) {
@@ -162,7 +157,14 @@return NULL ; } -if (WideCharToMultiByte (CP_UTF8 ,0 , wtmpdir,-1 ,NULL ,0 ,NULL ,NULL ) >sizeof (tmpdir)) +int ret =WideCharToMultiByte (CP_UTF8 ,0 , wtmpdir,-1 ,NULL ,0 ,NULL ,NULL ); +/* According to documentation ret is never < 0, but include it here just in case */ +if (ret <=0 ) + { +msg (M_WARN |M_ERRNO ,"Conversion of path name failed." ); +return NULL ; + } +if ((unsigned int )ret >sizeof (tmpdir)) {msg (M_WARN ,"Could not get temporary directory. Path is too long." " Consider using --tmp-dir" );
@@ -173,7 +175,4 @@ return tmpdir; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif #endif /* _WIN32 */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1495?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4ff7983a33426fda9a138fe6e56a1c03522836d3
Gerrit-Change-Number: 1495
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>