Change in openvpn[master]: win32: Change some APIs to use DWORD instead of size_t
A message that is not in the archive (sent off-list or not yet received): gerrit.1760359115000.Ia836e3c05a868a7e8419c2bb2f547d968260783c@...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/+/1269?usp=email
to review the following change.
Change subject: win32: Change some APIs to use DWORD instead of size_t
......................................................................
win32: Change some APIs to use DWORD instead of size_t
This is what the Win32 APIs use. Since we put static integers into this (e.g. sizeof()) this doesn't result in new conversion warnings at the caller sites.
---
M src/openvpn/route.c
M src/openvpn/win32.c
M src/openvpn/win32.h
M tests/unit_tests/openvpn/test_user_pass.c
4 files changed, 20 insertions(+), 24 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/69/1269/1
src/openvpn/route.c +1 -1
@@ -2840,7 +2840,7 @@/* Returns RTA_SUCCESS on success, RTA_EEXIST if route exists, RTA_ERROR on error */ static int -do_route_service (const bool add,const route_message_t *rt,const size_t size,HANDLE pipe) +do_route_service (const bool add,const route_message_t *rt,const DWORD size,HANDLE pipe) {int ret =RTA_ERROR ;ack_message_t ack;
src/openvpn/win32.c +6 -14
@@ -1418,13 +1418,8 @@return (const char *)out.data; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -bool -send_msg_iservice (HANDLE pipe,const void *data,size_t size,ack_message_t *ack, +send_msg_iservice (HANDLE pipe,const void *data,DWORD size,ack_message_t *ack,const char *context) {struct gc_arena gc =gc_new ();
@@ -1527,7 +1522,8 @@while (expire >= now) { -DWORD status =WaitForSingleObject (win32_signal.in.read, (expire - now) *1000 ); +DWORD wait_ms = (DWORD )((expire - now) *1000 ); +DWORD status =WaitForSingleObject (win32_signal.in.read, wait_ms);if ((status ==WAIT_OBJECT_0 &&win32_signal_get (&win32_signal)) || status ==WAIT_TIMEOUT ) {return ;
@@ -1539,7 +1535,7 @@ {if (expire > now) { -Sleep ((expire - now) *1000 ); +Sleep ((DWORD )((expire - now) *1000 )); }return ; }
@@ -1602,7 +1598,7 @@ }bool -protect_buffer_win32 (char *buf,size_t len) +protect_buffer_win32 (char *buf,DWORD len) {bool ret;if (len %CRYPTPROTECTMEMORY_BLOCK_SIZE )
@@ -1620,7 +1616,7 @@ }bool -unprotect_buffer_win32 (char *buf,size_t len) +unprotect_buffer_win32 (char *buf,DWORD len) {bool ret;if (len %CRYPTPROTECTMEMORY_BLOCK_SIZE )
@@ -1637,8 +1633,4 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -#endif /* ifdef _WIN32 */
src/openvpn/win32.h +9 -7
@@ -301,12 +301,14 @@*/ const char *win32_version_string (struct gc_arena *gc); -/* -* Send the |size| bytes in buffer |data| to the interactive service |pipe| -* and read the result in |ack|. Returns false on communication error. -* The string in |context| is used to prefix error messages. +/** +* Send the \p size bytes in buffer \p data to the interactive service \p pipe +* and read the result in \p ack. +* The string in \p context is used to prefix error messages. +* +* @return true on success, false on communication error */ -bool send_msg_iservice (HANDLE pipe,const void *data,size_t size,ack_message_t *ack, +bool send_msg_iservice (HANDLE pipe,const void *data,DWORD size,ack_message_t *ack,const char *context);/*
@@ -350,7 +352,7 @@* - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool protect_buffer_win32 (char *buf,size_t len); +bool protect_buffer_win32 (char *buf,DWORD len);/** * Decrypt a previously encrypted region of memory using CryptUnProtectMemory()
@@ -360,7 +362,7 @@* - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool unprotect_buffer_win32 (char *buf,size_t len); +bool unprotect_buffer_win32 (char *buf,DWORD len);#endif /* ifndef OPENVPN_WIN32_H */ #endif /* ifdef _WIN32 */
tests/unit_tests/openvpn/test_user_pass.c +4 -2
@@ -79,17 +79,19 @@return 0 ; } +#ifdef _WIN32bool -protect_buffer_win32 (char *buf,size_t len) +protect_buffer_win32 (char *buf,DWORD len) {return true; }bool -unprotect_buffer_win32 (char *buf,size_t len) +unprotect_buffer_win32 (char *buf,DWORD len) {return true; } +#endif /* tooling */ static void
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1269?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: Ia836e3c05a868a7e8419c2bb2f547d968260783c
Gerrit-Change-Number: 1269
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.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1269?usp=email )
Change subject: win32: Change some APIs to use DWORD instead of size_t
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1269?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: Ia836e3c05a868a7e8419c2bb2f547d968260783c
Gerrit-Change-Number: 1269
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Oct 2025 16:22:06 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH 1/1 win32: Change some APIs to use DWORD instead of size_t
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
This is what the Win32 APIs use. Since we put static integers into this (e.g. sizeof()) this doesn't result in new conversion warnings at the caller sites.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1269
---
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/+/1269
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/route.c +1 -1
@@ -2840,7 +2840,7 @@/* Returns RTA_SUCCESS on success, RTA_EEXIST if route exists, RTA_ERROR on error */ static int -do_route_service (const bool add,const route_message_t *rt,const size_t size,HANDLE pipe) +do_route_service (const bool add,const route_message_t *rt,const DWORD size,HANDLE pipe) {int ret =RTA_ERROR ;ack_message_t ack;
src/openvpn/win32.c +6 -14
@@ -1418,13 +1418,8 @@return (const char *)out.data; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -bool -send_msg_iservice (HANDLE pipe,const void *data,size_t size,ack_message_t *ack, +send_msg_iservice (HANDLE pipe,const void *data,DWORD size,ack_message_t *ack,const char *context) {struct gc_arena gc =gc_new ();
@@ -1527,7 +1522,8 @@while (expire >= now) { -DWORD status =WaitForSingleObject (win32_signal.in.read, (expire - now) *1000 ); +DWORD wait_ms = (DWORD )((expire - now) *1000 ); +DWORD status =WaitForSingleObject (win32_signal.in.read, wait_ms);if ((status ==WAIT_OBJECT_0 &&win32_signal_get (&win32_signal)) || status ==WAIT_TIMEOUT ) {return ;
@@ -1539,7 +1535,7 @@ {if (expire > now) { -Sleep ((expire - now) *1000 ); +Sleep ((DWORD )((expire - now) *1000 )); }return ; }
@@ -1602,7 +1598,7 @@ }bool -protect_buffer_win32 (char *buf,size_t len) +protect_buffer_win32 (char *buf,DWORD len) {bool ret;if (len %CRYPTPROTECTMEMORY_BLOCK_SIZE )
@@ -1620,7 +1616,7 @@ }bool -unprotect_buffer_win32 (char *buf,size_t len) +unprotect_buffer_win32 (char *buf,DWORD len) {bool ret;if (len %CRYPTPROTECTMEMORY_BLOCK_SIZE )
@@ -1637,8 +1633,4 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -#endif /* ifdef _WIN32 */
src/openvpn/win32.h +9 -7
@@ -301,12 +301,14 @@*/ const char *win32_version_string (struct gc_arena *gc); -/* -* Send the |size| bytes in buffer |data| to the interactive service |pipe| -* and read the result in |ack|. Returns false on communication error. -* The string in |context| is used to prefix error messages. +/** +* Send the \p size bytes in buffer \p data to the interactive service \p pipe +* and read the result in \p ack. +* The string in \p context is used to prefix error messages. +* +* @return true on success, false on communication error */ -bool send_msg_iservice (HANDLE pipe,const void *data,size_t size,ack_message_t *ack, +bool send_msg_iservice (HANDLE pipe,const void *data,DWORD size,ack_message_t *ack,const char *context);/*
@@ -350,7 +352,7 @@* - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool protect_buffer_win32 (char *buf,size_t len); +bool protect_buffer_win32 (char *buf,DWORD len);/** * Decrypt a previously encrypted region of memory using CryptUnProtectMemory()
@@ -360,7 +362,7 @@* - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool unprotect_buffer_win32 (char *buf,size_t len); +bool unprotect_buffer_win32 (char *buf,DWORD len);#endif /* ifndef OPENVPN_WIN32_H */ #endif /* ifdef _WIN32 */
tests/unit_tests/openvpn/test_user_pass.c +4 -2
@@ -79,17 +79,19 @@return 0 ; } +#ifdef _WIN32bool -protect_buffer_win32 (char *buf,size_t len) +protect_buffer_win32 (char *buf,DWORD len) {return true; }bool -unprotect_buffer_win32 (char *buf,size_t len) +unprotect_buffer_win32 (char *buf,DWORD len) {return true; } +#endif /* tooling */ static void
[Openvpn-devel] [PATCH applied] Re: win32: Change some APIs to use DWORD instead of size_t
Straightforward enough. The #ifdef addition surprised me first, but that's just "the mocked function exists only on windows", so it can be DWORD - but that data type might not be available elsewhere.
Stared-at-code, and BB is all green. GHA will actually run a windows test client, so in case something went wrong, we'll be told...
Your patch has been applied to the master branch.
commit c4f7b418c223ba1bd4614b3fa5ec243b385c8dc5
Author: Frank Lichtenheld Date: Mon Oct 13 18:22:15 2025 +0200
win32: Change some APIs to use DWORD instead of size_t
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1269
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59246222/
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1269?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: win32: Change some APIs to use DWORD instead of size_t
......................................................................
win32: Change some APIs to use DWORD instead of size_t
This is what the Win32 APIs use. Since we put static integers into this (e.g. sizeof()) this doesn't result in new conversion warnings at the caller sites.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1269
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59246222/
---
M src/openvpn/route.c
M src/openvpn/win32.c
M src/openvpn/win32.h
M tests/unit_tests/openvpn/test_user_pass.c
4 files changed, 20 insertions(+), 24 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/69/1269/2
src/openvpn/route.c +1 -1
@@ -2840,7 +2840,7 @@/* Returns RTA_SUCCESS on success, RTA_EEXIST if route exists, RTA_ERROR on error */ static int -do_route_service (const bool add,const route_message_t *rt,const size_t size,HANDLE pipe) +do_route_service (const bool add,const route_message_t *rt,const DWORD size,HANDLE pipe) {int ret =RTA_ERROR ;ack_message_t ack;
src/openvpn/win32.c +6 -14
@@ -1418,13 +1418,8 @@return (const char *)out.data; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -bool -send_msg_iservice (HANDLE pipe,const void *data,size_t size,ack_message_t *ack, +send_msg_iservice (HANDLE pipe,const void *data,DWORD size,ack_message_t *ack,const char *context) {struct gc_arena gc =gc_new ();
@@ -1527,7 +1522,8 @@while (expire >= now) { -DWORD status =WaitForSingleObject (win32_signal.in.read, (expire - now) *1000 ); +DWORD wait_ms = (DWORD )((expire - now) *1000 ); +DWORD status =WaitForSingleObject (win32_signal.in.read, wait_ms);if ((status ==WAIT_OBJECT_0 &&win32_signal_get (&win32_signal)) || status ==WAIT_TIMEOUT ) {return ;
@@ -1539,7 +1535,7 @@ {if (expire > now) { -Sleep ((expire - now) *1000 ); +Sleep ((DWORD )((expire - now) *1000 )); }return ; }
@@ -1602,7 +1598,7 @@ }bool -protect_buffer_win32 (char *buf,size_t len) +protect_buffer_win32 (char *buf,DWORD len) {bool ret;if (len %CRYPTPROTECTMEMORY_BLOCK_SIZE )
@@ -1620,7 +1616,7 @@ }bool -unprotect_buffer_win32 (char *buf,size_t len) +unprotect_buffer_win32 (char *buf,DWORD len) {bool ret;if (len %CRYPTPROTECTMEMORY_BLOCK_SIZE )
@@ -1637,8 +1633,4 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -#endif /* ifdef _WIN32 */
src/openvpn/win32.h +9 -7
@@ -301,12 +301,14 @@*/ const char *win32_version_string (struct gc_arena *gc); -/* -* Send the |size| bytes in buffer |data| to the interactive service |pipe| -* and read the result in |ack|. Returns false on communication error. -* The string in |context| is used to prefix error messages. +/** +* Send the \p size bytes in buffer \p data to the interactive service \p pipe +* and read the result in \p ack. +* The string in \p context is used to prefix error messages. +* +* @return true on success, false on communication error */ -bool send_msg_iservice (HANDLE pipe,const void *data,size_t size,ack_message_t *ack, +bool send_msg_iservice (HANDLE pipe,const void *data,DWORD size,ack_message_t *ack,const char *context);/*
@@ -350,7 +352,7 @@* - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool protect_buffer_win32 (char *buf,size_t len); +bool protect_buffer_win32 (char *buf,DWORD len);/** * Decrypt a previously encrypted region of memory using CryptUnProtectMemory()
@@ -360,7 +362,7 @@* - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool unprotect_buffer_win32 (char *buf,size_t len); +bool unprotect_buffer_win32 (char *buf,DWORD len);#endif /* ifndef OPENVPN_WIN32_H */ #endif /* ifdef _WIN32 */
tests/unit_tests/openvpn/test_user_pass.c +4 -2
@@ -79,17 +79,19 @@return 0 ; } +#ifdef _WIN32bool -protect_buffer_win32 (char *buf,size_t len) +protect_buffer_win32 (char *buf,DWORD len) {return true; }bool -unprotect_buffer_win32 (char *buf,size_t len) +unprotect_buffer_win32 (char *buf,DWORD len) {return true; } +#endif /* tooling */ static void
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1269?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: Ia836e3c05a868a7e8419c2bb2f547d968260783c
Gerrit-Change-Number: 1269
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1269?usp=email )
Change subject: win32: Change some APIs to use DWORD instead of size_t
......................................................................
win32: Change some APIs to use DWORD instead of size_t
This is what the Win32 APIs use. Since we put static integers into this (e.g. sizeof()) this doesn't result in new conversion warnings at the caller sites.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1269
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59246222/
---
M src/openvpn/route.c
M src/openvpn/win32.c
M src/openvpn/win32.h
M tests/unit_tests/openvpn/test_user_pass.c
4 files changed, 20 insertions(+), 24 deletions(-)
src/openvpn/route.c +1 -1
@@ -2840,7 +2840,7 @@/* Returns RTA_SUCCESS on success, RTA_EEXIST if route exists, RTA_ERROR on error */ static int -do_route_service (const bool add,const route_message_t *rt,const size_t size,HANDLE pipe) +do_route_service (const bool add,const route_message_t *rt,const DWORD size,HANDLE pipe) {int ret =RTA_ERROR ;ack_message_t ack;
src/openvpn/win32.c +6 -14
@@ -1418,13 +1418,8 @@return (const char *)out.data; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -bool -send_msg_iservice (HANDLE pipe,const void *data,size_t size,ack_message_t *ack, +send_msg_iservice (HANDLE pipe,const void *data,DWORD size,ack_message_t *ack,const char *context) {struct gc_arena gc =gc_new ();
@@ -1527,7 +1522,8 @@while (expire >= now) { -DWORD status =WaitForSingleObject (win32_signal.in.read, (expire - now) *1000 ); +DWORD wait_ms = (DWORD )((expire - now) *1000 ); +DWORD status =WaitForSingleObject (win32_signal.in.read, wait_ms);if ((status ==WAIT_OBJECT_0 &&win32_signal_get (&win32_signal)) || status ==WAIT_TIMEOUT ) {return ;
@@ -1539,7 +1535,7 @@ {if (expire > now) { -Sleep ((expire - now) *1000 ); +Sleep ((DWORD )((expire - now) *1000 )); }return ; }
@@ -1602,7 +1598,7 @@ }bool -protect_buffer_win32 (char *buf,size_t len) +protect_buffer_win32 (char *buf,DWORD len) {bool ret;if (len %CRYPTPROTECTMEMORY_BLOCK_SIZE )
@@ -1620,7 +1616,7 @@ }bool -unprotect_buffer_win32 (char *buf,size_t len) +unprotect_buffer_win32 (char *buf,DWORD len) {bool ret;if (len %CRYPTPROTECTMEMORY_BLOCK_SIZE )
@@ -1637,8 +1633,4 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -#endif /* ifdef _WIN32 */
src/openvpn/win32.h +9 -7
@@ -301,12 +301,14 @@*/ const char *win32_version_string (struct gc_arena *gc); -/* -* Send the |size| bytes in buffer |data| to the interactive service |pipe| -* and read the result in |ack|. Returns false on communication error. -* The string in |context| is used to prefix error messages. +/** +* Send the \p size bytes in buffer \p data to the interactive service \p pipe +* and read the result in \p ack. +* The string in \p context is used to prefix error messages. +* +* @return true on success, false on communication error */ -bool send_msg_iservice (HANDLE pipe,const void *data,size_t size,ack_message_t *ack, +bool send_msg_iservice (HANDLE pipe,const void *data,DWORD size,ack_message_t *ack,const char *context);/*
@@ -350,7 +352,7 @@* - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool protect_buffer_win32 (char *buf,size_t len); +bool protect_buffer_win32 (char *buf,DWORD len);/** * Decrypt a previously encrypted region of memory using CryptUnProtectMemory()
@@ -360,7 +362,7 @@* - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool unprotect_buffer_win32 (char *buf,size_t len); +bool unprotect_buffer_win32 (char *buf,DWORD len);#endif /* ifndef OPENVPN_WIN32_H */ #endif /* ifdef _WIN32 */
tests/unit_tests/openvpn/test_user_pass.c +4 -2
@@ -79,17 +79,19 @@return 0 ; } +#ifdef _WIN32bool -protect_buffer_win32 (char *buf,size_t len) +protect_buffer_win32 (char *buf,DWORD len) {return true; }bool -unprotect_buffer_win32 (char *buf,size_t len) +unprotect_buffer_win32 (char *buf,DWORD len) {return true; } +#endif /* tooling */ static void
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1269?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: Ia836e3c05a868a7e8419c2bb2f547d968260783c
Gerrit-Change-Number: 1269
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>