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.
Change-Id: I4ff7983a33426fda9a138fe6e56a1c03522836d3
Signed-off-by: Frank Lichtenheld <[email protected]>
---
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
diff --git a/src/openvpn/win32-util.c b/src/openvpn/win32-util.c
index e60cbac..6fc3be4 100644
--- a/src/openvpn/win32-util.c
+++ b/src/openvpn/win32-util.c
@@ -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]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel