1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-06 12:58:22 +03:00

tmpfiles: rework condition check

(!a && b) || (a && c) is replaced by (a ? c : b).

path_startswith() != NULL is need to avoid type warning.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-04-07 17:54:49 +02:00
parent bec890e3cd
commit 875e7b25d8

View 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;
}