Fix various compiler warnings
PATCH 1/1 Fix various compiler warnings
From: Lev Stipakov <[email protected]...>
This patch fixes "unused variable/unreferenced format parameter" warnings in different places, kudos to Visual Studio compiler for discoveing some of those.
--- src/openvpn/forward.c | 2 +- src/openvpn/init.c | 2 +- src/openvpn/init.h | 2 +- src/openvpn/mtcp.c | 2 +- src/openvpn/mudp.c | 2 +- src/openvpn/multi.c | 28 +++++++++++++--------------- src/openvpn/multi.h | 8 ++++---- src/openvpn/openvpn.c | 2 +- src/openvpn/tun.c | 11 ++++------- src/openvpn/tun.h | 2 +- src/openvpn/win32.c | 3 +-- 11 files changed, 29 insertions(+), 35 deletions(-)
src/openvpn/forward.c +1 -1
@@ -1251,7 +1251,7 @@ read_incoming_tun(struct context *c) c->c2.buf = c->c2.buffers->read_tun_buf;#ifdef TUN_PASS_BUFFER -read_tun_buffered (c->c1.tuntap, &c->c2.buf,MAX_RW_SIZE_TUN (&c->c2.frame)); +read_tun_buffered (c->c1.tuntap, &c->c2.buf);#else ASSERT (buf_init (&c->c2.buf,FRAME_HEADROOM (&c->c2.frame)));ASSERT (buf_safe (&c->c2.buf,MAX_RW_SIZE_TUN (&c->c2.frame)));
src/openvpn/init.c +1 -1
@@ -3858,7 +3858,7 @@ init_management_callback_p2p(struct context *c)#ifdef ENABLE_MANAGEMENT void -init_management (struct context *c) +init_management (void ) {if (!management) {
src/openvpn/init.h +1 -1
@@ -119,7 +119,7 @@ void initialization_sequence_completed(struct context *c, const unsigned int fla#ifdef ENABLE_MANAGEMENT -void init_management (struct context *c); +void init_management (void );bool open_management (struct context *c);
src/openvpn/mtcp.c +1 -1
@@ -834,7 +834,7 @@ tunnel_server_tcp(struct context *top)#endif /* shut down management interface */ -uninit_management_callback_multi (&multi); +uninit_management_callback_multi ();/* save ifconfig-pool */ multi_ifconfig_pool_persist (&multi, true);
src/openvpn/mudp.c +1 -1
@@ -362,7 +362,7 @@ tunnel_server_udp_single_threaded(struct context *top)#endif /* shut down management interface */ -uninit_management_callback_multi (&multi); +uninit_management_callback_multi ();/* save ifconfig-pool */ multi_ifconfig_pool_persist (&multi, true);
src/openvpn/multi.c +13 -15
@@ -557,8 +557,7 @@ setenv_stats(struct context *c) }static void -multi_client_disconnect_setenv (struct multi_context *m, -struct multi_instance *mi) +multi_client_disconnect_setenv (struct multi_instance *mi) {/* setenv client real IP address */ setenv_trusted (mi->context.c2.es,get_link_socket_info (&mi->context));
@@ -571,13 +570,12 @@ multi_client_disconnect_setenv(struct multi_context *m, }static void -multi_client_disconnect_script (struct multi_context *m, -struct multi_instance *mi) +multi_client_disconnect_script (struct multi_instance *mi) {if ((mi->context.c2.context_auth ==CAS_SUCCEEDED && mi->connection_established_flag) || mi->context.c2.context_auth ==CAS_PARTIAL ) { -multi_client_disconnect_setenv (m, mi); +multi_client_disconnect_setenv (mi);if (plugin_defined (mi->context.plugins,OPENVPN_PLUGIN_CLIENT_DISCONNECT )) {
@@ -684,7 +682,7 @@ multi_close_instance(struct multi_context *m,set_cc_config (mi,NULL );#endif -multi_client_disconnect_script (m, mi); +multi_client_disconnect_script (mi);if (mi->did_open_context) {
@@ -1112,7 +1110,7 @@ multi_learn_addr(struct multi_context *m,if (oldroute)/* route already exists? */ { -if (route_quota_test (m, mi) &&learn_address_script (m, mi,"update" , &newroute->addr)) +if (route_quota_test (mi) &&learn_address_script (m, mi,"update" , &newroute->addr)) { learn_succeeded = true; owner = mi;
@@ -1129,7 +1127,7 @@ multi_learn_addr(struct multi_context *m, }else { -if (route_quota_test (m, mi) &&learn_address_script (m, mi,"add" , &newroute->addr)) +if (route_quota_test (mi) &&learn_address_script (m, mi,"add" , &newroute->addr)) { learn_succeeded = true; owner = mi;
@@ -1579,7 +1577,7 @@ multi_select_virtual_addr(struct multi_context *m, struct multi_instance *mi)* Set virtual address environmental variables. */ static void -multi_set_virtual_addr_env (struct multi_context *m,struct multi_instance *mi) +multi_set_virtual_addr_env (struct multi_instance *mi) {setenv_del (mi->context.c2.es,"ifconfig_pool_local_ip" );setenv_del (mi->context.c2.es,"ifconfig_pool_remote_ip" );
@@ -1658,7 +1656,7 @@ multi_client_connect_post(struct multi_context *m,* directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }
@@ -1702,7 +1700,7 @@ multi_client_connect_post_plugin(struct multi_context *m,* directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }
@@ -1742,7 +1740,7 @@ multi_client_connect_mda(struct multi_context *m,* directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }
@@ -1761,7 +1759,7 @@ multi_client_connect_setenv(struct multi_context *m,setenv_trusted (mi->context.c2.es,get_link_socket_info (&mi->context));/* setenv client virtual IP address */ -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi);/* setenv connection time */ {
@@ -2936,7 +2934,7 @@ multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_*/ void -route_quota_exceeded (const struct multi_context *m,const struct multi_instance *mi) +route_quota_exceeded (const struct multi_instance *mi) {struct gc_arena gc =gc_new (); msg(D_ROUTE_QUOTA, "MULTI ROUTE: route quota (%d) exceeded for %s (see --max-routes-per-client option)",
@@ -3373,7 +3371,7 @@ init_management_callback_multi(struct multi_context *m) }void -uninit_management_callback_multi (struct multi_context *m) +uninit_management_callback_multi (void ) {uninit_management_callback (); }
src/openvpn/multi.h +4 -4
@@ -346,7 +346,7 @@ void multi_close_instance_on_signal(struct multi_context *m, struct multi_instanvoid init_management_callback_multi (struct multi_context *m); -void uninit_management_callback_multi (struct multi_context *m); +void uninit_management_callback_multi (void );#ifdef ENABLE_ASYNC_PUSH
@@ -403,7 +403,7 @@ multi_process_outgoing_link_pre(struct multi_context *m)* Per-client route quota management */ -void route_quota_exceeded (const struct multi_context *m,const struct multi_instance *mi); +void route_quota_exceeded (const struct multi_instance *mi);static inline void route_quota_inc (struct multi_instance *mi)
@@ -419,11 +419,11 @@ route_quota_dec(struct multi_instance *mi)/* can we add a new route? */ static inline bool -route_quota_test (const struct multi_context *m,const struct multi_instance *mi) +route_quota_test (const struct multi_instance *mi) {if (mi->route_count >= mi->context.options.max_routes_per_client) { -route_quota_exceeded (m, mi); +route_quota_exceeded (mi);return false; }else
src/openvpn/openvpn.c +1 -1
@@ -199,7 +199,7 @@ openvpn_main(int argc, char *argv[])#ifdef ENABLE_MANAGEMENT /* initialize management subsystem */ -init_management (&c); +init_management ();#endif /* initialize options to default state */
src/openvpn/tun.c +4 -7
@@ -4867,7 +4867,6 @@ void ipconfig_register_dns(const struct env_set *es) {struct argv argv =argv_new (); -bool status;const char err[] ="ERROR: Windows ipconfig command failed" ;msg (D_TUNTAP_INFO ,"Start ipconfig commands for register-dns..." );
@@ -4877,14 +4876,14 @@ ipconfig_register_dns(const struct env_set *es)get_win_sys_path (), WIN_IPCONFIG_PATH_SUFFIX);argv_msg (D_TUNTAP_INFO , &argv); - status =openvpn_execve_check (&argv, es,0 , err); +openvpn_execve_check (&argv, es,0 , err);argv_reset (&argv);argv_printf (&argv,"%s%sc /registerdns" ,get_win_sys_path (),WIN_IPCONFIG_PATH_SUFFIX );argv_msg (D_TUNTAP_INFO , &argv); - status =openvpn_execve_check (&argv, es,0 , err); +openvpn_execve_check (&argv, es,0 , err);argv_reset (&argv);netcmd_semaphore_release ();
@@ -5178,8 +5177,7 @@ netsh_ifconfig(const struct tuntap_options *to, }static void -netsh_enable_dhcp (const struct tuntap_options *to, -const char *actual_name) +netsh_enable_dhcp (const char *actual_name) {struct argv argv =argv_new ();
@@ -5199,7 +5197,6 @@ netsh_enable_dhcp(const struct tuntap_options *to,static bool service_enable_dhcp (const struct tuntap *tt) { -DWORD len;bool ret = false;ack_message_t ack;struct gc_arena gc =gc_new ();
@@ -5720,7 +5717,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun }else { -netsh_enable_dhcp (&tt->options, tt->actual_name); +netsh_enable_dhcp (tt->actual_name); } } dhcp_masq = true;
src/openvpn/tun.h +1 -1
@@ -457,7 +457,7 @@ tun_write_win32(struct tuntap *tt, struct buffer *buf) }static inline int -read_tun_buffered (struct tuntap *tt,struct buffer *buf,int maxsize) +read_tun_buffered (struct tuntap *tt,struct buffer *buf) {return tun_finalize (tt->hand, &tt->reads, buf); }
src/openvpn/win32.c +1 -2
@@ -685,11 +685,10 @@ win32_pause(struct win32_signal *ws) {if (ws->mode ==WSO_MODE_CONSOLE &&HANDLE_DEFINED (ws->in.read)) { -int status;msg (M_INFO |M_NOPREFIX ,"Press any key to continue..." );do { - status =WaitForSingleObject (ws->in.read,INFINITE ); +WaitForSingleObject (ws->in.read,INFINITE ); }while (!win32_keyboard_get (ws)); } }
Signature · 1 line
2.7.4
Hi,
Congratulations! 518 left to go. 😝
I believe MSVC warning level 3 is a bit too high for a code that was not developed in MSVC or even with MSVC in mind. I lowered it to level 1, and about 8 of interesting warnings remained out of all the warning noise. Maybe we should address those too, then raise to warning level 2 etc.
Regards,
Simon
Quoted 382 lines
-----Original Message-----
From: Lev Stipakov <[email protected]...>
Sent: Monday, October 8, 2018 12:47 PM
To: [email protected]
Subject: [Openvpn-devel] [PATCH] Fix various compiler warningsFrom: Lev Stipakov <[email protected]...>
This patch fixes "unused variable/unreferenced format parameter" warnings in different places, kudos to Visual Studio compiler for discoveing some of those.
Signed-off-by Lev Stipakov <[email protected]...>--- src/openvpn/forward.c | 2 +- src/openvpn/init.c | 2 +- src/openvpn/init.h | 2 +- src/openvpn/mtcp.c | 2 +- src/openvpn/mudp.c | 2 +- src/openvpn/multi.c | 28 +++++++++++++--------------- src/openvpn/multi.h | 8 ++++---- src/openvpn/openvpn.c | 2 +- src/openvpn/tun.c | 11 ++++------- src/openvpn/tun.h | 2 +- src/openvpn/win32.c | 3 +-- 11 files changed, 29 insertions(+), 35 deletions(-)src/openvpn/forward.c +1
-1@@ -1251,7 +1251,7 @@ read_incoming_tun(struct context *c) c->c2.buf = c->c2.buffers->read_tun_buf;#ifdef TUN_PASS_BUFFER -read_tun_buffered (c->c1.tuntap, &c->c2.buf,MAX_RW_SIZE_TUN (&c- >c2.frame)); +read_tun_buffered (c->c1.tuntap, &c->c2.buf);#else ASSERT (buf_init (&c->c2.buf,FRAME_HEADROOM (&c->c2.frame)));ASSERT(buf_safe(&c->c2.buf, MAX_RW_SIZE_TUN(&c->c2.frame)));src/openvpn/init.c +1
-1@@ -3858,7 +3858,7 @@ init_management_callback_p2p(struct context *c)#ifdef ENABLE_MANAGEMENT void -init_management (struct context *c) +init_management (void ) {if (!management) {src/openvpn/init.h +0
-0@@ -119,7 +119,7 @@ void initialization_sequence_completed(structcontext *c, const unsigned int fla
#ifdef
ENABLE_MANAGEMENTsrc/openvpn/init.h +1
-1-void init_management (struct context *c); +void init_management (void );bool open_management (struct context *c);src/openvpn/mtcp.c +1
-1@@ -834,7 +834,7 @@ tunnel_server_tcp(struct context *top)#endif /* shut down management interface */ -uninit_management_callback_multi (&multi); +uninit_management_callback_multi ();/* save ifconfig-pool */ multi_ifconfig_pool_persist (&multi, true);src/openvpn/mudp.c +1
-1@@ -362,7 +362,7 @@ tunnel_server_udp_single_threaded(struct context *top)#endif /* shut down management interface */ -uninit_management_callback_multi (&multi); +uninit_management_callback_multi ();/* save ifconfig-pool */ multi_ifconfig_pool_persist(&multi, true);src/openvpn/multi.c +1
-2@@ -557,8 +557,7 @@ setenv_stats(struct context *c) }static void -multi_client_disconnect_setenv (struct multi_context *m, -struct multi_instance *mi) +multi_client_disconnect_setenv (struct multi_instance *mi) {/* setenv client real IP address */ setenv_trusted(mi->context.c2.es, get_link_socket_info(&mi-Quoted 1 line
context));
src/openvpn/multi.c +2
-3@@ -571,13 +570,12 @@ multi_client_disconnect_setenv(struct multi_context *m, }static void -multi_client_disconnect_script (struct multi_context *m, -struct multi_instance *mi) +multi_client_disconnect_script (struct multi_instance *mi) {if ((mi->context.c2.context_auth ==CAS_SUCCEEDED && mi- >connection_established_flag) || mi->context.c2.context_auth ==CAS_PARTIAL ) { -multi_client_disconnect_setenv (m, mi); +multi_client_disconnect_setenv (mi);if (plugin_defined(mi->context.plugins, OPENVPN_PLUGIN_CLIENT_DISCONNECT)) {src/openvpn/multi.c +2
-2@@ -684,7 +682,7 @@ multi_close_instance(struct multi_context *m,set_cc_config (mi,NULL );#endif -multi_client_disconnect_script (m, mi); +multi_client_disconnect_script (mi);if (mi->did_open_context) {@@ -1112,7 +1110,7 @@ multi_learn_addr(struct multi_context *m,if (oldroute)/* route already exists? */ { -if (route_quota_test (m, mi) &&learn_address_script (m, mi, "update", &newroute->addr)) +if (route_quota_test (mi) &&learn_address_script (m, mi,"update" , &newroute->addr)) {learn_succeeded = true; owner = mi;src/openvpn/multi.c +1
-1@@ -1129,7 +1127,7 @@ multi_learn_addr(struct multi_context *m, }else { -if (route_quota_test (m, mi) &&learn_address_script (m, mi, "add", &newroute->addr)) +if (route_quota_test (mi) &&learn_address_script (m, mi,"add" , &newroute->addr)) {learn_succeeded = true; owner = mi;src/openvpn/multi.c +1
-1@@ -1579,7 +1577,7 @@ multi_select_virtual_addr(struct multi_context *m,struct multi_instance *mi) * Set virtual address environmental variables. */ static void -multi_set_virtual_addr_env (struct multi_context *m,struct multi_instance *mi) +multi_set_virtual_addr_env(struct multi_instance *mi) {setenv_del(mi->context.c2.es, "ifconfig_pool_local_ip"); setenv_del(mi->context.c2.es, "ifconfig_pool_remote_ip");src/openvpn/multi.c +4
-4@@ -1658,7 +1656,7 @@ multi_client_connect_post(struct multi_context *m,* directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }@@ -1702,7 +1700,7 @@ multi_client_connect_post_plugin(structmulti_context *m, * directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }@@ -1742,7 +1740,7 @@ multi_client_connect_mda(struct multi_context *m,* directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }@@ -1761,7 +1759,7 @@ multi_client_connect_setenv(struct multi_context *m,setenv_trusted (mi->context.c2.es,get_link_socket_info (&mi- >context));/* setenv client virtual IP address */ -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi);/* setenv connection time */ {src/openvpn/multi.c +0
-0@@ -2936,7 +2934,7 @@ multi_process_drop_outgoing_tun(struct
multi_context*m, const unsigned intmpp_
*/void
-route_quota_exceeded(const structmulti_context*m, const structmulti_instance*mi)
+route_quota_exceeded(const structmulti_instance*mi)
{
structgc_arenagc =gc_new();
msg(D_ROUTE_QUOTA, "MULTI ROUTE: route quota (%d) exceeded for %s
(see --max-routes-per-client option)",src/openvpn/multi.c +1
-1@@ -3373,7 +3371,7 @@ init_management_callback_multi(struct multi_context *m) }void -uninit_management_callback_multi (struct multi_context *m) +uninit_management_callback_multi (void ) {uninit_management_callback ();}
src/openvpn/multi.h +0
-0@@ -346,7 +346,7 @@ void multi_close_instance_on_signal(struct
multi_context*m, structmulti_instanvoid
init_management_callback_multi(struct multi_context *m);src/openvpn/multi.h +2
-2-void uninit_management_callback_multi (struct multi_context *m); +void uninit_management_callback_multi (void );#ifdef ENABLE_ASYNC_PUSH @@ -403,7 +403,7 @@ multi_process_outgoing_link_pre(struct multi_context*m) * Per-client route quota management */ -void route_quota_exceeded (const struct multi_context *m,const struct multi_instance *mi); +void route_quota_exceeded (const struct multi_instance *mi);static inline void
route_quota_inc(struct multi_instance *mi)src/openvpn/multi.h +2
-2@@ -419,11 +419,11 @@ route_quota_dec(struct multi_instance *mi)/* can we add a new route? */ static inline bool -route_quota_test (const struct multi_context *m,const struct multi_instance *mi) +route_quota_test(const struct multi_instance *mi) {if (mi->route_count >= mi->context.options.max_routes_per_client) { -route_quota_exceeded (m, mi); +route_quota_exceeded (mi);return false; }else
src/openvpn/openvpn.c +1
-1@@ -199,7 +199,7 @@ openvpn_main(int argc, char *argv[])#ifdef ENABLE_MANAGEMENT /* initialize management subsystem */ -init_management (&c); +init_management ();#endif /* initialize options to default state */ src/openvpn/tun.c +3
-6@@ -4867,7 +4867,6 @@ void ipconfig_register_dns(const struct env_set *es) {struct argv argv =argv_new (); -bool status;const char err[] ="ERROR: Windows ipconfig command failed" ;msg (D_TUNTAP_INFO ,"Start ipconfig commands for register-dns..." );@@ -4877,14 +4876,14 @@ ipconfig_register_dns(const struct env_set *es)get_win_sys_path (), WIN_IPCONFIG_PATH_SUFFIX);argv_msg (D_TUNTAP_INFO , &argv); - status =openvpn_execve_check (&argv, es,0 , err); +openvpn_execve_check (&argv, es,0 , err);argv_reset (&argv);argv_printf (&argv,"%s%sc /registerdns" ,get_win_sys_path (),WIN_IPCONFIG_PATH_SUFFIX );argv_msg (D_TUNTAP_INFO , &argv); - status =openvpn_execve_check (&argv, es,0 , err); +openvpn_execve_check (&argv, es,0 , err);argv_reset (&argv);netcmd_semaphore_release ();@@ -5178,8 +5177,7 @@ netsh_ifconfig(const struct tuntap_options *to, }static void -netsh_enable_dhcp (const struct tuntap_options *to, -const char *actual_name) +netsh_enable_dhcp (const char *actual_name) {struct argv argv =argv_new ();@@ -5199,7 +5197,6 @@ netsh_enable_dhcp(const struct tuntap_options *to,static bool service_enable_dhcp (const struct tuntap *tt) { -DWORD len;bool ret = false;ack_message_t ack;struct gc_arena gc =gc_new ();@@ -5720,7 +5717,7 @@ open_tun(const char *dev, const char *dev_type,const char
*dev_node, struct tun} else {src/openvpn/tun.c +1
-1-netsh_enable_dhcp (&tt->options, tt->actual_name); +netsh_enable_dhcp (tt->actual_name); } } dhcp_masq = true;src/openvpn/tun.h +1
-1@@ -457,7 +457,7 @@ tun_write_win32(struct tuntap *tt, struct buffer *buf) }static inline int -read_tun_buffered (struct tuntap *tt,struct buffer *buf,int maxsize) +read_tun_buffered (struct tuntap *tt,struct buffer *buf) {return tun_finalize (tt->hand, &tt->reads, buf);}
src/openvpn/win32.c +1
-3@@ -685,11 +685,10 @@ win32_pause(struct win32_signal *ws) {if (ws->mode ==WSO_MODE_CONSOLE &&HANDLE_DEFINED (ws->in.read)) { -int status;msg (M_INFO |M_NOPREFIX ,"Press any key to continue..." );do { - status =WaitForSingleObject (ws->in.read,INFINITE ); +WaitForSingleObject (ws->in.read,INFINITE ); }while (!win32_keyboard_get (ws)); } } --2.7.4
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 7 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
This patch fixes "unused variable/unreferenced format parameter" warnings in different places, kudos to Visual Studio compiler for discoveing some of those.
Signed-off-by Lev Stipakov <[email protected]...>
Quoted 13 lines
--- src/openvpn/forward.c | 2 +- src/openvpn/init.c | 2 +- src/openvpn/init.h | 2 +- src/openvpn/mtcp.c | 2 +- src/openvpn/mudp.c | 2 +- src/openvpn/multi.c | 28 +++++++++++++--------------- src/openvpn/multi.h | 8 ++++---- src/openvpn/openvpn.c | 2 +- src/openvpn/tun.c | 11 ++++------- src/openvpn/tun.h | 2 +- src/openvpn/win32.c | 3 +-- 11 files changed, 29 insertions(+), 35 deletions(-)
I was about to pull this in, based on Simons ACK ... but below is something I think we could do better.
Quoted 14 lines
src/openvpn/multi.c +1
-1@@ -2936,7 +2934,7 @@ multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_*/ void -route_quota_exceeded (const struct multi_context *m,const struct multi_instance *mi) +route_quota_exceeded (const struct multi_instance *mi) {struct gc_arena gc =gc_new (); msg(D_ROUTE_QUOTA, "MULTI ROUTE: route quota (%d) exceeded for %s (see --max-routes-per-client option)",
src/openvpn/multi.c init_management_callback_multi(struct multi_context *m) · line 3377
Quoted 8 lines
src/openvpn/multi.c +1
-1@@ -3373,7 +3371,7 @@ init_management_callback_multi(struct multi_context *m) }void -uninit_management_callback_multi (struct multi_context *m) +uninit_management_callback_multi (void ) {uninit_management_callback (); }
Is there any reasonable reason we keep this simple wrapper function? The users of it is very limited and I struggle to see the value of it. Can't we just wipe this out out? This has been unchanged since the initial BETA21 SVN branch dating back to 2005. I struggle to see us changing anything drastic in this context.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
PATCH v2 1/1 Fix various compiler warnings
From: Lev Stipakov <[email protected]...>
This patch fixes "unused variable/unreferenced format parameter" warnings in different places, kudos to Visual Studio compiler for discoveing some of those.
This also also removes unneeded uninit_management_callback_multi() wrapper.
---
v2: remove unneeded uninit_management_callback_multi() wrapper
src/openvpn/forward.c | 2 +- src/openvpn/init.c | 2 +- src/openvpn/init.h | 2 +- src/openvpn/mtcp.c | 2 +- src/openvpn/mudp.c | 2 +- src/openvpn/multi.c | 32 ++++++++++++-------------------- src/openvpn/multi.h | 9 +++------ src/openvpn/openvpn.c | 2 +- src/openvpn/tun.c | 11 ++++------- src/openvpn/tun.h | 2 +- src/openvpn/win32.c | 3 +-- 11 files changed, 27 insertions(+), 42 deletions(-)
src/openvpn/forward.c +1 -1
@@ -1251,7 +1251,7 @@ read_incoming_tun(struct context *c) c->c2.buf = c->c2.buffers->read_tun_buf;#ifdef TUN_PASS_BUFFER -read_tun_buffered (c->c1.tuntap, &c->c2.buf,MAX_RW_SIZE_TUN (&c->c2.frame)); +read_tun_buffered (c->c1.tuntap, &c->c2.buf);#else ASSERT (buf_init (&c->c2.buf,FRAME_HEADROOM (&c->c2.frame)));ASSERT (buf_safe (&c->c2.buf,MAX_RW_SIZE_TUN (&c->c2.frame)));
src/openvpn/init.c +1 -1
@@ -3919,7 +3919,7 @@ init_management_callback_p2p(struct context *c)#ifdef ENABLE_MANAGEMENT void -init_management (struct context *c) +init_management (void ) {if (!management) {
src/openvpn/init.h +1 -1
@@ -119,7 +119,7 @@ void initialization_sequence_completed(struct context *c, const unsigned int fla#ifdef ENABLE_MANAGEMENT -void init_management (struct context *c); +void init_management (void );bool open_management (struct context *c);
src/openvpn/mtcp.c +1 -1
@@ -834,7 +834,7 @@ tunnel_server_tcp(struct context *top)#endif /* shut down management interface */ -uninit_management_callback_multi (&multi); +uninit_management_callback ();/* save ifconfig-pool */ multi_ifconfig_pool_persist (&multi, true);
src/openvpn/mudp.c +1 -1
@@ -362,7 +362,7 @@ tunnel_server_udp_single_threaded(struct context *top)#endif /* shut down management interface */ -uninit_management_callback_multi (&multi); +uninit_management_callback ();/* save ifconfig-pool */ multi_ifconfig_pool_persist (&multi, true);
src/openvpn/multi.c +12 -20
@@ -557,8 +557,7 @@ setenv_stats(struct context *c) }static void -multi_client_disconnect_setenv (struct multi_context *m, -struct multi_instance *mi) +multi_client_disconnect_setenv (struct multi_instance *mi) {/* setenv client real IP address */ setenv_trusted (mi->context.c2.es,get_link_socket_info (&mi->context));
@@ -571,13 +570,12 @@ multi_client_disconnect_setenv(struct multi_context *m, }static void -multi_client_disconnect_script (struct multi_context *m, -struct multi_instance *mi) +multi_client_disconnect_script (struct multi_instance *mi) {if ((mi->context.c2.context_auth ==CAS_SUCCEEDED && mi->connection_established_flag) || mi->context.c2.context_auth ==CAS_PARTIAL ) { -multi_client_disconnect_setenv (m, mi); +multi_client_disconnect_setenv (mi);if (plugin_defined (mi->context.plugins,OPENVPN_PLUGIN_CLIENT_DISCONNECT )) {
@@ -684,7 +682,7 @@ multi_close_instance(struct multi_context *m,set_cc_config (mi,NULL );#endif -multi_client_disconnect_script (m, mi); +multi_client_disconnect_script (mi);if (mi->did_open_context) {
@@ -1112,7 +1110,7 @@ multi_learn_addr(struct multi_context *m,if (oldroute)/* route already exists? */ { -if (route_quota_test (m, mi) &&learn_address_script (m, mi,"update" , &newroute->addr)) +if (route_quota_test (mi) &&learn_address_script (m, mi,"update" , &newroute->addr)) { learn_succeeded = true; owner = mi;
@@ -1129,7 +1127,7 @@ multi_learn_addr(struct multi_context *m, }else { -if (route_quota_test (m, mi) &&learn_address_script (m, mi,"add" , &newroute->addr)) +if (route_quota_test (mi) &&learn_address_script (m, mi,"add" , &newroute->addr)) { learn_succeeded = true; owner = mi;
@@ -1579,7 +1577,7 @@ multi_select_virtual_addr(struct multi_context *m, struct multi_instance *mi)* Set virtual address environmental variables. */ static void -multi_set_virtual_addr_env (struct multi_context *m,struct multi_instance *mi) +multi_set_virtual_addr_env (struct multi_instance *mi) {setenv_del (mi->context.c2.es,"ifconfig_pool_local_ip" );setenv_del (mi->context.c2.es,"ifconfig_pool_remote_ip" );
@@ -1658,7 +1656,7 @@ multi_client_connect_post(struct multi_context *m,* directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }
@@ -1702,7 +1700,7 @@ multi_client_connect_post_plugin(struct multi_context *m,* directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }
@@ -1742,7 +1740,7 @@ multi_client_connect_mda(struct multi_context *m,* directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr (m, mi); -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi); } }
@@ -1761,7 +1759,7 @@ multi_client_connect_setenv(struct multi_context *m,setenv_trusted (mi->context.c2.es,get_link_socket_info (&mi->context));/* setenv client virtual IP address */ -multi_set_virtual_addr_env (m, mi); +multi_set_virtual_addr_env (mi);/* setenv connection time */ {
@@ -2936,7 +2934,7 @@ multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_*/ void -route_quota_exceeded (const struct multi_context *m,const struct multi_instance *mi) +route_quota_exceeded (const struct multi_instance *mi) {struct gc_arena gc =gc_new (); msg(D_ROUTE_QUOTA, "MULTI ROUTE: route quota (%d) exceeded for %s (see --max-routes-per-client option)",
@@ -3372,12 +3370,6 @@ init_management_callback_multi(struct multi_context *m)#endif /* ifdef ENABLE_MANAGEMENT */ } -void -uninit_management_callback_multi (struct multi_context *m) -{ -uninit_management_callback (); -} -/* * Top level event loop. */
src/openvpn/multi.h +3 -6
@@ -346,9 +346,6 @@ void multi_close_instance_on_signal(struct multi_context *m, struct multi_instanvoid init_management_callback_multi (struct multi_context *m); -void uninit_management_callback_multi (struct multi_context *m); - -#ifdef ENABLE_ASYNC_PUSH /** * Called when inotify event is fired, which happens when acf file is closed or deleted.
@@ -403,7 +400,7 @@ multi_process_outgoing_link_pre(struct multi_context *m)* Per-client route quota management */ -void route_quota_exceeded (const struct multi_context *m,const struct multi_instance *mi); +void route_quota_exceeded (const struct multi_instance *mi);static inline void route_quota_inc (struct multi_instance *mi)
@@ -419,11 +416,11 @@ route_quota_dec(struct multi_instance *mi)/* can we add a new route? */ static inline bool -route_quota_test (const struct multi_context *m,const struct multi_instance *mi) +route_quota_test (const struct multi_instance *mi) {if (mi->route_count >= mi->context.options.max_routes_per_client) { -route_quota_exceeded (m, mi); +route_quota_exceeded (mi);return false; }else
src/openvpn/openvpn.c +1 -1
@@ -199,7 +199,7 @@ openvpn_main(int argc, char *argv[])#ifdef ENABLE_MANAGEMENT /* initialize management subsystem */ -init_management (&c); +init_management ();#endif /* initialize options to default state */
src/openvpn/tun.c +4 -7
@@ -4866,7 +4866,6 @@ void ipconfig_register_dns(const struct env_set *es) {struct argv argv =argv_new (); -bool status;const char err[] ="ERROR: Windows ipconfig command failed" ;msg (D_TUNTAP_INFO ,"Start ipconfig commands for register-dns..." );
@@ -4876,14 +4875,14 @@ ipconfig_register_dns(const struct env_set *es)get_win_sys_path (), WIN_IPCONFIG_PATH_SUFFIX);argv_msg (D_TUNTAP_INFO , &argv); - status =openvpn_execve_check (&argv, es,0 , err); +openvpn_execve_check (&argv, es,0 , err);argv_reset (&argv);argv_printf (&argv,"%s%sc /registerdns" ,get_win_sys_path (),WIN_IPCONFIG_PATH_SUFFIX );argv_msg (D_TUNTAP_INFO , &argv); - status =openvpn_execve_check (&argv, es,0 , err); +openvpn_execve_check (&argv, es,0 , err);argv_reset (&argv);netcmd_semaphore_release ();
@@ -5177,8 +5176,7 @@ netsh_ifconfig(const struct tuntap_options *to, }static void -netsh_enable_dhcp (const struct tuntap_options *to, -const char *actual_name) +netsh_enable_dhcp (const char *actual_name) {struct argv argv =argv_new ();
@@ -5198,7 +5196,6 @@ netsh_enable_dhcp(const struct tuntap_options *to,static bool service_enable_dhcp (const struct tuntap *tt) { -DWORD len;bool ret = false;ack_message_t ack;struct gc_arena gc =gc_new ();
@@ -5719,7 +5716,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun }else { -netsh_enable_dhcp (&tt->options, tt->actual_name); +netsh_enable_dhcp (tt->actual_name); } } dhcp_masq = true;
src/openvpn/tun.h +1 -1
@@ -457,7 +457,7 @@ tun_write_win32(struct tuntap *tt, struct buffer *buf) }static inline int -read_tun_buffered (struct tuntap *tt,struct buffer *buf,int maxsize) +read_tun_buffered (struct tuntap *tt,struct buffer *buf) {return tun_finalize (tt->hand, &tt->reads, buf); }
src/openvpn/win32.c +1 -2
@@ -685,11 +685,10 @@ win32_pause(struct win32_signal *ws) {if (ws->mode ==WSO_MODE_CONSOLE &&HANDLE_DEFINED (ws->in.read)) { -int status;msg (M_INFO |M_NOPREFIX ,"Press any key to continue..." );do { - status =WaitForSingleObject (ws->in.read,INFINITE ); +WaitForSingleObject (ws->in.read,INFINITE ); }while (!win32_keyboard_get (ws)); } }
Signature · 1 line
2.7.4
Am 30.10.18 um 09:53 schrieb Lev Stipakov:
Quoted 9 lines
From: Lev Stipakov <[email protected]...>
This patch fixes "unused variable/unreferenced format parameter" warnings in different places, kudos to Visual Studio compiler for discoveing some of those.
This also also removes unneeded
uninit_management_callback_multi()wrapper.
This looks good to me, compiles and David already give his ACK on the patch and demanded a small change, which has happend, so:
Your patch has been applied to the master and release/2.4 branch.
Why 2.4? Because since this changes the calling convention of quite a number of functions (by removing never-used arguments) I'm fairly sure it will get in the way of future bugfixes that tackle "related code" - and *those* need to go to 2.4. So take this in, even if "refactoring" is normally not done here. But these are very straightforward changes.
commit 91ba1add2f8f231a7ccf4557cdd593547e625723 (master) commit 0c1cc8d65539f5e156866056df9074d47bc3ed4b (release/2.4)
Author: Lev Stipakov Date: Tue Oct 30 10:53:35 2018 +0200
Fix various compiler warnings
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg17855.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering