chiark / gitweb /
path-util: minor coding style fix
authorLennart Poettering <lennart@poettering.net>
Sun, 25 Oct 2015 23:46:40 +0000 (00:46 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 26 Apr 2017 10:58:55 +0000 (12:58 +0200)
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 3998fc98a8f87b5d77b1da917a6154369ec03a15..7b38a01e34314d4eb81c7979e385ec3d92b18226 100644 (file)
@@ -417,7 +417,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 (;;) {
@@ -440,12 +440,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;