dbwrap_tool: Simplify persistent/non-persistent check / dbwrap_tool: Avoid an unnecessary "else"

Andrew Bartlett abartlet at samba.org
Mon Sep 3 21:11:32 UTC 2018


On Mon, 2018-09-03 at 21:39 +0200, Ralph Böhme wrote:
>  
> commit 0ce26c75cb0329d013365dcff973d6ebe2261775
> Author: Volker Lendecke <vl at samba.org>
> Date:   Fri Aug 24 15:07:28 2018 +0200
> 
>     dbwrap_tool: Avoid an unnecessary "else"
>     
>     Signed-off-by: Volker Lendecke <vl at samba.org>
>     Reviewed-by: Ralph Boehme <slow at samba.org>
> 
> 

> commit 02d448429cc7f715b34d42aa425b74a715221202
> Author: Volker Lendecke <vl at samba.org>
> Date:   Fri Aug 24 15:06:34 2018 +0200
> 
>     dbwrap_tool: Simplify persistent/non-persistent check
>     
>     Signed-off-by: Volker Lendecke <vl at samba.org>
>     Reviewed-by: Ralph Boehme <slow at samba.org>

G'Day,

While each of these looks reasonable on its own, is this really the
clearest (rather than cleverest) possible way this could have been
constructed as a whole?

> -       if ((persistent == 0 && non_persistent == 0) ||
> -           (persistent == 1 && non_persistent == 1))
> -       {
> +       if ((persistent + non_persistent) != 1) {
>                 d_fprintf(stderr, "ERROR: you must specify exactly one "
>                           "of --persistent and --non-persistent\n");
>                 goto done;
> -       } else if (non_persistent == 1) {
> +       }
> +       if (non_persistent == 1) {
>                 tdb_flags |= TDB_CLEAR_IF_FIRST;
>         }

What specifically was the goal of the change here?

Thanks,

Andrew Bartlett

-- 
Andrew Bartlett
https://samba.org/~abartlet/
Authentication Developer, Samba Team         https://samba.org
Samba Development and Support, Catalyst IT   
https://catalyst.net.nz/services/samba







More information about the samba-technical mailing list