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
+4 -5
View File
@@ -1255,12 +1255,11 @@ static int remove_variables(sd_id128_t uuid, const char *path, bool in_order) {
}
static int remove_loader_variables(void) {
const char *variable;
int r = 0;
/* Remove all persistent loader variables we define */
FOREACH_STRING(variable,
FOREACH_STRING(var,
EFI_LOADER_VARIABLE(LoaderConfigTimeout),
EFI_LOADER_VARIABLE(LoaderConfigTimeoutOneShot),
EFI_LOADER_VARIABLE(LoaderEntryDefault),
@@ -1269,15 +1268,15 @@ static int remove_loader_variables(void) {
int q;
q = efi_set_variable(variable, NULL, 0);
q = efi_set_variable(var, NULL, 0);
if (q == -ENOENT)
continue;
if (q < 0) {
log_warning_errno(q, "Failed to remove EFI variable %s: %m", variable);
log_warning_errno(q, "Failed to remove EFI variable %s: %m", var);
if (r >= 0)
r = q;
} else
log_info("Removed EFI variable %s.", variable);
log_info("Removed EFI variable %s.", var);
}
return r;