Get rid of unused 'bool tuntap_buffer' arguments.
PATCH 1/1 Get rid of unused 'bool tuntap_buffer' arguments.
overlapped_io_init() has a "bool tuntap_buffer" argument which is only passed onwards to alloc_buf_sock_tun(), which does nothing with it.
Remove from both functions.
--- src/openvpn/mtu.c | 3 +-- src/openvpn/mtu.h | 3 +-- src/openvpn/socket.c | 4 ++-- src/openvpn/tun.c | 4 ++-- src/openvpn/win32.c | 5 ++--- src/openvpn/win32.h | 3 +-- 6 files changed, 9 insertions(+), 13 deletions(-)
src/openvpn/mtu.c +1 -2
@@ -42,8 +42,7 @@/* allocate a buffer for socket or tun layer */ void alloc_buf_sock_tun (struct buffer *buf, -const struct frame *frame, -const bool tuntap_buffer) +const struct frame *frame) {/* allocate buffer for overlapped I/O */ *buf =alloc_buf (BUF_SIZE (frame));
src/openvpn/mtu.h +1 -2
@@ -265,8 +265,7 @@ calc_packet_id_size_dc(const struct options *options,* allocate a buffer for socket or tun layer */ void alloc_buf_sock_tun (struct buffer *buf, -const struct frame *frame, -const bool tuntap_buffer); +const struct frame *frame);/* * EXTENDED_SOCKET_ERROR_CAPABILITY functions -- print extra error info
src/openvpn/socket.c +2 -2
@@ -1623,8 +1623,8 @@ static void socket_frame_init(const struct frame *frame, struct link_socket *sock) { #ifdef _WIN32 - overlapped_io_init(&sock->reads, frame, FALSE, false); -overlapped_io_init (&sock->writes, frame, TRUE, false); + overlapped_io_init(&sock->reads, frame, FALSE); +overlapped_io_init (&sock->writes, frame, TRUE); sock->rw_handle.read = sock->reads.overlapped.hEvent; sock->rw_handle.write = sock->writes.overlapped.hEvent;#endif
src/openvpn/tun.c +2 -2
@@ -898,8 +898,8 @@ init_tun_post(struct tuntap *tt,return ; } -overlapped_io_init (&tt->reads, frame, FALSE, true); -overlapped_io_init (&tt->writes, frame, TRUE, true); +overlapped_io_init (&tt->reads, frame, FALSE); +overlapped_io_init (&tt->writes, frame, TRUE); tt->adapter_index =TUN_ADAPTER_INDEX_INVALID ;if (tt->windows_driver ==WINDOWS_DRIVER_WINTUN )
src/openvpn/win32.c +2 -3
@@ -173,8 +173,7 @@ init_security_attributes_allow_all(struct security_attributes *obj)void overlapped_io_init (struct overlapped_io *o,const struct frame *frame, -BOOL event_state, -bool tuntap_buffer)/* if true: tuntap buffer, if false: socket buffer */ +BOOL event_state) {CLEAR (*o);
@@ -186,7 +185,7 @@ overlapped_io_init(struct overlapped_io *o, }/* allocate buffer for overlapped I/O */ -alloc_buf_sock_tun (&o->buf_init, frame, tuntap_buffer); +alloc_buf_sock_tun (&o->buf_init, frame); }void
src/openvpn/win32.h +1 -2
@@ -217,8 +217,7 @@ struct overlapped_io {void overlapped_io_init (struct overlapped_io *o,const struct frame *frame, -BOOL event_state, -bool tuntap_buffer); +BOOL event_state);void overlapped_io_close (struct overlapped_io *o);
Signature · 1 line
2.34.1
PATCH v2 1/1 Get rid of unused 'bool tuntap_buffer' arguments.
overlapped_io_init() has a "bool tuntap_buffer" argument which is only passed onwards to alloc_buf_sock_tun(), which does nothing with it.
Remove from both functions.
While at it, move alloc_buf_sock_tun() from mtu.c to win32.c and make static. It's only ever called from win32.c / overlapped_io_init().
v2:
move alloc_buf_sock_tun() to win32.c
--- src/openvpn/mtu.c | 13 ------------- src/openvpn/mtu.h | 7 ------- src/openvpn/socket.c | 4 ++-- src/openvpn/tun.c | 4 ++-- src/openvpn/win32.c | 17 ++++++++++++++--- src/openvpn/win32.h | 3 +-- 6 files changed, 19 insertions(+), 29 deletions(-)
src/openvpn/mtu.c +0 -13
@@ -39,19 +39,6 @@#include "memdbg.h" -/* allocate a buffer for socket or tun layer */ -void -alloc_buf_sock_tun (struct buffer *buf, -const struct frame *frame, -const bool tuntap_buffer) -{ -/* allocate buffer for overlapped I/O */ - *buf =alloc_buf (BUF_SIZE (frame)); -ASSERT (buf_init (buf, frame->buf.headroom)); - buf->len = frame->buf.payload_size; -ASSERT (buf_safe (buf,0 )); -} -unsigned int calc_packet_id_size_dc (const struct options *options,const struct key_type *kt) {
src/openvpn/mtu.h +0 -7
@@ -261,13 +261,6 @@ unsigned int calc_packet_id_size_dc(const struct options *options, const struct key_type *kt); -/* -* allocate a buffer for socket or tun layer -*/ -void alloc_buf_sock_tun (struct buffer *buf, -const struct frame *frame, -const bool tuntap_buffer); -/* * EXTENDED_SOCKET_ERROR_CAPABILITY functions -- print extra error info * on socket errors, such as PMTU size. As of 2003.05.11, only works
src/openvpn/socket.c +2 -2
@@ -1623,8 +1623,8 @@ static void socket_frame_init(const struct frame *frame, struct link_socket *sock) { #ifdef _WIN32 - overlapped_io_init(&sock->reads, frame, FALSE, false); -overlapped_io_init (&sock->writes, frame, TRUE, false); + overlapped_io_init(&sock->reads, frame, FALSE); +overlapped_io_init (&sock->writes, frame, TRUE); sock->rw_handle.read = sock->reads.overlapped.hEvent; sock->rw_handle.write = sock->writes.overlapped.hEvent;#endif
src/openvpn/tun.c +2 -2
@@ -898,8 +898,8 @@ init_tun_post(struct tuntap *tt,return ; } -overlapped_io_init (&tt->reads, frame, FALSE, true); -overlapped_io_init (&tt->writes, frame, TRUE, true); +overlapped_io_init (&tt->reads, frame, FALSE); +overlapped_io_init (&tt->writes, frame, TRUE); tt->adapter_index =TUN_ADAPTER_INDEX_INVALID ;if (tt->windows_driver ==WINDOWS_DRIVER_WINTUN )
src/openvpn/win32.c +14 -3
@@ -170,11 +170,22 @@ init_security_attributes_allow_all(struct security_attributes *obj)return true; } +/* allocate a buffer for socket or tun layer */ +static void +alloc_buf_sock_tun (struct buffer *buf, +const struct frame *frame) +{ +/* allocate buffer for overlapped I/O */ + *buf =alloc_buf (BUF_SIZE (frame)); +ASSERT (buf_init (buf, frame->buf.headroom)); + buf->len = frame->buf.payload_size; +ASSERT (buf_safe (buf,0 )); +} +void overlapped_io_init (struct overlapped_io *o,const struct frame *frame, -BOOL event_state, -bool tuntap_buffer)/* if true: tuntap buffer, if false: socket buffer */ +BOOL event_state) {CLEAR (*o);
@@ -186,7 +197,7 @@ overlapped_io_init(struct overlapped_io *o, }/* allocate buffer for overlapped I/O */ -alloc_buf_sock_tun (&o->buf_init, frame, tuntap_buffer); +alloc_buf_sock_tun (&o->buf_init, frame); }void
src/openvpn/win32.h +1 -2
@@ -217,8 +217,7 @@ struct overlapped_io {void overlapped_io_init (struct overlapped_io *o,const struct frame *frame, -BOOL event_state, -bool tuntap_buffer); +BOOL event_state);void overlapped_io_close (struct overlapped_io *o);
Signature · 1 line
2.34.1
Am 30.01.23 um 17:17 schrieb Gert Doering:
Quoted 11 lines
overlapped_io_init()has a "booltuntap_buffer" argument which is only passed onwards toalloc_buf_sock_tun(), which does nothing with it.Remove from both functions.
While at it, move
alloc_buf_sock_tun()frommtu.ctowin32.cand make static. It's only ever called fromwin32.c/overlapped_io_init().v2:
movealloc_buf_sock_tun()towin32.c
Hi,
Quoted 7 lines · Gert Doering
overlapped_io_init()has a "booltuntap_buffer" argument which is only passed onwards toalloc_buf_sock_tun(), which does nothing with it.Remove from both functions.
While at it, move
alloc_buf_sock_tun()frommtu.ctowin32.cand make static. It's only ever called fromwin32.c/overlapped_io_init().
NAK this.
There are more calls in socket.c, in the non-WIN32 code paths, so v2 breaks Linux compilation (not sure why I overlooked that before).
Need to re-think how I want to clean this up...
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...PATCH v3 1/1 Get rid of unused 'bool tuntap_buffer' arguments.
In reply to Gert Doeringoverlapped_io_init() has a "bool tuntap_buffer" argument which is only passed onwards to alloc_buf_sock_tun(), which does nothing with it.
Remove from both functions.
v2:
move alloc_buf_sock_tun() to win32.c
v3:
leave alloc_buf_sock_tun() where it is, and fix non-WIN32 call from socket.c
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg26099.html
--- src/openvpn/mtu.c | 3 +-- src/openvpn/mtu.h | 3 +-- src/openvpn/socket.c | 8 +++----- src/openvpn/tun.c | 4 ++-- src/openvpn/win32.c | 5 ++--- src/openvpn/win32.h | 3 +-- 6 files changed, 10 insertions(+), 16 deletions(-)
src/openvpn/mtu.c +1 -2
@@ -42,8 +42,7 @@/* allocate a buffer for socket or tun layer */ void alloc_buf_sock_tun (struct buffer *buf, -const struct frame *frame, -const bool tuntap_buffer) +const struct frame *frame) {/* allocate buffer for overlapped I/O */ *buf =alloc_buf (BUF_SIZE (frame));
src/openvpn/mtu.h +1 -2
@@ -265,8 +265,7 @@ calc_packet_id_size_dc(const struct options *options,* allocate a buffer for socket or tun layer */ void alloc_buf_sock_tun (struct buffer *buf, -const struct frame *frame, -const bool tuntap_buffer); +const struct frame *frame);/* * EXTENDED_SOCKET_ERROR_CAPABILITY functions -- print extra error info
src/openvpn/socket.c +3 -5
@@ -1623,8 +1623,8 @@ static void socket_frame_init(const struct frame *frame, struct link_socket *sock) { #ifdef _WIN32 - overlapped_io_init(&sock->reads, frame, FALSE, false); -overlapped_io_init (&sock->writes, frame, TRUE, false); + overlapped_io_init(&sock->reads, frame, FALSE); +overlapped_io_init (&sock->writes, frame, TRUE); sock->rw_handle.read = sock->reads.overlapped.hEvent; sock->rw_handle.write = sock->writes.overlapped.hEvent;#endif
@@ -1637,9 +1637,7 @@ socket_frame_init(const struct frame *frame, struct link_socket *sock) sock->sockflags, sock->info.proto);#else -alloc_buf_sock_tun (&sock->stream_buf_data, - frame, - false); +alloc_buf_sock_tun (&sock->stream_buf_data, frame); stream_buf_init(&sock->stream_buf, &sock->stream_buf_data,
src/openvpn/tun.c +2 -2
@@ -898,8 +898,8 @@ init_tun_post(struct tuntap *tt,return ; } -overlapped_io_init (&tt->reads, frame, FALSE, true); -overlapped_io_init (&tt->writes, frame, TRUE, true); +overlapped_io_init (&tt->reads, frame, FALSE); +overlapped_io_init (&tt->writes, frame, TRUE); tt->adapter_index =TUN_ADAPTER_INDEX_INVALID ;if (tt->windows_driver ==WINDOWS_DRIVER_WINTUN )
src/openvpn/win32.c +2 -3
@@ -173,8 +173,7 @@ init_security_attributes_allow_all(struct security_attributes *obj)void overlapped_io_init (struct overlapped_io *o,const struct frame *frame, -BOOL event_state, -bool tuntap_buffer)/* if true: tuntap buffer, if false: socket buffer */ +BOOL event_state) {CLEAR (*o);
@@ -186,7 +185,7 @@ overlapped_io_init(struct overlapped_io *o, }/* allocate buffer for overlapped I/O */ -alloc_buf_sock_tun (&o->buf_init, frame, tuntap_buffer); +alloc_buf_sock_tun (&o->buf_init, frame); }void
src/openvpn/win32.h +1 -2
@@ -217,8 +217,7 @@ struct overlapped_io {void overlapped_io_init (struct overlapped_io *o,const struct frame *frame, -BOOL event_state, -bool tuntap_buffer); +BOOL event_state);void overlapped_io_close (struct overlapped_io *o);
Signature · 1 line
2.34.1
Am 01.02.23 um 15:15 schrieb Gert Doering:
Quoted 10 lines
overlapped_io_init()has a "booltuntap_buffer" argument which is only passed onwards toalloc_buf_sock_tun(), which does nothing with it.Remove from both functions.
v2:
movealloc_buf_sock_tun()towin32.cv3:
leavealloc_buf_sock_tun()where it is, and fix non-WIN32 call fromsocket.c
This time, it actually compiles on Linux *and* Windows... (GH says so :-) ).
Patch has been applied to the master and release/2.6 branch.
commit 092ceadb762a42a50191e38bd7cf0fe9f6528a59 (master) commit eca101ac4426442c1ad17e6a706d84c7960a8262 (release/2.6)
Author: Gert Doering Date: Wed Feb 1 14:15:18 2023 +0000
Get rid of unused 'bool tuntap_buffer' arguments.
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg26122.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering