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
+1 -5
View File
@@ -332,7 +332,6 @@ _public_ int sd_device_new_from_subsystem_sysname(
const char *subsystem,
const char *sysname) {
const char *s;
char *name;
int r;
@@ -341,7 +340,6 @@ _public_ int sd_device_new_from_subsystem_sysname(
assert_return(path_is_normalized(sysname), -EINVAL);
if (streq(subsystem, "subsystem")) {
FOREACH_STRING(s, "/sys/subsystem/", "/sys/bus/", "/sys/class/") {
r = device_strjoin_new(s, sysname, NULL, NULL, ret);
if (r < 0)
@@ -351,7 +349,6 @@ _public_ int sd_device_new_from_subsystem_sysname(
}
} else if (streq(subsystem, "module")) {
r = device_strjoin_new("/sys/module/", sysname, NULL, NULL, ret);
if (r < 0)
return r;
@@ -363,9 +360,8 @@ _public_ int sd_device_new_from_subsystem_sysname(
sep = strchr(sysname, ':');
if (sep && sep[1] != '\0') { /* Require ":" and something non-empty after that. */
const char *subsys;
subsys = memdupa_suffix0(sysname, sep - sysname);
const char *subsys = memdupa_suffix0(sysname, sep - sysname);
sep++;
FOREACH_STRING(s, "/sys/subsystem/", "/sys/bus/") {