]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
namespace: simplify mount_path_compare() a bit
authorLennart Poettering <lennart@poettering.net>
Thu, 25 Aug 2016 08:44:09 +0000 (10:44 +0200)
committerDjalal Harouni <tixxdz@opendz.org>
Sun, 25 Sep 2016 08:19:10 +0000 (10:19 +0200)
src/core/namespace.c

index 102fe576f370bb0fbc3a07d0c3a5dc27e9093b57..74201caa10633d19009a989f2e3c904723edbdcf 100644 (file)
@@ -93,21 +93,19 @@ static int mount_path_compare(const void *a, const void *b) {
         const BindMount *p = a, *q = b;
         int d;
 
+        /* If the paths are not equal, then order prefixes first */
         d = path_compare(p->path, q->path);
+        if (d != 0)
+                return d;
 
-        if (d == 0) {
-                /* If the paths are equal, check the mode */
-                if (p->mode < q->mode)
-                        return -1;
-
-                if (p->mode > q->mode)
-                        return 1;
+        /* If the paths are equal, check the mode */
+        if (p->mode < q->mode)
+                return -1;
 
-                return 0;
-        }
+        if (p->mode > q->mode)
+                return 1;
 
-        /* If the paths are not equal, then order prefixes first */
-        return d;
+        return 0;
 }
 
 static void drop_duplicates(BindMount *m, unsigned *n) {