From: Zbigniew Jędrzejewski-Szmek Date: Wed, 7 Apr 2021 15:54:49 +0000 (+0200) Subject: tmpfiles: rework condition check X-Git-Tag: v249-rc1~434^2~2 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=875e7b25d84a111755dab79241c9e64e44836910;p=systemd%2F.git tmpfiles: rework condition check (!a && b) || (a && c) is replaced by (a ? c : b). path_startswith() != NULL is need to avoid type warning. --- diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index df2b90e88f..8b58ac95e4 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -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; }