windows: kill a couple of warnings
cover windows: kill a couple of warnings
When compiling with mingw32-w64 we still get a bunch of warnings. Some are easily fixable and therefore I thought about providing small patches addressing those.
Remaining warnings are not "difficult" to fix, but rather not easy to be fixed cleanly while keeping the change compact.
Note: I haven't compiled this with MSVC.
Cheers,
Antonio Quartulli (3):
windows: use appropriate and portable format specifier for 64bit
pointer
windows: define variable only where used
windows: list all enum values in switch block
src/openvpn/common.h | 2 +- src/openvpn/run_command.c | 2 +- src/openvpnserv/interactive.c | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.3
PATCH 1/3 windows: use appropriate and portable format specifier for 64bit pointer
From: Antonio Quartulli <[email protected]...>
To print a 64bit poiner, fprintf() must be provided with the appropriate format specifier.
The most portable in this case is PRIx64, which is redefined accordingly on each platform. It comes from inttypes.h and it's the recommended way to print a 64bit long hex value.
Fixes various warnings of this type:
event.c: In function ‘we_ctl’:
event.c:235:24: warning: 'I' flag used with ‘%x’ gnu_printf format [-Wformat=]
235 | dmsg(D_EVENT_WAIT, "WE_CTL n=%d ev=%p rwflags=0x%04x arg=" ptr_format,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error.h:151:68: note: in definition of macro ‘dmsg’
151 | #define dmsg(flags, ...) do { if (msg_test(flags)) {x_msg((flags), __VA_ARGS__);} EXIT_FATAL(flags); } while (false)
| ^~~~~~~~~~~
event.c:235:24: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 6 has type ‘long long unsigned int’ [-Wformat=]
235 | dmsg(D_EVENT_WAIT, "WE_CTL n=%d ev=%p rwflags=0x%04x arg=" ptr_format,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
239 | (ptr_type)arg);
| ~~~~~~~~~~~~~
| |
| long long unsigned int--- src/openvpn/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/common.h +1 -1
@@ -44,7 +44,7 @@ typedef int interval_t;* Printf formats for special types */ #ifdef _WIN64 -#define ptr_format "0x%I64x" +#define ptr_format "0x%016" PRIx64#else #define ptr_format "0x%08lx"#endif
Signature · 1 line
2.26.3
Re: [Openvpn-devel] [PATCH 1/3] windows: use appropriate and portable format specifier for 64bit pointer
Am 01.05.21 um 15:06 schrieb Antonio Quartulli:
Quoted 8 lines
From: Antonio Quartulli <[email protected]...>
To print a 64bit poiner,
fprintf()must be provided with the appropriate format specifier.The most portable in this case is PRIx64, which is redefined accordingly on each platform. It comes from
inttypes.hand it's the recommended way to print a 64bit long hex value.
Yes. I checked at there seem to be no portable integer same size as pointer, so the ifdef with a 64 bit int is okay here.
[Openvpn-devel] [PATCH applied] Re: windows: use appropriate and portable format specifier for 64bit pointer
In reply to Antonio QuartulliYour patch has been applied to the master branch.
commit 396c4e4903fda078536016b7ada97862f713bd94
Author: Antonio Quartulli Date: Sat May 1 15:06:38 2021 +0200
windows: use appropriate and portable format specifier for 64bit pointer
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg22268.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 2/3 windows: define variable only where used
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]...>
warn_used is a static variable but that is used only under certain conditions. These conditions do not apply for Windows and therefore mingw is spitting a warning for unused variable.
Move variable declaration inside code block that uses it.
Fixes:
run_command.c: In function ‘openvpn_popen’:
run_command.c:236:17: warning: unused variable ‘warn_shown’ [-Wunused-variable]
236 | static bool warn_shown = false;
| ^~~~~~~~~~--- src/openvpn/run_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/run_command.c +1 -1
@@ -233,11 +233,11 @@ openvpn_popen(const struct argv *a, const struct env_set *es) {struct gc_arena gc =gc_new ();int ret =-1 ; -static bool warn_shown = false;if (a && a->argv[0 ]) {#if defined(ENABLE_FEATURE_EXECVE ) +static bool warn_shown = false;if (script_security () >=SSEC_BUILT_IN ) {const char *cmd = a->argv[0 ];
Signature · 1 line
2.26.3
Re: [Openvpn-devel] [PATCH 2/3] windows: define variable only where used
Am 01.05.21 um 15:06 schrieb Antonio Quartulli:
Quoted 28 lines
From: Antonio Quartulli <[email protected]...>
warn_usedis a static variable but that is used only under certain conditions. These conditions do not apply for Windows and therefore mingw is spitting a warning for unused variable.Move variable declaration inside code block that uses it.
Fixes:
run_command.c: In function ‘openvpn_popen’:
run_command.c:236:17: warning: unused variable ‘warn_shown’ [-Wunused-variable]236 | static bool warn_shown = false; | ^~~~~~~~~~Signed-off-by Antonio Quartulli <[email protected]...>--- src/openvpn/run_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/openvpn/run_command.c +0
-0@@ -233,11 +233,11 @@ openvpn_popen(const struct argv *a, const struct env_set *es) {struct gc_arena gc =gc_new ();
src/openvpn/run_command.c openvpn_popen(const struct argv *a, const struct env_set *es) · line 243
Quoted 10 lines
src/openvpn/run_command.c +1
-1int ret =-1 ; -static bool warn_shown = false;if (a && a->argv[0 ]) {#if defined(ENABLE_FEATURE_EXECVE ) +static bool warn_shown = false;if (script_security () >=SSEC_BUILT_IN ) {const char *cmd = a->argv[0 ];
[Openvpn-devel] [PATCH applied] Re: windows: define variable only where used
In reply to Antonio QuartulliYour patch has been applied to the master branch.
commit 00c36948297654d93174aed1f8244e6e6734e141
Author: Antonio Quartulli Date: Sat May 1 15:06:39 2021 +0200
windows: define variable only where used
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg22265.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 3/3 windows: list all enum values in switch block
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]...>
A switch block in interactive.c is missing the _undo_type_max value of the neum set, thus triggering a compiler warning.
Due to the logic, this value cannot really be assigned to the variable being examinated, however, add the missing enum value to silence the warning.
Fixes:
interactive.c: In function ‘Undo’:
interactive.c:1561:13: warning: enumeration value ‘_undo_type_max’ not handled in switch [-Wswitch]
1561 | switch (type)
| ^~~~~~--- src/openvpnserv/interactive.c | 3 +++ 1 file changed, 3 insertions(+)
src/openvpnserv/interactive.c +3 -0
@@ -1594,6 +1594,9 @@ Undo(undo_lists_t *lists) interface_data->metric_v6); }break ; +case _undo_type_max: +/* unreachable */ +break ; }/* Remove from the list and free memory */
Signature · 1 line
2.26.3
Re: [Openvpn-devel] [PATCH 3/3] windows: list all enum values in switch block
Am 01.05.21 um 15:06 schrieb Antonio Quartulli:
Quoted 9 lines
From: Antonio Quartulli <[email protected]...>
A switch block in
interactive.cis missing the_undo_type_maxvalue of the neum set, thus triggering a compiler warning.Due to the logic, this value cannot really be assigned to the variable being examinated, however, add the missing enum value to silence the warning.
Quoted 8 lines
Fixes:
interactive.c: In function ‘Undo’:
interactive.c:1561:13: warning: enumeration value ‘_undo_type_max’ not handled in switch [-Wswitch]1561 | switch (type) | ^~~~~~
[Openvpn-devel] [PATCH applied] Re: windows: list all enum values in switch block
In reply to Antonio QuartulliYour patch has been applied to the master branch.
commit f20c377c65f499595939f8a0910f7d7b062b6894
Author: Antonio Quartulli Date: Sat May 1 15:06:40 2021 +0200
windows: list all enum values in switch block
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg22267.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering