diff options
author | Integral <integral@member.fsf.org> | 2024-10-26 00:10:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-26 00:10:22 +0200 |
commit | ddb8a639d5d1f9a0ebfa790805703cf381a42459 (patch) | |
tree | ee6fcdfcecd1ab5c5e4840d41e901d73f1ec38a2 /src/core | |
parent | Merge pull request #34884 from poettering/run0-disconnect-fix (diff) | |
download | systemd-ddb8a639d5d1f9a0ebfa790805703cf381a42459.tar.xz systemd-ddb8a639d5d1f9a0ebfa790805703cf381a42459.zip |
tree-wide: replace for loop with FOREACH_ELEMENT or FOREACH_ARRAY macros (#34893)
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/automount.c | 6 | ||||
-rw-r--r-- | src/core/device.c | 7 | ||||
-rw-r--r-- | src/core/load-fragment.c | 6 | ||||
-rw-r--r-- | src/core/unit-serialize.c | 9 |
4 files changed, 13 insertions, 15 deletions
diff --git a/src/core/automount.c b/src/core/automount.c index 0bdd970efc..9d0f7a1f6f 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -176,13 +176,13 @@ static int automount_verify(Automount *a) { if (!unit_has_name(UNIT(a), e)) return log_unit_error_errno(UNIT(a), SYNTHETIC_ERRNO(ENOEXEC), "Where= setting doesn't match unit name. Refusing."); - for (size_t i = 0; i < ELEMENTSOF(reserved_options); i++) - if (fstab_test_option(a->extra_options, reserved_options[i])) + FOREACH_ELEMENT(reserved_option, reserved_options) + if (fstab_test_option(a->extra_options, *reserved_option)) return log_unit_error_errno( UNIT(a), SYNTHETIC_ERRNO(ENOEXEC), "ExtraOptions= setting may not contain reserved option %s.", - reserved_options[i]); + *reserved_option); return 0; } diff --git a/src/core/device.c b/src/core/device.c index 4b62477d2c..03a730f624 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -372,7 +372,6 @@ static int device_found_from_string_many(const char *name, DeviceFound *ret) { for (;;) { _cleanup_free_ char *word = NULL; DeviceFound f = 0; - unsigned i; r = extract_first_word(&name, &word, ",", 0); if (r < 0) @@ -380,9 +379,9 @@ static int device_found_from_string_many(const char *name, DeviceFound *ret) { if (r == 0) break; - for (i = 0; i < ELEMENTSOF(device_found_map); i++) - if (streq(word, device_found_map[i].name)) { - f = device_found_map[i].flag; + FOREACH_ELEMENT(i, device_found_map) + if (streq(word, i->name)) { + f = i->flag; break; } diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 4b702038e6..fa8909e1d1 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -6383,9 +6383,9 @@ void unit_dump_config_items(FILE *f) { p->ltype == DISABLED_LEGACY) continue; - for (size_t j = 0; j < ELEMENTSOF(table); j++) - if (p->parse == table[j].callback) { - rvalue = table[j].rvalue; + FOREACH_ELEMENT(j, table) + if (p->parse == j->callback) { + rvalue = j->rvalue; break; } diff --git a/src/core/unit-serialize.c b/src/core/unit-serialize.c index ec1d3df32f..f196242eaf 100644 --- a/src/core/unit-serialize.c +++ b/src/core/unit-serialize.c @@ -419,12 +419,11 @@ static void print_unit_dependency_mask(FILE *f, const char *kind, UnitDependency assert(kind); assert(space); - for (size_t i = 0; i < ELEMENTSOF(table); i++) { - + FOREACH_ELEMENT(i, table) { if (mask == 0) break; - if (FLAGS_SET(mask, table[i].mask)) { + if (FLAGS_SET(mask, i->mask)) { if (*space) fputc(' ', f); else @@ -432,9 +431,9 @@ static void print_unit_dependency_mask(FILE *f, const char *kind, UnitDependency fputs(kind, f); fputs("-", f); - fputs(table[i].name, f); + fputs(i->name, f); - mask &= ~table[i].mask; + mask &= ~i->mask; } } |