Re: [Openvpn-devel] [PATCH] Convert cc_check_return to switch/case

2020-07-19 Thread Gert Doering
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
-- 
"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 g...@greenie.muc.de


signature.asc
Description: PGP signature
___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel


Re: [Openvpn-devel] [PATCH] Convert cc_check_return to switch/case

2020-07-17 Thread David Sommerseth
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 
> ---
>  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

...

... 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.


-- 
kind regards,

David Sommerseth
OpenVPN Inc




signature.asc
Description: OpenPGP digital signature
___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel


[Openvpn-devel] [PATCH] Convert cc_check_return to switch/case

2020-07-17 Thread Arne Schwabe
The return false/return true is the result of
running uncrustify.

Signed-off-by: Arne Schwabe 
---
 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);
 }
 }
 
-- 
2.26.2



___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel