| Message ID | 20200717112953.6699-1-arne@rfc2549.org |
|---|---|
| State | Not Applicable |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net> Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id uIq+A+uLEV9MfQAAIUCqbw for <patchwork@openvpn.net>; Fri, 17 Jul 2020 07:30:51 -0400 Received: from proxy3.mail.ord1d.rsapps.net ([172.30.191.6]) by director7.mail.ord1d.rsapps.net with LMTP id EPaHA+uLEV+QYAAAovjBpQ ; Fri, 17 Jul 2020 07:30:51 -0400 Received: from smtp1.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.ord1d.rsapps.net with LMTP id INx9A+uLEV+zQwAA7WKfLA ; Fri, 17 Jul 2020 07:30:51 -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: smtp1.gate.ord1c.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=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: f720523e-c820-11ea-952f-842b2b47c027-1-1 Received: from [216.105.38.7] ([216.105.38.7:57348] helo=lists.sourceforge.net) by smtp1.gate.ord1c.rsapps.net (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id DC/0D-20291-AEB811F5; Fri, 17 Jul 2020 07:30:50 -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 <openvpn-devel-bounces@lists.sourceforge.net>) id 1jwOZB-0005FR-5b; Fri, 17 Jul 2020 11:30:13 +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 <arne@kamera.blinkt.de>) id 1jwOZ4-0005EX-8M for openvpn-devel@lists.sourceforge.net; Fri, 17 Jul 2020 11:30:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding: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=UYjfmirSRndyHF7bRJIIUUXDhMKA5gf2D65+m5dbZCE=; b=jxfMjVi5Ns/9mymZMuIEVT1Bru UrmOpK8V/ZZckWpo1E5Saka1AhCD0qncuDA8WBsNlaYh5Aqy/8FWNKtfeFtwdfF7gqwFYl7ulbqYY JpRNOJzyr2SzNH1znz5BbXBs/+h8rfUZyKZBALKnHpqy293Z4IY4BfjSe2PcaX7XFtdI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding: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=UYjfmirSRndyHF7bRJIIUUXDhMKA5gf2D65+m5dbZCE=; b=jGUeXJDC8Js06nNvU+RD786/Yc AjBTYgoYdwIo4K64bKPq6cuU8q3xEROeH8pZKKd11ynORDEKSJh8hJjqQSdGO2QExaT7g7zRIzvv+ smTuLifnhigjiGOgNU56GltJ2bGen7mjmpiOWQtvg+cDLTj3dK286JEEpwhCg63j1nSU=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jwOYz-007Krw-HX for openvpn-devel@lists.sourceforge.net; Fri, 17 Jul 2020 11:30:06 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from <arne@kamera.blinkt.de>) id 1jwOYr-000KD6-Qe for openvpn-devel@lists.sourceforge.net; Fri, 17 Jul 2020 13:29:53 +0200 Received: (nullmailer pid 6744 invoked by uid 10006); Fri, 17 Jul 2020 11:29:53 -0000 From: Arne Schwabe <arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Fri, 17 Jul 2020 13:29:53 +0200 Message-Id: <20200717112953.6699-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rfc2549.org] 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1jwOYz-007Krw-HX Subject: [Openvpn-devel] [PATCH] Convert cc_check_return to switch/case X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox |
| Series |
[Openvpn-devel] Convert cc_check_return to switch/case
|
|
Commit Message
Arne Schwabe
July 17, 2020, 1:29 a.m. UTC
The return false/return true is the result of
running uncrustify.
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
src/openvpn/multi.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
Comments
On 17/07/2020 13:29, Arne Schwabe wrote: > The return false/return true is the result of > running uncrustify. > > Signed-off-by: Arne Schwabe <arne@rfc2549.org> > --- > src/openvpn/multi.c | 24 +++++++++--------------- > 1 file changed, 9 insertions(+), 15 deletions(-) > > diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c > index 97b7df16..1fdf6ce5 100644 > --- a/src/openvpn/multi.c > +++ b/src/openvpn/multi.c > @@ -2229,22 +2229,16 @@ static inline bool > cc_check_return(int *cc_succeeded_count, > enum client_connect_return ret) > { > - if (ret == CC_RET_SUCCEEDED) > + switch (ret) > { > - (*cc_succeeded_count)++; > - return true; > - } > - else if (ret == CC_RET_FAILED) > - { > - return false; > - } > - else if (ret == CC_RET_SKIPPED) > - { > - return true; > - } > - else > - { > - ASSERT(0); > + case CC_RET_SUCCEEDED: (*cc_succeeded_count)++; > + return true; > + > + case CC_RET_FAILED: return false; > + > + case CC_RET_SKIPPED: return true; > + > + default: ASSERT(0); Code style police .... Even though it is not clearly defined, but based on the example here <https://community.openvpn.net/openvpn/wiki/CodeStyle#Casesinaswitchstatementshouldbreakorexplicitlyfallthrough> ... ... it should be more like: switch (ret) { case CC_RET_SUCCEEDED: (*cc_succeeded_count)++; return true; case CC_RET_FAILED: return false; case CC_RET_SKIPPED: return true; default: ASSERT(0); } I generally find this approach more readable.
Hi, On Fri, Jul 17, 2020 at 02:06:02PM +0200, David Sommerseth wrote: > On 17/07/2020 13:29, Arne Schwabe wrote: > > The return false/return true is the result of > > running uncrustify. [..] > > + case CC_RET_SKIPPED: return true; > > + > > + default: ASSERT(0); > > Code style police .... Not needed :-) - that code escaped, and the change-to-switch-case has long been merged in proper form. (For the record, this was discovered and discussed on IRC like "5 minutes after the mail was sent"). gert
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 97b7df16..1fdf6ce5 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -2229,22 +2229,16 @@ static inline bool cc_check_return(int *cc_succeeded_count, enum client_connect_return ret) { - if (ret == CC_RET_SUCCEEDED) + switch (ret) { - (*cc_succeeded_count)++; - return true; - } - else if (ret == CC_RET_FAILED) - { - return false; - } - else if (ret == CC_RET_SKIPPED) - { - return true; - } - else - { - ASSERT(0); + case CC_RET_SUCCEEDED: (*cc_succeeded_count)++; + return true; + + case CC_RET_FAILED: return false; + + case CC_RET_SKIPPED: return true; + + default: ASSERT(0); } }