From patchwork Tue Jul 27 04:37:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 1889 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director13.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id ICmABAciAGEpaAAAIUCqbw (envelope-from ) for ; Tue, 27 Jul 2021 11:11:03 -0400 Received: from proxy2.mail.ord1d.rsapps.net ([172.30.191.6]) by director13.mail.ord1d.rsapps.net with LMTP id GBRhBAciAGF8LgAA91zNiA (envelope-from ) for ; Tue, 27 Jul 2021 11:11:03 -0400 Received: from smtp16.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.ord1d.rsapps.net with LMTPS id yHwvBAciAGHnfgAAfawv4w (envelope-from ) for ; Tue, 27 Jul 2021 11:11:03 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp16.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: dac345f8-eeec-11eb-ba80-525400ca3ad5-1-1 Received: from [216.105.38.7] ([216.105.38.7:52062] helo=lists.sourceforge.net) by smtp16.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 07/2C-09147-50220016; Tue, 27 Jul 2021 11:11:02 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1m8Oil-0001Qd-12; Tue, 27 Jul 2021 15:10:15 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m8Oij-0001QJ-Cb for openvpn-devel@lists.sourceforge.net; Tue, 27 Jul 2021 15:10:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZAWOw2lxgK1qiqu/bivVuZ3axvYe7Cre3OvSLACImEU=; b=A7UvBjweeZ6bXg0/g+0Gn5LKiY owCxZ26O9fk6eAeMO/uLyY55Vy9CEMbJbBdjeDKQwAC34QpeqGqd1KfJNeaFBa92gx0cCkyGVe2iZ fvoRJGFEeK8EemLyt9XMOb186UIawc90O6tjqvf2uXWUuTFJRiglitwgMU3f6xmUBgvA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=ZAWOw2lxgK1qiqu/bivVuZ3axvYe7Cre3OvSLACImEU=; b=f e8xK5gQSxICEMpmEHxFxTIsLaiUEWh0+nQzf1yM7eEEYTH4uLf0CIZo7PwIP5LTXW+ttsHGeTsJuX avSHov4EjMjFXAlXYUiyL/TTMDn1Rdn0G1Ux7oiH7t28j5dBJXBm1C/trGt0703PKIofqw/QDg49P FYG8NiUhFfiUYILU=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1m8Oic-0003Uz-RC for openvpn-devel@lists.sourceforge.net; Tue, 27 Jul 2021 15:10:13 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.15.2/8.14.9) with ESMTP id 16REbg5d029087 for ; Tue, 27 Jul 2021 16:37:42 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.15.2/8.14.9/Submit) id 16REbgds029086 for openvpn-devel@lists.sourceforge.net; Tue, 27 Jul 2021 16:37:42 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 27 Jul 2021 16:37:41 +0200 Message-Id: <20210727143741.29039-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1m8Oic-0003Uz-RC Subject: [Openvpn-devel] [PATCH] Use more C99 initialization in add_route/add_route_ipv6(). X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This gets rid of a few #ifdef and also removes the need for commit a11bea18b1c93 (argv is only initialized after the early exit check on RT_DEFINED). Signed-off-by: Gert Doering --- src/openvpn/route.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index e429e8c0..bec5d6ff 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1570,32 +1570,24 @@ add_route(struct route_ipv4 *r, const struct env_set *es, openvpn_net_ctx_t *ctx) { - struct gc_arena gc; - struct argv argv = argv_new(); -#if !defined(TARGET_LINUX) - const char *network; -#if !defined(TARGET_AIX) - const char *netmask; -#endif - const char *gateway; -#endif bool status = false; int is_local_route; if (!(r->flags & RT_DEFINED)) { - argv_free(&argv); return; } + struct argv argv = argv_new(); + struct gc_arena gc; gc_init(&gc); #if !defined(TARGET_LINUX) - network = print_in_addr_t(r->network, 0, &gc); + const char *network = print_in_addr_t(r->network, 0, &gc); #if !defined(TARGET_AIX) - netmask = print_in_addr_t(r->netmask, 0, &gc); + const char *netmask = print_in_addr_t(r->netmask, 0, &gc); #endif - gateway = print_in_addr_t(r->gateway, 0, &gc); + const char *gateway = print_in_addr_t(r->gateway, 0, &gc); #endif is_local_route = local_route(r->network, r->netmask, r->gateway, rgi); @@ -1879,23 +1871,18 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt, openvpn_net_ctx_t *ctx) { struct gc_arena gc; - struct argv argv = argv_new(); - const char *network; - const char *gateway; bool status = false; const char *device = tt->actual_name; -#if defined(TARGET_LINUX) - int metric; -#endif bool gateway_needed = false; if (!(r6->flags & RT_DEFINED) ) { - argv_free(&argv); return; } + struct argv argv = argv_new(); + #ifndef _WIN32 if (r6->iface != NULL) /* vpn server special route */ { @@ -1910,9 +1897,8 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt, gc_init(&gc); route_ipv6_clear_host_bits(r6); - - network = print_in6_addr( r6->network, 0, &gc); - gateway = print_in6_addr( r6->gateway, 0, &gc); + const char *network = print_in6_addr( r6->network, 0, &gc); + const char *gateway = print_in6_addr( r6->gateway, 0, &gc); #if defined(TARGET_DARWIN) \ || defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) \ @@ -1963,7 +1949,7 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt, } #if defined(TARGET_LINUX) - metric = -1; + int metric = -1; if ((r6->flags & RT_METRIC_DEFINED) && (r6->metric > 0)) { metric = r6->metric;