From patchwork Sun Apr 19 13:51:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4899 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:66c6:b0:84a:48f:a1fd with SMTP id x6csp1105586mal; Sun, 19 Apr 2026 06:51:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AFNElJ/qBXf6rEMF+Lzh0U37th3YhC+aaRCY3Wim9JzMpYzIPgQ7OE+XHiY9CRoPRyClzwLveuGD2X0vaPQ=@openvpn.net X-Received: by 2002:a05:6808:1522:b0:471:d846:86e2 with SMTP id 5614622812f47-4799c0508c1mr4467896b6e.32.1776606687884; Sun, 19 Apr 2026 06:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776606687; cv=none; d=google.com; s=arc-20240605; b=hZ5Mf9eYhDUy+0wr7jYBUgHy1pGo+9DCmFOPjq4GGCoR7kbgqfw2N70QijM3NCh/YH pjuLxUe6fZ0k8nDkJghHfA2fB2pq0Mhos+Wj0P4ACWxBAxXmz9Nip6tVnuQfWaiOzEAS P6jQP7sZar6/oMcSm0xJKyTTGSErrwk/y5DdK3LArTE1fabxtpsakisDfbxqcCtEvfwl xuZQhu2ycNpPG67rOvY3WQn051IpcZEl7DdtfHepgIWLQInhJ/qmYIsDltLsbnj2YdOR 9KkJis0AH80ugU+/Zus6eFwRRktta6UOMsVL8WkZkkOfzqbcMsr92Zk0goJzjXYINcIF huqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=6XRQ/AAqayG3eAXhwqWtgz3aMbZJAO/eW6j8E/eaygY=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=HRBwAmNXTuey1dZGtDS6BHmuji3vufApWFDg8xQ4y8IWRMvFZ3w3IICVgIDDPWjcJU oJXKTWZXjlAT65U1BqdqBW0UDB5vgtwKifG+ENSDi8aXkhI3tPHtKMsQmMwidRsqys4E xAccW7z5QIsscKIFgWMBUBhoc+BQW0dQ43nSCjDoLcKv7gGLah7vNCQssdCQq09pK0ZD +0nF7rBXavJ1qfrALf/S9ndmQyJb9LoL906XOCu/B6sIZ2ekihTEJntinEYnD0ATROJF +Q11iUyYoKXFYJHpUcx909mDCz/5eMzT+EVQ9wWo9td3PKAMZz66cNwWqj5KnV8bedx6 mkeg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=EZi8PLlx; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iSsXkHNz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Yo0F20pl; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-42b9ad9d4c9si5897399fac.248.2026.04.19.06.51.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Apr 2026 06:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=EZi8PLlx; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iSsXkHNz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Yo0F20pl; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6XRQ/AAqayG3eAXhwqWtgz3aMbZJAO/eW6j8E/eaygY=; b=EZi8PLlxpqLiH5VCGkorocEFmr 6yNJp9JKnTX6YepAlRE6WPl1jDvetzAefAkGpBFBGXBjyAj4zZdiaeNzIOYCshSeGzHFHsSPv76ub 5MqOKDpnifH/ZgBgX9yP2xVpm7h7NNljiY5JuizId5yZVrPE04HJpL7TaYJHDegzrZcc=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wESYX-0003mc-AF; Sun, 19 Apr 2026 13:51:25 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wESYW-0003mV-Nr for openvpn-devel@lists.sourceforge.net; Sun, 19 Apr 2026 13:51:24 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=G9q6WV8jfdnNpYxSiVKCWciM6JeoQKRghfPvxqf7dcs=; b=iSsXkHNziUvNK9TEH3YCjZ2EcA UEopfNssEx4haiAzxj+IiAfZ0/4PPehiMHvuA0iplUYnr5smFNvffBmI+CMyojf4pjyZ/KMsLogtI UbVU0FRrH3kMWDCoGmaY30h6XOiaSvYBzKacHkEPdBU2qSD+hC3mWzl6QGc3MuVACjJI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=G9q6WV8jfdnNpYxSiVKCWciM6JeoQKRghfPvxqf7dcs=; b=Yo0F20plfPu8bgr3v4icPVwVSR fs8DCJR+dpidCMz7fVqyQMILA/L0UWiixrFmsANxM+PukZ3pO6KIkHqzsVoQpos/L9w1pwGn8Grmh OHGa+JjgTYP2rm1fzBvSZEIGiFkqsIRZ+exE394gkS9AE96kiuIDJAB4sbpe1BnNrcaI=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wESYV-0000n7-Ny for openvpn-devel@lists.sourceforge.net; Sun, 19 Apr 2026 13:51:24 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 63JDpHEQ022186 for ; Sun, 19 Apr 2026 15:51:17 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 63JDpHC2022185 for openvpn-devel@lists.sourceforge.net; Sun, 19 Apr 2026 15:51:17 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sun, 19 Apr 2026 15:51:11 +0200 Message-ID: <20260419135116.22170-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Frank Lichtenheld These are all already proven to be true by surrounding code. Identified by cppcheck. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1wESYV-0000n7-Ny Subject: [Openvpn-devel] [PATCH v3] Remove various redundant conditionals 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 X-GMAIL-THRID: =?utf-8?q?1862907134484878754?= X-GMAIL-MSGID: =?utf-8?q?1862907134484878754?= From: Frank Lichtenheld These are all already proven to be true by surrounding code. Identified by cppcheck. Change-Id: Iacf06c113e8db5b7c78270f361ee76938ef1db47 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1613 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1613 This mail reflects revision 3 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index c22a2a4..2a3023c 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -1625,10 +1625,7 @@ } else { - if (p[1]) - { - man_state(man, p[1]); - } + man_state(man, p[1]); if (p[2]) { man_state(man, p[2]); @@ -2542,7 +2539,7 @@ { buffer_list_advance(man->connection.out, sent); } - else if (sent < 0) + else { if (man_io_error(man, "send")) { diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index fe210ee..06e3758 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -1837,7 +1837,7 @@ { msg(M_INFO, "PUSH: No NCP or OCC cipher data received from peer."); - if (o->enable_ncp_fallback && !tls_multi->remote_ciphername) + if (o->enable_ncp_fallback) { msg(M_INFO, "Using data channel cipher '%s' since " diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 70af6d2..0c2866c 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -5304,7 +5304,7 @@ struct dns_server *server = dns_server_get(&options->dns_options.servers, priority, &options->dns_options.gc); - if (streq(p[3], "address") && p[4]) + if (streq(p[3], "address")) { for (int i = 4; p[i]; ++i) { diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c index 3a6b272..9fa9363 100644 --- a/src/openvpn/platform.c +++ b/src/openvpn/platform.c @@ -572,7 +572,7 @@ close(fd); return retfname; } - else if (fd == -1 && errno != EEXIST) + else if (errno != EEXIST) { /* Something else went wrong, no need to retry. */ msg(M_WARN | M_ERRNO, "Could not create temporary file '%s'", retfname); diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index d44f25f..99df49c 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -895,7 +895,7 @@ { /* Must have at least three lines. further lines are ignored for * forward compatibility */ - if (!lines->head || !lines->head->next || !lines->head->next->next) + if (!lines->head->next || !lines->head->next->next) { msg(M_WARN, "auth pending control file is not at least " "three lines long."); diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 4268214..473a8d3 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -486,7 +486,7 @@ sud->directory = data; len = wcslen(sud->directory) + 1; size -= len; - if (size <= 0) + if (size == 0) { MsgToEventLog(M_ERR, L"Startup data ends at working directory"); ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event); @@ -496,7 +496,7 @@ sud->options = sud->directory + len; len = wcslen(sud->options) + 1; size -= len; - if (size <= 0) + if (size == 0) { MsgToEventLog(M_ERR, L"Startup data ends at command line options"); ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);