]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-util: minor coding style fix
authorLennart Poettering <lennart@poettering.net>
Sun, 25 Oct 2015 23:46:40 +0000 (00:46 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 26 Oct 2015 00:24:39 +0000 (01:24 +0100)
We usually avoid relying on C's degrade-to-boolean functionality when
comparing numerical variables with 0. We use it only for pointers and
actual booleans.

src/basic/path-util.c

index 7b01633f5f19ebad778ebd6147bd05bbde9cb08a..0b8cac8f3e590c63b15f9a6722eabda1ed8d4dd2 100644 (file)
@@ -428,7 +428,7 @@ int path_compare(const char *a, const char *b) {
          * Which one is sorted before the other does not really matter.
          * Here a relative path is ordered before an absolute path. */
         d = (a[0] == '/') - (b[0] == '/');
-        if (d)
+        if (d != 0)
                 return d;
 
         for (;;) {
@@ -451,12 +451,12 @@ int path_compare(const char *a, const char *b) {
 
                 /* Alphabetical sort: "/foo/aaa" before "/foo/b" */
                 d = memcmp(a, b, MIN(j, k));
-                if (d)
+                if (d != 0)
                         return (d > 0) - (d < 0); /* sign of d */
 
                 /* Sort "/foo/a" before "/foo/aaa" */
                 d = (j > k) - (j < k);  /* sign of (j - k) */
-                if (d)
+                if (d != 0)
                         return d;
 
                 a += j;