[systemd-devel] [PATCH 1/4] nspawn: shorten conditional path

Lennart Poettering lennart at poettering.net
Mon Dec 2 08:30:28 PST 2013


On Sun, 01.12.13 14:50, Shawn Landden (shawn at churchofgit.com) wrote:

> ---
>  src/nspawn/nspawn.c | 19 +++++++------------
>  1 file changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
> index dd7337b..0151cf3 100644
> --- a/src/nspawn/nspawn.c
> +++ b/src/nspawn/nspawn.c
> @@ -481,10 +481,8 @@ static int setup_timezone(const char *dest) {
>                  return 0;
>          }
>  
> -        z = path_startswith(p, "../usr/share/zoneinfo/");
> -        if (!z)
> -                z = path_startswith(p, "/usr/share/zoneinfo/");
> -        if (!z) {
> +        if ((z = path_startswith(p, "../usr/share/zoneinfo/")) ||
> +            (z = path_startswith(p, "/usr/share/zoneinfo/"))) {

Please don't do this. Let's keep our code simply, let's not munge
assignments and checks into one here. We used to do that quite
extensively, but we are actually in the process of converting everything
to the simpler to read scheme where we do assignment and checks in two
steps...

(Well, ther are a few exceptions where doing this one is OK, for
example, inside the checks of while() blocks...)

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list