strv: make iterator in STRV_FOREACH() declaread in the loop

This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
This commit is contained in:
Yu Watanabe
2022-03-19 08:33:33 +09:00
parent 80a226b26b
commit de010b0b2e
210 changed files with 109 additions and 621 deletions
+3 -5
View File
@@ -209,8 +209,7 @@ bool lookup_paths_timestamp_hash_same(const LookupPaths *lp, uint64_t timestamp_
siphash24_init(&state, HASH_KEY.bytes);
char **dir;
STRV_FOREACH(dir, (char**) lp->search_path) {
STRV_FOREACH(dir, lp->search_path) {
struct stat st;
if (lookup_paths_mtime_exclude(lp, *dir))
@@ -281,7 +280,6 @@ int unit_file_build_name_map(
_cleanup_hashmap_free_ Hashmap *ids = NULL, *names = NULL;
_cleanup_set_free_free_ Set *paths = NULL;
uint64_t timestamp_hash;
char **dir;
int r;
/* Before doing anything, check if the timestamp hash that was passed is still valid.
@@ -299,7 +297,7 @@ int unit_file_build_name_map(
return log_oom();
}
STRV_FOREACH(dir, (char**) lp->search_path) {
STRV_FOREACH(dir, lp->search_path) {
_cleanup_closedir_ DIR *d = NULL;
d = opendir(*dir);
@@ -550,7 +548,7 @@ static int add_names(
Set **names,
const char *name) {
char **aliases, **alias;
char **aliases;
int r;
assert(name_type == UNIT_NAME_PLAIN || instance);