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

Shawn Landden shawn at churchofgit.com
Sun Dec 1 14:50:14 PST 2013


---
 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/"))) {
                 log_warning("/etc/localtime does not point into /usr/share/zoneinfo/, not updating container timezone.");
                 return 0;
         }
@@ -495,14 +493,11 @@ static int setup_timezone(const char *dest) {
 
         r = readlink_malloc(where, &q);
         if (r >= 0) {
-                y = path_startswith(q, "../usr/share/zoneinfo/");
-                if (!y)
-                        y = path_startswith(q, "/usr/share/zoneinfo/");
-
-
-                /* Already pointing to the right place? Then do nothing .. */
-                if (y && streq(y, z))
-                        return 0;
+                if ((y = path_startswith(q, "../usr/share/zoneinfo/")) ||
+                    (y = path_startswith(q, "/usr/share/zoneinfo/")))
+                        /* Already pointing to the right place? Then do nothing .. */
+                        if (streq(y, z))
+                                return 0;
         }
 
         check = strjoin(dest, "/usr/share/zoneinfo/", z, NULL);
-- 
1.8.4.4



More information about the systemd-devel mailing list