]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: rework condition check
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Apr 2021 15:54:49 +0000 (17:54 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 8 Apr 2021 09:01:29 +0000 (11:01 +0200)
(!a && b) || (a && c) is replaced by (a ? c : b).

path_startswith() != NULL is need to avoid type warning.

src/tmpfiles/tmpfiles.c

index df2b90e88fd914a728af56179f73bd11bf62d943..8b58ac95e4b62fe4c1b61c5bc24978faf57e84de 100644 (file)
@@ -3251,7 +3251,11 @@ static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoe
                                 for (size_t nj = 0; nj < ja->n_items; nj++) {
                                         Item *j = ja->items + nj;
 
-                                        if (!IN_SET(j->type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA))
+                                        if (!IN_SET(j->type, CREATE_DIRECTORY,
+                                                             TRUNCATE_DIRECTORY,
+                                                             CREATE_SUBVOLUME,
+                                                             CREATE_SUBVOLUME_INHERIT_QUOTA,
+                                                             CREATE_SUBVOLUME_NEW_QUOTA))
                                                 continue;
 
                                         if (path_equal(j->path, i->path)) {
@@ -3259,8 +3263,9 @@ static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoe
                                                 break;
                                         }
 
-                                        if ((!candidate_item && path_startswith(i->path, j->path)) ||
-                                            (candidate_item && path_startswith(j->path, candidate_item->path) && (fnmatch(i->path, j->path, FNM_PATHNAME | FNM_PERIOD) == 0)))
+                                        if (candidate_item
+                                            ? (path_startswith(j->path, candidate_item->path) && fnmatch(i->path, j->path, FNM_PATHNAME | FNM_PERIOD) == 0)
+                                            : path_startswith(i->path, j->path) != NULL)
                                                 candidate_item = j;
                                 }