strv: declare iterator of FOREACH_STRING() in the loop

Same idea as 03677889f0.

No functional change intended. The type of the iterator is generally changed to
be 'const char*' instead of 'char*'. Despite the type commonly used, modifying
the string was not allowed.

I adjusted the naming of some short variables for clarity and reduced the scope
of some variable declarations in code that was being touched anyway.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-03-23 11:50:18 +01:00
parent 5b39139582
commit 5980d46304
53 changed files with 66 additions and 146 deletions
-2
View File
@@ -39,7 +39,6 @@ static int populate_uid_cache(const char *root, Hashmap **ret) {
/* The directory list is hardcoded here: /etc is the standard, and rpm-ostree uses /usr/lib. This
* could be made configurable, but I don't see the point right now. */
const char *fname;
FOREACH_STRING(fname, "/etc/passwd", "/usr/lib/passwd") {
_cleanup_fclose_ FILE *f = NULL;
@@ -78,7 +77,6 @@ static int populate_gid_cache(const char *root, Hashmap **ret) {
if (!cache)
return -ENOMEM;
const char *fname;
FOREACH_STRING(fname, "/etc/group", "/usr/lib/group") {
_cleanup_fclose_ FILE *f = NULL;