From: Gert Doering Date: Mon, 7 Nov 2016 21:44:02 +0000 (+0100) Subject: clean up *sig_info handling in link_socket_init_phase2() X-Git-Tag: v2.4_beta1~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=238cd6440312c59353a40a97b3c45d272561457f;p=thirdparty%2Fopenvpn.git clean up *sig_info handling in link_socket_init_phase2() The code was a mix of "assume that it is not NULL" and "check that it is not NULL before using" - it cannot be NULL (due to the single call graph, referencing c->sig with the global context), but for good measure, add an ASSERT() upon function entry and get rid of all the individual checks. Found by Coverity. Signed-off-by: Gert Doering Acked-by: Steffan Karger Message-Id: <1478555042-31299-1-git-send-email-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12931.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 184c7ad9b..18e640973 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -1857,8 +1857,9 @@ link_socket_init_phase2 (struct link_socket *sock, int sig_save = 0; ASSERT (sock); + ASSERT (sig_info); - if (sig_info && sig_info->signal_received) + if (sig_info->signal_received) { sig_save = sig_info->signal_received; sig_info->signal_received = 0; @@ -1879,7 +1880,7 @@ link_socket_init_phase2 (struct link_socket *sock, if (sock->inetd) { phase2_inetd (sock, frame, remote_dynamic, &sig_info->signal_received); - if (sig_info && sig_info->signal_received) + if (sig_info->signal_received) goto done; } @@ -1921,7 +1922,7 @@ link_socket_init_phase2 (struct link_socket *sock, goto done; } - if (sig_info && sig_info->signal_received) + if (sig_info->signal_received) goto done; if (sock->info.proto == PROTO_TCP_SERVER) @@ -1942,7 +1943,7 @@ link_socket_init_phase2 (struct link_socket *sock, if (sock->sd != -1) protect_fd_nonlocal (sock->sd, &sock->info.lsa->actual.dest.addr.sa); #endif - if (sig_info && sig_info->signal_received) + if (sig_info->signal_received) goto done; } @@ -1950,7 +1951,7 @@ link_socket_init_phase2 (struct link_socket *sock, linksock_print_addr(sock); done: - if (sig_save && sig_info) + if (sig_save) { if (!sig_info->signal_received) sig_info->signal_received = sig_save;