diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-09-08 11:58:29 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-09-08 12:14:05 +0200 |
commit | 90e74a66e663f1776457d599cb7d5ce44785a56c (patch) | |
tree | 16ce28594b8dc475e37df9a3b80accb96e748efa | |
parent | 12375b95ddcb7dbbcbc5969b87822d39115d8acf (diff) | |
download | systemd-90e74a66e663f1776457d599cb7d5ce44785a56c.tar.gz |
tree-wide: define iterator inside of the macro
151 files changed, 546 insertions, 927 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 549c4a4a9b..a9e4b37573 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1500,7 +1500,6 @@ static int do_unit_files(int argc, char *argv[], void *userdata) { _cleanup_hashmap_free_ Hashmap *unit_ids = NULL; _cleanup_hashmap_free_ Hashmap *unit_names = NULL; char **patterns = strv_skip(argv, 1); - Iterator i; const char *k, *dst; char **v; int r; @@ -1513,7 +1512,7 @@ static int do_unit_files(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "unit_file_build_name_map() failed: %m"); - HASHMAP_FOREACH_KEY(dst, k, unit_ids, i) { + HASHMAP_FOREACH_KEY(dst, k, unit_ids) { if (!strv_fnmatch_or_empty(patterns, k, FNM_NOESCAPE) && !strv_fnmatch_or_empty(patterns, dst, FNM_NOESCAPE)) continue; @@ -1521,7 +1520,7 @@ static int do_unit_files(int argc, char *argv[], void *userdata) { printf("ids: %s → %s\n", k, dst); } - HASHMAP_FOREACH_KEY(v, k, unit_names, i) { + HASHMAP_FOREACH_KEY(v, k, unit_names) { if (!strv_fnmatch_or_empty(patterns, k, FNM_NOESCAPE) && !strv_fnmatch_strv_or_empty(patterns, v, FNM_NOESCAPE)) continue; diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h index 70189db867..890f90a9d1 100644 --- a/src/basic/hashmap.h +++ b/src/basic/hashmap.h @@ -407,17 +407,25 @@ static inline char** ordered_hashmap_get_strv(OrderedHashmap *h) { * the entries were inserted. * It is safe to remove the current entry. */ -#define HASHMAP_FOREACH(e, h, i) \ - for ((i) = ITERATOR_FIRST; hashmap_iterate((h), &(i), (void**)&(e), NULL); ) - -#define ORDERED_HASHMAP_FOREACH(e, h, i) \ - for ((i) = ITERATOR_FIRST; ordered_hashmap_iterate((h), &(i), (void**)&(e), NULL); ) - -#define HASHMAP_FOREACH_KEY(e, k, h, i) \ - for ((i) = ITERATOR_FIRST; hashmap_iterate((h), &(i), (void**)&(e), (const void**) &(k)); ) - -#define ORDERED_HASHMAP_FOREACH_KEY(e, k, h, i) \ - for ((i) = ITERATOR_FIRST; ordered_hashmap_iterate((h), &(i), (void**)&(e), (const void**) &(k)); ) +#define _HASHMAP_FOREACH(e, h, i) \ + for (Iterator i = ITERATOR_FIRST; hashmap_iterate((h), &i, (void**)&(e), NULL); ) +#define HASHMAP_FOREACH(e, h) \ + _HASHMAP_FOREACH(e, h, UNIQ_T(i, UNIQ)) + +#define _ORDERED_HASHMAP_FOREACH(e, h, i) \ + for (Iterator i = ITERATOR_FIRST; ordered_hashmap_iterate((h), &i, (void**)&(e), NULL); ) +#define ORDERED_HASHMAP_FOREACH(e, h) \ + _ORDERED_HASHMAP_FOREACH(e, h, UNIQ_T(i, UNIQ)) + +#define _HASHMAP_FOREACH_KEY(e, k, h, i) \ + for (Iterator i = ITERATOR_FIRST; hashmap_iterate((h), &i, (void**)&(e), (const void**) &(k)); ) +#define HASHMAP_FOREACH_KEY(e, k, h) \ + _HASHMAP_FOREACH_KEY(e, k, h, UNIQ_T(i, UNIQ)) + +#define _ORDERED_HASHMAP_FOREACH_KEY(e, k, h, i) \ + for (Iterator i = ITERATOR_FIRST; ordered_hashmap_iterate((h), &i, (void**)&(e), (const void**) &(k)); ) +#define ORDERED_HASHMAP_FOREACH_KEY(e, k, h) \ + _ORDERED_HASHMAP_FOREACH_KEY(e, k, h, UNIQ_T(i, UNIQ)) DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, hashmap_free); DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, hashmap_free_free); diff --git a/src/basic/ordered-set.c b/src/basic/ordered-set.c index fb82c17b5a..83098435b2 100644 --- a/src/basic/ordered-set.c +++ b/src/basic/ordered-set.c @@ -70,12 +70,11 @@ int ordered_set_put_strdupv(OrderedSet *s, char **l) { int ordered_set_put_string_set(OrderedSet *s, OrderedSet *l) { int n = 0, r; - Iterator i; char *p; /* Like ordered_set_put_strv, but for an OrderedSet of strings */ - ORDERED_SET_FOREACH(p, l, i) { + ORDERED_SET_FOREACH(p, l) { r = ordered_set_put_strdup(s, p); if (r < 0) return r; @@ -88,7 +87,6 @@ int ordered_set_put_string_set(OrderedSet *s, OrderedSet *l) { void ordered_set_print(FILE *f, const char *field, OrderedSet *s) { bool space = false; - Iterator i; char *p; if (ordered_set_isempty(s)) @@ -96,7 +94,7 @@ void ordered_set_print(FILE *f, const char *field, OrderedSet *s) { fputs(field, f); - ORDERED_SET_FOREACH(p, s, i) + ORDERED_SET_FOREACH(p, s) fputs_with_space(f, p, NULL, &space); fputc('\n', f); diff --git a/src/basic/ordered-set.h b/src/basic/ordered-set.h index 26481b72d4..c942aafe81 100644 --- a/src/basic/ordered-set.h +++ b/src/basic/ordered-set.h @@ -64,8 +64,10 @@ int ordered_set_put_strdupv(OrderedSet *s, char **l); int ordered_set_put_string_set(OrderedSet *s, OrderedSet *l); void ordered_set_print(FILE *f, const char *field, OrderedSet *s); -#define ORDERED_SET_FOREACH(e, s, i) \ - for ((i) = ITERATOR_FIRST; ordered_set_iterate((s), &(i), (void**)&(e)); ) +#define _ORDERED_SET_FOREACH(e, s, i) \ + for (Iterator i = ITERATOR_FIRST; ordered_set_iterate((s), &i, (void**)&(e)); ) +#define ORDERED_SET_FOREACH(e, s) \ + _ORDERED_SET_FOREACH(e, s, UNIQ_T(i, UNIQ)) DEFINE_TRIVIAL_CLEANUP_FUNC(OrderedSet*, ordered_set_free); DEFINE_TRIVIAL_CLEANUP_FUNC(OrderedSet*, ordered_set_free_free); diff --git a/src/basic/set.h b/src/basic/set.h index 42cc064ac4..7170eea84c 100644 --- a/src/basic/set.h +++ b/src/basic/set.h @@ -135,8 +135,10 @@ int _set_put_strdupv(Set **s, char **l HASHMAP_DEBUG_PARAMS); int set_put_strsplit(Set *s, const char *v, const char *separators, ExtractFlags flags); -#define SET_FOREACH(e, s, i) \ - for ((i) = ITERATOR_FIRST; set_iterate((s), &(i), (void**)&(e)); ) +#define _SET_FOREACH(e, s, i) \ + for (Iterator i = ITERATOR_FIRST; set_iterate((s), &i, (void**)&(e)); ) +#define SET_FOREACH(e, s) \ + _SET_FOREACH(e, s, UNIQ_T(i, UNIQ)) #define SET_FOREACH_MOVE(e, d, s) \ for (; ({ e = set_first(s); assert_se(!e || set_move_one(d, s, e) >= 0); e; }); ) diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 3447f305a7..3163492268 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -145,7 +145,6 @@ static int list_bus_names(int argc, char **argv, void *userdata) { _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; _cleanup_hashmap_free_ Hashmap *names = NULL; _cleanup_(table_unrefp) Table *table = NULL; - Iterator iterator; char **i, *k; void *v; int r; @@ -247,7 +246,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) { table_set_header(table, arg_legend); - HASHMAP_FOREACH_KEY(v, k, names, iterator) { + HASHMAP_FOREACH_KEY(v, k, names) { _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL; if (v == NAME_IS_ACTIVATABLE) { @@ -986,7 +985,6 @@ static int introspect(int argc, char **argv, void *userdata) { _cleanup_(member_set_freep) Set *members = NULL; unsigned name_width, type_width, signature_width, result_width, j, k = 0; Member *m, **sorted = NULL; - Iterator i; const char *xml; int r; @@ -1022,7 +1020,7 @@ static int introspect(int argc, char **argv, void *userdata) { return r; /* Second, find the current values for them */ - SET_FOREACH(m, members, i) { + SET_FOREACH(m, members) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; if (!streq(m->type, "property")) @@ -1105,7 +1103,7 @@ static int introspect(int argc, char **argv, void *userdata) { sorted = newa(Member*, set_size(members)); - SET_FOREACH(m, members, i) { + SET_FOREACH(m, members) { if (argv[3] && !streq(argv[3], m->interface)) continue; diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index e6c09d1b38..042d83c495 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -582,7 +582,6 @@ static int group_compare(Group * const *a, Group * const *b) { } static void display(Hashmap *a) { - Iterator i; Group *g; Group **array; signed path_columns; @@ -596,7 +595,7 @@ static void display(Hashmap *a) { array = newa(Group*, hashmap_size(a)); - HASHMAP_FOREACH(g, a, i) + HASHMAP_FOREACH(g, a) if (g->n_tasks_valid || g->cpu_valid || g->memory_valid || g->io_valid) array[n++] = g; diff --git a/src/core/automount.c b/src/core/automount.c index def267ddb7..782f7680aa 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -850,7 +850,6 @@ static int automount_stop(Unit *u) { static int automount_serialize(Unit *u, FILE *f, FDSet *fds) { Automount *a = AUTOMOUNT(u); - Iterator i; void *p; int r; @@ -862,9 +861,9 @@ static int automount_serialize(Unit *u, FILE *f, FDSet *fds) { (void) serialize_item(f, "result", automount_result_to_string(a->result)); (void) serialize_item_format(f, "dev-id", "%lu", (unsigned long) a->dev_id); - SET_FOREACH(p, a->tokens, i) + SET_FOREACH(p, a->tokens) (void) serialize_item_format(f, "token", "%u", PTR_TO_UINT(p)); - SET_FOREACH(p, a->expire_tokens, i) + SET_FOREACH(p, a->expire_tokens) (void) serialize_item_format(f, "expire-token", "%u", PTR_TO_UINT(p)); r = serialize_fd(f, fds, "pipe-fd", a->pipe_fd); diff --git a/src/core/bpf-firewall.c b/src/core/bpf-firewall.c index bceb049b58..5671d0c195 100644 --- a/src/core/bpf-firewall.c +++ b/src/core/bpf-firewall.c @@ -646,14 +646,13 @@ int bpf_firewall_load_custom(Unit *u) { static int attach_custom_bpf_progs(Unit *u, const char *path, int attach_type, Set **set, Set **set_installed) { BPFProgram *prog; - Iterator i; int r; assert(u); set_clear(*set_installed); - SET_FOREACH(prog, *set, i) { + SET_FOREACH(prog, *set) { r = bpf_program_cgroup_attach(prog, attach_type, path, BPF_F_ALLOW_MULTI); if (r < 0) return log_unit_error_errno(u, r, "Attaching custom egress BPF program to cgroup %s failed: %m", path); diff --git a/src/core/cgroup.c b/src/core/cgroup.c index a6a9e0c7d4..6af08e78e6 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -1516,9 +1516,8 @@ CGroupMask unit_get_members_mask(Unit *u) { if (u->type == UNIT_SLICE) { void *v; Unit *member; - Iterator i; - HASHMAP_FOREACH_KEY(v, member, u->dependencies[UNIT_BEFORE], i) + HASHMAP_FOREACH_KEY(v, member, u->dependencies[UNIT_BEFORE]) if (UNIT_DEREF(member->slice) == u) u->cgroup_members_mask |= unit_get_subtree_mask(member); /* note that this calls ourselves again, for the children */ } @@ -1940,7 +1939,6 @@ static int unit_attach_pid_to_cgroup_via_bus(Unit *u, pid_t pid, const char *suf int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) { CGroupMask delegated_mask; const char *p; - Iterator i; void *pidp; int r, q; @@ -1970,7 +1968,7 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) { delegated_mask = unit_get_delegate_mask(u); r = 0; - SET_FOREACH(pidp, pids, i) { + SET_FOREACH(pidp, pids) { pid_t pid = PTR_TO_PID(pidp); CGroupController c; @@ -2158,7 +2156,6 @@ static int unit_realize_cgroup_now_enable(Unit *u, ManagerState state) { /* Controllers can only be disabled depth-first, from the leaves of the * hierarchy upwards to the unit in question. */ static int unit_realize_cgroup_now_disable(Unit *u, ManagerState state) { - Iterator i; Unit *m; void *v; @@ -2167,7 +2164,7 @@ static int unit_realize_cgroup_now_disable(Unit *u, ManagerState state) { if (u->type != UNIT_SLICE) return 0; - HASHMAP_FOREACH_KEY(v, m, u->dependencies[UNIT_BEFORE], i) { + HASHMAP_FOREACH_KEY(v, m, u->dependencies[UNIT_BEFORE]) { CGroupMask target_mask, enable_mask, new_target_mask, new_enable_mask; int r; @@ -2331,14 +2328,13 @@ void unit_add_family_to_cgroup_realize_queue(Unit *u) { * masks. */ do { - Iterator i; Unit *m; void *v; /* Children of u likely changed when we're called */ u->cgroup_members_mask_valid = false; - HASHMAP_FOREACH_KEY(v, m, u->dependencies[UNIT_BEFORE], i) { + HASHMAP_FOREACH_KEY(v, m, u->dependencies[UNIT_BEFORE]) { /* Skip units that have a dependency on the slice but aren't actually in it. */ if (UNIT_DEREF(m->slice) != u) continue; @@ -3527,10 +3523,9 @@ void unit_invalidate_cgroup_bpf(Unit *u) { * list of our children includes our own. */ if (u->type == UNIT_SLICE) { Unit *member; - Iterator i; void *v; - HASHMAP_FOREACH_KEY(v, member, u->dependencies[UNIT_BEFORE], i) + HASHMAP_FOREACH_KEY(v, member, u->dependencies[UNIT_BEFORE]) if (UNIT_DEREF(member->slice) == u) unit_invalidate_cgroup_bpf(member); } @@ -3552,12 +3547,11 @@ bool unit_cgroup_delegate(Unit *u) { } void manager_invalidate_startup_units(Manager *m) { - Iterator i; Unit *u; assert(m); - SET_FOREACH(u, m->startup_units, i) + SET_FOREACH(u, m->startup_units) unit_invalidate_cgroup(u, CGROUP_MASK_CPU|CGROUP_MASK_IO|CGROUP_MASK_BLKIO); } diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c index 5a586f1e59..4bb262bd93 100644 --- a/src/core/core-varlink.c +++ b/src/core/core-varlink.c @@ -79,10 +79,9 @@ static int vl_method_get_user_record(Varlink *link, JsonVariant *parameters, Var else if (p.user_name) r = dynamic_user_lookup_name(m, p.user_name, &found_uid); else { - Iterator i; DynamicUser *d; - HASHMAP_FOREACH(d, m->dynamic_users, i) { + HASHMAP_FOREACH(d, m->dynamic_users) { r = dynamic_user_current(d, &uid); if (r == -EAGAIN) /* not realized yet? */ continue; @@ -189,9 +188,8 @@ static int vl_method_get_group_record(Varlink *link, JsonVariant *parameters, Va r = dynamic_user_lookup_name(m, p.group_name, (uid_t*) &found_gid); else { DynamicUser *d; - Iterator i; - HASHMAP_FOREACH(d, m->dynamic_users, i) { + HASHMAP_FOREACH(d, m->dynamic_users) { uid_t uid; r = dynamic_user_current(d, &uid); diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 9042f0baa8..8f915ac2f5 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -360,7 +360,6 @@ static int property_get_syscall_filter( int r; #if HAVE_SECCOMP - Iterator i; void *id, *val; #endif @@ -377,7 +376,7 @@ static int property_get_syscall_filter( return r; #if HAVE_SECCOMP - HASHMAP_FOREACH_KEY(val, id, c->syscall_filter, i) { + HASHMAP_FOREACH_KEY(val, id, c->syscall_filter) { _cleanup_free_ char *name = NULL; const char *e = NULL; char *s; @@ -430,7 +429,6 @@ static int property_get_syscall_archs( int r; #if HAVE_SECCOMP - Iterator i; void *id; #endif @@ -439,7 +437,7 @@ static int property_get_syscall_archs( assert(c); #if HAVE_SECCOMP - SET_FOREACH(id, c->syscall_archs, i) { + SET_FOREACH(id, c->syscall_archs) { const char *name; name = seccomp_arch_to_string(PTR_TO_UINT32(id) - 1); @@ -526,7 +524,6 @@ static int property_get_address_families( ExecContext *c = userdata; _cleanup_strv_free_ char **l = NULL; - Iterator i; void *af; int r; @@ -542,7 +539,7 @@ static int property_get_address_families( if (r < 0) return r; - SET_FOREACH(af, c->address_families, i) { + SET_FOREACH(af, c->address_families) { const char *name; name = af_to_name(PTR_TO_INT(af)); @@ -759,7 +756,6 @@ static int property_get_set_credential( ExecContext *c = userdata; ExecSetCredential *sc; - Iterator iterator; int r; assert(bus); @@ -771,7 +767,7 @@ static int property_get_set_credential( if (r < 0) return r; - HASHMAP_FOREACH(sc, c->set_credentials, iterator) { + HASHMAP_FOREACH(sc, c->set_credentials) { r = sd_bus_message_open_container(reply, 'r', "say"); if (r < 0) diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index 0859bb3779..06443a4be4 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -164,14 +164,13 @@ static int bus_job_enumerate(sd_bus *bus, const char *path, void *userdata, char _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; unsigned k = 0; - Iterator i; Job *j; l = new0(char*, hashmap_size(m->jobs)+1); if (!l) return -ENOMEM; - HASHMAP_FOREACH(j, m->jobs, i) { + HASHMAP_FOREACH(j, m->jobs) { l[k] = job_dbus_path(j); if (!l[k]) return -ENOMEM; diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 16945d09c4..0ac87b56a8 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -1058,7 +1058,6 @@ static int list_units_filtered(sd_bus_message *message, void *userdata, sd_bus_e _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; const char *k; - Iterator i; Unit *u; int r; @@ -1079,7 +1078,7 @@ static int list_units_filtered(sd_bus_message *message, void *userdata, sd_bus_e if (r < 0) return r; - HASHMAP_FOREACH_KEY(u, k, m->units, i) { + HASHMAP_FOREACH_KEY(u, k, m->units) { if (k != u->id) continue; @@ -1139,7 +1138,6 @@ static int method_list_units_by_patterns(sd_bus_message *message, void *userdata static int method_list_jobs(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; - Iterator i; Job *j; int r; @@ -1160,7 +1158,7 @@ static int method_list_jobs(sd_bus_message *message, void *userdata, sd_bus_erro if (r < 0) return r; - HASHMAP_FOREACH(j, m->jobs, i) { + HASHMAP_FOREACH(j, m->jobs) { _cleanup_free_ char *unit_path = NULL, *job_path = NULL; job_path = job_dbus_path(j); @@ -1759,7 +1757,6 @@ static int method_get_dynamic_users(sd_bus_message *message, void *userdata, sd_ _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; DynamicUser *d; - Iterator i; int r; assert(message); @@ -1778,7 +1775,7 @@ static int method_get_dynamic_users(sd_bus_message *message, void *userdata, sd_ if (r < 0) return r; - HASHMAP_FOREACH(d, m->dynamic_users, i) { + HASHMAP_FOREACH(d, m->dynamic_users) { uid_t uid; r = dynamic_user_current(d, &uid); @@ -1804,7 +1801,6 @@ static int list_unit_files_by_patterns(sd_bus_message *message, void *userdata, Manager *m = userdata; UnitFileList *item; Hashmap *h; - Iterator i; int r; assert(message); @@ -1832,7 +1828,7 @@ static int list_unit_files_by_patterns(sd_bus_message *message, void *userdata, if (r < 0) goto fail; - HASHMAP_FOREACH(item, h, i) { + HASHMAP_FOREACH(item, h) { r = sd_bus_message_append(reply, "(ss)", item->path, unit_file_state_to_string(item->state)); if (r < 0) diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index 09f88b385b..73052fac6d 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -42,7 +42,6 @@ static int property_get_exit_status_set( const ExitStatusSet *status_set = userdata; unsigned n; - Iterator i; int r; assert(bus); @@ -57,7 +56,7 @@ static int property_get_exit_status_set( if (r < 0) return r; - BITMAP_FOREACH(n, &status_set->status, i) { + BITMAP_FOREACH(n, &status_set->status) { assert(n < 256); r = sd_bus_message_append_basic(reply, 'i', &n); @@ -73,7 +72,7 @@ static int property_get_exit_status_set( if (r < 0) return r; - BITMAP_FOREACH(n, &status_set->signal, i) { + BITMAP_FOREACH(n, &status_set->signal) { const char *str; str = signal_to_string(n); diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index e799771c22..d38c0f0582 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -103,7 +103,6 @@ static int property_get_names( sd_bus_error *error) { Unit *u = userdata; - Iterator i; const char *t; int r; @@ -119,7 +118,7 @@ static int property_get_names( if (r < 0) return r; - SET_FOREACH(t, u->aliases, i) { + SET_FOREACH(t, u->aliases) { r = sd_bus_message_append(reply, "s", t); if (r < 0) return r; @@ -157,7 +156,6 @@ static int property_get_dependencies( sd_bus_error *error) { Hashmap **h = userdata; - Iterator j; Unit *u; void *v; int r; @@ -170,7 +168,7 @@ static int property_get_dependencies( if (r < 0) return r; - HASHMAP_FOREACH_KEY(v, u, *h, j) { + HASHMAP_FOREACH_KEY(v, u, *h) { r = sd_bus_message_append(reply, "s", u->id); if (r < 0) return r; @@ -190,7 +188,6 @@ static int property_get_requires_mounts_for( Hashmap **h = userdata; const char *p; - Iterator j; void *v; int r; @@ -202,7 +199,7 @@ static int property_get_requires_mounts_for( if (r < 0) return r; - HASHMAP_FOREACH_KEY(v, p, *h, j) { + HASHMAP_FOREACH_KEY(v, p, *h) { r = sd_bus_message_append(reply, "s", p); if (r < 0) return r; @@ -1729,7 +1726,6 @@ int bus_unit_queue_job( _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_free_ char *job_path = NULL, *unit_path = NULL; _cleanup_set_free_ Set *affected = NULL; - Iterator i; Job *j, *a; int r; @@ -1808,7 +1804,7 @@ int bus_unit_queue_job( if (r < 0) return r; - SET_FOREACH(a, affected, i) { + SET_FOREACH(a, affected) { if (a->id == j->id) continue; diff --git a/src/core/dbus.c b/src/core/dbus.c index 8958af48ce..774ee5632f 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -457,14 +457,13 @@ static int bus_unit_enumerate(sd_bus *bus, const char *path, void *userdata, cha _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; unsigned k = 0; - Iterator i; Unit *u; l = new0(char*, hashmap_size(m->units)+1); if (!l) return -ENOMEM; - HASHMAP_FOREACH(u, m->units, i) { + HASHMAP_FOREACH(u, m->units) { l[k] = unit_dbus_path(u); if (!l[k]) return -ENOMEM; @@ -767,7 +766,6 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void } static int bus_setup_api(Manager *m, sd_bus *bus) { - Iterator i; char *name; Unit *u; int r; @@ -787,7 +785,7 @@ static int bus_setup_api(Manager *m, sd_bus *bus) { if (r < 0) return r; - HASHMAP_FOREACH_KEY(u, name, m->watch_bus, i) { + HASHMAP_FOREACH_KEY(u, name, m->watch_bus) { r = unit_install_bus_match(u, bus, name); if (r < 0) log_error_errno(r, "Failed to subscribe to NameOwnerChanged signal for '%s': %m", name); @@ -976,7 +974,6 @@ int bus_init_private(Manager *m) { } static void destroy_bus(Manager *m, sd_bus **bus) { - Iterator i; Unit *u; Job *j; @@ -987,7 +984,7 @@ static void destroy_bus(Manager *m, sd_bus **bus) { return; /* Make sure all bus slots watching names are released. */ - HASHMAP_FOREACH(u, m->watch_bus, i) { + HASHMAP_FOREACH(u, m->watch_bus) { if (u->match_bus_slot && sd_bus_slot_get_bus(u->match_bus_slot) == *bus) u->match_bus_slot = sd_bus_slot_unref(u->match_bus_slot); if (u->get_name_owner_slot && sd_bus_slot_get_bus(u->get_name_owner_slot) == *bus) @@ -998,11 +995,11 @@ static void destroy_bus(Manager *m, sd_bus **bus) { if (m->subscribed && sd_bus_track_get_bus(m->subscribed) == *bus) m->subscribed = sd_bus_track_unref(m->subscribed); - HASHMAP_FOREACH(j, m->jobs, i) + HASHMAP_FOREACH(j, m->jobs) if (j->bus_track && sd_bus_track_get_bus(j->bus_track) == *bus) j->bus_track = sd_bus_track_unref(j->bus_track); - HASHMAP_FOREACH(u, m->units, i) { + HASHMAP_FOREACH(u, m->units) { if (u->bus_track && sd_bus_track_get_bus(u->bus_track) == *bus) u->bus_track = sd_bus_track_unref(u->bus_track); @@ -1060,7 +1057,6 @@ void bus_done(Manager *m) { } int bus_fdset_add_all(Manager *m, FDSet *fds) { - Iterator i; sd_bus *b; int fd; @@ -1083,7 +1079,7 @@ int bus_fdset_add_all(Manager *m, FDSet *fds) { } } - SET_FOREACH(b, m->private_buses, i) { + SET_FOREACH(b, m->private_buses) { fd = sd_bus_get_fd(b); if (fd >= 0) { fd = fdset_put_dup(fds, fd); @@ -1105,12 +1101,11 @@ int bus_foreach_bus( int (*send_message)(sd_bus *bus, void *userdata), void *userdata) { - Iterator i; sd_bus *b; int r, ret = 0; /* Send to all direct buses, unconditionally */ - SET_FOREACH(b, m->private_buses, i) { + SET_FOREACH(b, m->private_buses) { /* Don't bother with enqueuing these messages to clients that haven't started yet */ if (sd_bus_is_ready(b) <= 0) @@ -1191,13 +1186,12 @@ int bus_verify_set_environment_async(Manager *m, sd_bus_message *call, sd_bus_er uint64_t manager_bus_n_queued_write(Manager *m) { uint64_t c = 0; - Iterator i; sd_bus *b; int r; /* Returns the total number of messages queued for writing on all our direct and API buses. */ - SET_FOREACH(b, m->private_buses, i) { + SET_FOREACH(b, m->private_buses) { uint64_t k; r = sd_bus_get_n_queued_write(b, &k); diff --git a/src/core/device.c b/src/core/device.c index 53bc549bd3..31aa3341c2 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -468,13 +468,12 @@ static bool device_is_bound_by_mounts(Device *d, sd_device *dev) { static void device_upgrade_mount_deps(Unit *u) { Unit *other; - Iterator i; void *v; int r; /* Let's upgrade Requires= to BindsTo= on us. (Used when SYSTEMD_MOUNT_DEVICE_BOUND is set) */ - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REQUIRED_BY], i) { + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REQUIRED_BY]) { if (other->type != UNIT_MOUNT) continue; diff --git a/src/core/dynamic-user.c b/src/core/dynamic-user.c index 58b37925bf..be386df12b 100644 --- a/src/core/dynamic-user.c +++ b/src/core/dynamic-user.c @@ -611,7 +611,6 @@ static DynamicUser* dynamic_user_destroy(DynamicUser *d) { int dynamic_user_serialize(Manager *m, FILE *f, FDSet *fds) { DynamicUser *d; - Iterator i; assert(m); assert(f); @@ -619,7 +618,7 @@ int dynamic_user_serialize(Manager *m, FILE *f, FDSet *fds) { /* Dump the dynamic user database into the manager serialization, to deal with daemon reloads. */ - HASHMAP_FOREACH(d, m->dynamic_users, i) { + HASHMAP_FOREACH(d, m->dynamic_users) { int copy0, copy1; copy0 = fdset_put_dup(fds, d->storage_socket[0]); @@ -674,7 +673,6 @@ void dynamic_user_deserialize_one(Manager *m, const char *value, FDSet *fds) { void dynamic_user_vacuum(Manager *m, bool close_user) { DynamicUser *d; - Iterator i; assert(m); @@ -682,7 +680,7 @@ void dynamic_user_vacuum(Manager *m, bool close_user) { * to which no reference exist. This is called after a daemon reload finished, in order to destroy users which * might not be referenced anymore. */ - HASHMAP_FOREACH(d, m->dynamic_users, i) { + HASHMAP_FOREACH(d, m->dynamic_users) { if (d->n_ref > 0) continue; diff --git a/src/core/execute.c b/src/core/execute.c index e02a55e222..e2fc61fe78 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -2483,7 +2483,6 @@ static int acquire_credentials( _cleanup_close_ int dfd = -1; ExecSetCredential *sc; char **id, **fn; - Iterator iterator; int r; assert(context); @@ -2495,7 +2494,7 @@ static int acquire_credentials( /* First we use the literally specified credentials. Note that they might be overriden again below, * and thus act as a "default" if the same credential is specified multiple times */ - HASHMAP_FOREACH(sc, context->set_credentials, iterator) { + HASHMAP_FOREACH(sc, context->set_credentials) { size_t add; add = strlen(sc->id) + sc->size; @@ -5484,7 +5483,6 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { if (c->syscall_filter) { #if HAVE_SECCOMP - Iterator j; void *id, *val; bool first = true; #endif @@ -5497,7 +5495,7 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { fputc('~', f); #if HAVE_SECCOMP - HASHMAP_FOREACH_KEY(val, id, c->syscall_filter, j) { + HASHMAP_FOREACH_KEY(val, id, c->syscall_filter) { _cleanup_free_ char *name = NULL; const char *errno_name = NULL; int num = PTR_TO_INT(val); @@ -5525,7 +5523,6 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { if (c->syscall_archs) { #if HAVE_SECCOMP - Iterator j; void *id; #endif @@ -5534,7 +5531,7 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { prefix); #if HAVE_SECCOMP - SET_FOREACH(id, c->syscall_archs, j) + SET_FOREACH(id, c->syscall_archs) fprintf(f, " %s", strna(seccomp_arch_to_string(PTR_TO_UINT32(id) - 1))); #endif fputc('\n', f); @@ -6100,13 +6097,12 @@ ExecRuntime *exec_runtime_unref(ExecRuntime *rt, bool destroy) { int exec_runtime_serialize(const Manager *m, FILE *f, FDSet *fds) { ExecRuntime *rt; - Iterator i; assert(m); assert(f); assert(fds); - HASHMAP_FOREACH(rt, m->exec_runtime_by_id, i) { + HASHMAP_FOREACH(rt, m->exec_runtime_by_id) { fprintf(f, "exec-runtime=%s", rt->id); if (rt->tmp_dir) @@ -6309,13 +6305,12 @@ finalize: void exec_runtime_vacuum(Manager *m) { ExecRuntime *rt; - Iterator i; assert(m); /* Free unreferenced ExecRuntime objects. This is used after manager deserialization process. */ - HASHMAP_FOREACH(rt, m->exec_runtime_by_id, i) { + HASHMAP_FOREACH(rt, m->exec_runtime_by_id) { if (rt->n_ref > 0) continue; diff --git a/src/core/job.c b/src/core/job.c index d97cb64d38..063f3f7892 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -458,7 +458,6 @@ int job_type_merge_and_collapse(JobType *a, JobType b, Unit *u) { } static bool job_is_runnable(Job *j) { - Iterator i; Unit *other; void *v; @@ -482,7 +481,7 @@ static bool job_is_runnable(Job *j) { if (j->type == JOB_NOP) return true; - HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER], i) + HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER]) if (other->job && job_compare(j, other->job, UNIT_AFTER) > 0) { log_unit_debug(j->unit, "starting held back, waiting for: %s", @@ -490,7 +489,7 @@ static bool job_is_runnable(Job *j) { return false; } - HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE], i) + HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE]) if (other->job && job_compare(j, other->job, UNIT_BEFORE) > 0) { log_unit_debug(j->unit, "stopping held back, waiting for: %s", @@ -957,12 +956,11 @@ static void job_emit_done_status_message(Unit *u, uint32_t job_id, JobType t, Jo static void job_fail_dependencies(Unit *u, UnitDependency d) { Unit *other; - Iterator i; void *v; assert(u); - HASHMAP_FOREACH_KEY(v, other, u->dependencies[d], i) { + HASHMAP_FOREACH_KEY(v, other, u->dependencies[d]) { Job *j = other->job; if (!j) @@ -978,7 +976,6 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr Unit *u; Unit *other; JobType t; - Iterator i; void *v; assert(j); @@ -1072,12 +1069,12 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr finish: /* Try to start the next jobs that can be started */ - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_AFTER], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_AFTER]) if (other->job) { job_add_to_run_queue(other->job); job_add_to_gc_queue(other->job); } - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BEFORE], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BEFORE]) if (other->job) { job_add_to_run_queue(other->job); job_add_to_gc_queue(other->job); @@ -1427,7 +1424,6 @@ int job_get_timeout(Job *j, usec_t *timeout) { bool job_may_gc(Job *j) { Unit *other; - Iterator i; void *v; assert(j); @@ -1457,11 +1453,11 @@ bool job_may_gc(Job *j) { return false; /* The logic is inverse to job_is_runnable, we cannot GC as long as we block any job. */ - HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE], i) + HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE]) if (other->job && job_compare(j, other->job, UNIT_BEFORE) < 0) return false; - HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER], i) + HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER]) if (other->job && job_compare(j, other->job, UNIT_AFTER) < 0) return false; @@ -1508,7 +1504,6 @@ int job_get_before(Job *j, Job*** ret) { _cleanup_free_ Job** list = NULL; size_t n = 0, n_allocated = 0; Unit *other = NULL; - Iterator i; void *v; /* Returns a list of all pending jobs that need to finish before this job may be started. */ @@ -1521,7 +1516,7 @@ int job_get_before(Job *j, Job*** ret) { return 0; } - HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER], i) { + HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER]) { if (!other->job) continue; if (job_compare(j, other->job, UNIT_AFTER) <= 0) @@ -1532,7 +1527,7 @@ int job_get_before(Job *j, Job*** ret) { list[n++] = other->job; } - HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE], i) { + HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE]) { if (!other->job) continue; if (job_compare(j, other->job, UNIT_BEFORE) <= 0) @@ -1555,14 +1550,13 @@ int job_get_after(Job *j, Job*** ret) { size_t n = 0, n_allocated = 0; Unit *other = NULL; void *v; - Iterator i; assert(j); assert(ret); /* Returns a list of all pending jobs that are waiting for this job to finish. */ - HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE], i) { + HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE]) { if (!other->job) continue; @@ -1577,7 +1571,7 @@ int job_get_after(Job *j, Job*** ret) { list[n++] = other->job; } - HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER], i) { + HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER]) { if (!other->job) continue; diff --git a/src/core/killall.c b/src/core/killall.c index 075c705ca7..0272fdb0da 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -79,10 +79,9 @@ static bool ignore_proc(pid_t pid, bool warn_rootfs) { static void log_children_no_yet_killed(Set *pids) { _cleanup_free_ char *lst_child = NULL; - Iterator i; void *p; - SET_FOREACH(p, pids, i) { + SET_FOREACH(p, pids) { _cleanup_free_ char *s = NULL; if (get_process_comm(PTR_TO_PID(p), &s) < 0) @@ -121,7 +120,6 @@ static int wait_for_children(Set *pids, sigset_t *mask, usec_t timeout) { struct timespec ts; int k; void *p; - Iterator i; /* First, let the kernel inform us about killed * children. Most processes will probably be our @@ -145,7 +143,7 @@ static int wait_for_children(Set *pids, sigset_t *mask, usec_t timeout) { /* Now explicitly check who might be remaining, who * might not be our child. */ - SET_FOREACH(p, pids, i) { + SET_FOREACH(p, pids) { /* kill(pid, 0) sends no signal, but it tells * us whether the process still exists. */ diff --git a/src/core/manager.c b/src/core/manager.c index 5372e81d97..b6165bd7e8 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -198,7 +198,6 @@ static void manager_flip_auto_status(Manager *m, bool enable, const char *reason static void manager_print_jobs_in_progress(Manager *m) { _cleanup_free_ char *job_of_n = NULL; - Iterator i; Job *j; unsigned counter = 0, print_nr; char cylon[6 + CYLON_BUFFER_EXTRA + 1]; @@ -213,7 +212,7 @@ static void manager_print_jobs_in_progress(Manager *m) { print_nr = (m->jobs_in_progress_iteration / JOBS_IN_PROGRESS_PERIOD_DIVISOR) % m->n_running_jobs; - HASHMAP_FOREACH(j, m->jobs, i) + HASHMAP_FOREACH(j, m->jobs) if (j->state == JOB_RUNNING && counter++ == print_nr) break; @@ -1147,13 +1146,12 @@ enum { static void unit_gc_mark_good(Unit *u, unsigned gc_marker) { Unit *other; - Iterator i; void *v; u->gc_marker = gc_marker + GC_OFFSET_GOOD; /* Recursively mark referenced units as GOOD as well */ - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REFERENCES], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REFERENCES]) if (other->gc_marker == gc_marker + GC_OFFSET_UNSURE) unit_gc_mark_good(other, gc_marker); } @@ -1161,7 +1159,6 @@ static void unit_gc_mark_good(Unit *u, unsigned gc_marker) { static void unit_gc_sweep(Unit *u, unsigned gc_marker) { Unit *other; bool is_bad; - Iterator i; void *v; assert(u); @@ -1180,7 +1177,7 @@ static void unit_gc_sweep(Unit *u, unsigned gc_marker) { is_bad = true; - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REFERENCED_BY], i) { + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REFERENCED_BY]) { unit_gc_sweep(other, gc_marker); if (other->gc_marker == gc_marker + GC_OFFSET_GOOD) @@ -1474,7 +1471,6 @@ static void manager_enumerate(Manager *m) { } static void manager_coldplug(Manager *m) { - Iterator i; Unit *u; char *k; int r; @@ -1484,7 +1480,7 @@ static void manager_coldplug(Manager *m) { log_debug("Invoking unit coldplug() handlers…"); /* Let's place the units back into their deserialized state */ - HASHMAP_FOREACH_KEY(u, k, m->units, i) { + HASHMAP_FOREACH_KEY(u, k, m->units) { /* ignore aliases */ if (u->id != k) @@ -1497,7 +1493,6 @@ static void manager_coldplug(Manager *m) { } static void manager_catchup(Manager *m) { - Iterator i; Unit *u; char *k; @@ -1506,7 +1501,7 @@ static void manager_catchup(Manager *m) { log_debug("Invoking unit catchup() handlers…"); /* Let's catch up on any state changes that happened while we were reloading/reexecing */ - HASHMAP_FOREACH_KEY(u, k, m->units, i) { + HASHMAP_FOREACH_KEY(u, k, m->units) { /* ignore aliases */ if (u->id != k) @@ -1517,12 +1512,11 @@ static void manager_catchup(Manager *m) { } static void manager_distribute_fds(Manager *m, FDSet *fds) { - Iterator i; Unit *u; assert(m); - HASHMAP_FOREACH(u, m->units, i) { + HASHMAP_FOREACH(u, m->units) { if (fdset_size(fds) <= 0) break; @@ -1903,10 +1897,9 @@ static int manager_dispatch_target_deps_queue(Manager *m) { for (k = 0; k < ELEMENTSOF(deps); k++) { Unit *target; - Iterator i; void *v; - HASHMAP_FOREACH_KEY(v, target, u->dependencies[deps[k]], i) { + HASHMAP_FOREACH_KEY(v, target, u->dependencies[deps[k]]) { r = unit_add_default_target_dependency(u, target); if (r < 0) return r; @@ -2099,25 +2092,23 @@ int manager_load_startable_unit_or_warn( } void manager_dump_jobs(Manager *s, FILE *f, const char *prefix) { - Iterator i; Job *j; assert(s); assert(f); - HASHMAP_FOREACH(j, s->jobs, i) + HASHMAP_FOREACH(j, s->jobs) job_dump(j, f, prefix); } void manager_dump_units(Manager *s, FILE *f, const char *prefix) { - Iterator i; Unit *u; const char *t; assert(s); assert(f); - HASHMAP_FOREACH_KEY(u, t, s->units, i) + HASHMAP_FOREACH_KEY(u, t, s->units) if (u->id == t) unit_dump(u, f, prefix); } @@ -2840,7 +2831,6 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) { Manager *m = userdata; - Iterator i; Unit *u; assert(m); @@ -2853,7 +2843,7 @@ static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint /* Restart the watch */ (void) manager_setup_time_change(m); - HASHMAP_FOREACH(u, m->units, i) + HASHMAP_FOREACH(u, m->units) if (UNIT_VTABLE(u)->time_change) UNIT_VTABLE(u)->time_change(u); @@ -2867,7 +2857,6 @@ static int manager_dispatch_timezone_change( Manager *m = userdata; int changed; - Iterator i; Unit *u; assert(m); @@ -2886,7 +2875,7 @@ static int manager_dispatch_timezone_change( log_debug("Timezone has been changed (now: %s).", tzname[daylight]); - HASHMAP_FOREACH(u, m->units, i) + HASHMAP_FOREACH(u, m->units) if (UNIT_VTABLE(u)->timezone_change) UNIT_VTABLE(u)->timezone_change(u); @@ -3189,7 +3178,6 @@ static void manager_serialize_uid_refs_internal( Hashmap **uid_refs, const char *field_name) { - Iterator i; void *p, *k; assert(m); @@ -3200,7 +3188,7 @@ static void manager_serialize_uid_refs_internal( /* Serialize the UID reference table. Or actually, just the IPC destruction flag of it, as * the actual counter of it is better rebuild after a reload/reexec. */ - HASHMAP_FOREACH_KEY(p, k, *uid_refs, i) { + HASHMAP_FOREACH_KEY(p, k, *uid_refs) { uint32_t c; uid_t uid; @@ -3230,7 +3218,6 @@ int manager_serialize( ManagerTimestamp q; const char *t; - Iterator i; Unit *u; int r; @@ -3323,7 +3310,7 @@ int manager_serialize( (void) fputc('\n', f); - HASHMAP_FOREACH_KEY(u, t, m->units, i) { + HASHMAP_FOREACH_KEY(u, t, m->units) { if (u->id != t) continue; @@ -3826,11 +3813,10 @@ int manager_reload(Manager *m) { void manager_reset_failed(Manager *m) { Unit *u; - Iterator i; assert(m); - HASHMAP_FOREACH(u, m->units, i) + HASHMAP_FOREACH(u, m->units) unit_reset_failed(u); } @@ -4663,14 +4649,13 @@ static void manager_vacuum_uid_refs_internal( Hashmap **uid_refs, int (*_clean_ipc)(uid_t uid)) { - Iterator i; void *p, *k; assert(m); assert(uid_refs); assert(_clean_ipc); - HASHMAP_FOREACH_KEY(p, k, *uid_refs, i) { + HASHMAP_FOREACH_KEY(p, k, *uid_refs) { uint32_t c, n; uid_t uid; diff --git a/src/core/mount.c b/src/core/mount.c index 6e9d61ff18..dbbb73f3d5 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -281,7 +281,6 @@ static int update_parameters_proc_self_mountinfo( static int mount_add_mount_dependencies(Mount *m) { MountParameters *pm; Unit *other; - Iterator i; Set *s; int r; @@ -315,7 +314,7 @@ static int mount_add_mount_dependencies(Mount *m) { /* Adds in dependencies to other units that use this path or paths further down in the hierarchy */ s = manager_get_units_requiring_mounts_for(UNIT(m)->manager, m->where); - SET_FOREACH(other, s, i) { + SET_FOREACH(other, s) { if (other->load_state != UNIT_LOADED) continue; @@ -1903,7 +1902,6 @@ static int drain_libmount(Manager *m) { static int mount_process_proc_self_mountinfo(Manager *m) { _cleanup_set_free_free_ Set *around = NULL, *gone = NULL; const char *what; - Iterator i; Unit *u; int r; @@ -2001,7 +1999,7 @@ static int mount_process_proc_self_mountinfo(Manager *m) { mount->proc_flags = 0; } - SET_FOREACH(what, gone, i) { + SET_FOREACH(what, gone) { if (set_contains(around, what)) continue; diff --git a/src/core/service.c b/src/core/service.c index dec6b2c9ea..14c90c26df 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1273,13 +1273,12 @@ static int service_collect_fds( rn_socket_fds = 1; } else { - Iterator i; void *v; Unit *u; /* Pass all our configured sockets for singleton services */ - HASHMAP_FOREACH_KEY(v, u, UNIT(s)->dependencies[UNIT_TRIGGERED_BY], i) { + HASHMAP_FOREACH_KEY(v, u, UNIT(s)->dependencies[UNIT_TRIGGERED_BY]) { _cleanup_free_ int *cfds = NULL; Socket *sock; int cn_fds; diff --git a/src/core/slice.c b/src/core/slice.c index f4f63fcb5b..aa7e7555e5 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -351,11 +351,10 @@ static void slice_enumerate_perpetual(Manager *m) { static bool slice_freezer_action_supported_by_children(Unit *s) { Unit *member; void *v; - Iterator i; assert(s); - HASHMAP_FOREACH_KEY(v, member, s->dependencies[UNIT_BEFORE], i) { + HASHMAP_FOREACH_KEY(v, member, s->dependencies[UNIT_BEFORE]) { int r; if (UNIT_DEREF(member->slice) != s) @@ -377,7 +376,6 @@ static bool slice_freezer_action_supported_by_children(Unit *s) { static int slice_freezer_action(Unit *s, FreezerAction action) { Unit *member; void *v; - Iterator i; int r; assert(s); @@ -386,7 +384,7 @@ static int slice_freezer_action(Unit *s, FreezerAction action) { if (!slice_freezer_action_supported_by_children(s)) return log_unit_warning(s, "Requested freezer operation is not supported by all children of the slice"); - HASHMAP_FOREACH_KEY(v, member, s->dependencies[UNIT_BEFORE], i) { + HASHMAP_FOREACH_KEY(v, member, s->dependencies[UNIT_BEFORE]) { if (UNIT_DEREF(member->slice) != s) continue; diff --git a/src/core/socket.c b/src/core/socket.c index 20c09b2a3f..855b354dd8 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -2338,12 +2338,11 @@ static void socket_enter_running(Socket *s, int cfd_in) { if (cfd < 0) { bool pending = false; Unit *other; - Iterator i; void *v; /* If there's already a start pending don't bother to * do anything */ - HASHMAP_FOREACH_KEY(v, other, UNIT(s)->dependencies[UNIT_TRIGGERS], i) + HASHMAP_FOREACH_KEY(v, other, UNIT(s)->dependencies[UNIT_TRIGGERS]) if (unit_active_or_pending(other)) { pending = true; break; @@ -2788,7 +2787,6 @@ static void socket_distribute_fds(Unit *u, FDSet *fds) { assert(u); LIST_FOREACH(port, p, s->ports) { - Iterator i; int fd; if (p->type != SOCKET_SOCKET) @@ -2797,7 +2795,7 @@ static void socket_distribute_fds(Unit *u, FDSet *fds) { if (p->fd >= 0) continue; - FDSET_FOREACH(fd, fds, i) { + FDSET_FOREACH(fd, fds) { if (socket_address_matches_fd(&p->address, fd)) { p->fd = fdset_remove(fds, fd); s->deserialized_state = SOCKET_LISTENING; diff --git a/src/core/target.c b/src/core/target.c index 65affcec19..3f85773b24 100644 --- a/src/core/target.c +++ b/src/core/target.c @@ -57,10 +57,9 @@ static int target_add_default_dependencies(Target *t) { for (k = 0; k < ELEMENTSOF(deps); k++) { Unit *other; - Iterator i; void *v; - HASHMAP_FOREACH_KEY(v, other, UNIT(t)->dependencies[deps[k]], i) { + HASHMAP_FOREACH_KEY(v, other, UNIT(t)->dependencies[deps[k]]) { r = unit_add_default_target_dependency(other, UNIT(t)); if (r < 0) return r; diff --git a/src/core/transaction.c b/src/core/transaction.c index 0fa419787e..ab07c80f1d 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -218,14 +218,13 @@ static int delete_one_unmergeable_job(Transaction *tr, Job *j) { static int transaction_merge_jobs(Transaction *tr, sd_bus_error *e) { Job *j; - Iterator i; int r; assert(tr); /* First step, check whether any of the jobs for one specific * task conflict. If so, try to drop one of them. */ - HASHMAP_FOREACH(j, tr->jobs, i) { + HASHMAP_FOREACH(j, tr->jobs) { JobType t; Job *k; @@ -256,7 +255,7 @@ static int transaction_merge_jobs(Transaction *tr, sd_bus_error *e) { } /* Second step, merge the jobs. */ - HASHMAP_FOREACH(j, tr->jobs, i) { + HASHMAP_FOREACH(j, tr->jobs) { JobType t = j->type; Job *k; @@ -288,12 +287,11 @@ static void transaction_drop_redundant(Transaction *tr) { assert(tr); do { - Iterator i; Job *j; again = false; - HASHMAP_FOREACH(j, tr->jobs, i) { + HASHMAP_FOREACH(j, tr->jobs) { bool keep = false; Job *k; @@ -349,7 +347,6 @@ static char* merge_unit_ids(const char* unit_log_field, char **pairs) { } static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsigned generation, sd_bus_error *e) { - Iterator i; Unit *u; void *v; int r; @@ -453,7 +450,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi * ordering dependencies and we test with job_compare() whether it is the 'before' edge in the job * execution ordering. */ for (d = 0; d < ELEMENTSOF(directions); d++) { - HASHMAP_FOREACH_KEY(v, u, j->unit->dependencies[directions[d]], i) { + HASHMAP_FOREACH_KEY(v, u, j->unit->dependencies[directions[d]]) { Job *o; /* Is there a job for this unit? */ @@ -487,7 +484,6 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi static int transaction_verify_order(Transaction *tr, unsigned *generation, sd_bus_error *e) { Job *j; int r; - Iterator i; unsigned g; assert(tr); @@ -498,7 +494,7 @@ static int transaction_verify_order(Transaction *tr, unsigned *generation, sd_bu g = (*generation)++; - HASHMAP_FOREACH(j, tr->jobs, i) { + HASHMAP_FOREACH(j, tr->jobs) { r = transaction_verify_order_one(tr, j, NULL, g, e); if (r < 0) return r; @@ -515,12 +511,11 @@ static void transaction_collect_garbage(Transaction *tr) { /* Drop jobs that are not required by any other job */ do { - Iterator i; Job *j; again = false; - HASHMAP_FOREACH(j, tr->jobs, i) { + HASHMAP_FOREACH(j, tr->jobs) { if (tr->anchor_job == j) continue; @@ -541,7 +536,6 @@ static void transaction_collect_garbage(Transaction *tr) { } static int transaction_is_destructive(Transaction *tr, JobMode mode, sd_bus_error *e) { - Iterator i; Job *j; assert(tr); @@ -549,7 +543,7 @@ static int transaction_is_destructive(Transaction *tr, JobMode mode, sd_bus_erro /* Checks whether applying this transaction means that * existing jobs would be replaced */ - HASHMAP_FOREACH(j, tr->jobs, i) { + HASHMAP_FOREACH(j, tr->jobs) { /* Assume merged */ assert(!j->transaction_prev); @@ -568,7 +562,6 @@ static int transaction_is_destructive(Transaction *tr, JobMode mode, sd_bus_erro static void transaction_minimize_impact(Transaction *tr) { Job *j; - Iterator i; assert(tr); @@ -576,7 +569,7 @@ static void transaction_minimize_impact(Transaction *tr) { * or that stop a running service. */ rescan: - HASHMAP_FOREACH(j, tr->jobs, i) { + HASHMAP_FOREACH(j, tr->jobs) { LIST_FOREACH(transaction, j, j) { bool stops_running_service, changes_existing_job; @@ -625,7 +618,6 @@ static int transaction_apply( JobMode mode, Set *affected_jobs) { - Iterator i; Job *j; int r; @@ -635,7 +627,7 @@ static int transaction_apply( /* When isolating first kill all installed jobs which * aren't part of the new transaction */ - HASHMAP_FOREACH(j, m->jobs, i) { + HASHMAP_FOREACH(j, m->jobs) { assert(j->installed); if (j->unit->ignore_on_isolate) @@ -651,7 +643,7 @@ static int transaction_apply( } } - HASHMAP_FOREACH(j, tr->jobs, i) { + HASHMAP_FOREACH(j, tr->jobs) { /* Assume merged */ assert(!j->transaction_prev); assert(!j->transaction_next); @@ -696,7 +688,7 @@ static int transaction_apply( rollback: - HASHMAP_FOREACH(j, tr->jobs, i) + HASHMAP_FOREACH(j, tr->jobs) hashmap_remove(m->jobs, UINT32_TO_PTR(j->id)); return r; @@ -709,7 +701,6 @@ int transaction_activate( Set *affected_jobs, sd_bus_error *e) { - Iterator i; Job *j; int r; unsigned generation = 1; @@ -722,7 +713,7 @@ int transaction_activate( /* Reset the generation counter of all installed jobs. The detection of cycles * looks at installed jobs. If they had a non-zero generation from some previous * walk of the graph, the algorithm would break. */ - HASHMAP_FOREACH(j, m->jobs, i) + HASHMAP_FOREACH(j, m->jobs) j->generation = 0; /* First step: figure out which jobs matter */ @@ -890,7 +881,6 @@ static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependen } void transaction_add_propagate_reload_jobs(Transaction *tr, Unit *unit, Job *by, bool ignore_order, sd_bus_error *e) { - Iterator i; JobType nt; Unit *dep; void *v; @@ -899,7 +889,7 @@ void transaction_add_propagate_reload_jobs(Transaction *tr, Unit *unit, Job *by, assert(tr); assert(unit); - HASHMAP_FOREACH_KEY(v, dep, unit->dependencies[UNIT_PROPAGATES_RELOAD_TO], i) { + HASHMAP_FOREACH_KEY(v, dep, unit->dependencies[UNIT_PROPAGATES_RELOAD_TO]) { nt = job_type_collapse(JOB_TRY_RELOAD, dep); if (nt == JOB_NOP) continue; @@ -926,7 +916,6 @@ int transaction_add_job_and_dependencies( sd_bus_error *e) { bool is_new; - Iterator i; Unit *dep; Job *ret; void *v; @@ -1006,7 +995,7 @@ int transaction_add_job_and_dependencies( /* If we are following some other unit, make sure we * add all dependencies of everybody following. */ if (unit_following_set(ret->unit, &following) > 0) { - SET_FOREACH(dep, following, i) { + SET_FOREACH(dep, following) { r = transaction_add_job_and_dependencies(tr, type, dep, ret, false, false, false, ignore_order, e); if (r < 0) { log_unit_full(dep, @@ -1022,7 +1011,7 @@ int transaction_add_job_and_dependencies( /* Finally, recursively add in all dependencies. */ if (IN_SET(type, JOB_START, JOB_RESTART)) { - HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_REQUIRES], i) { + HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_REQUIRES]) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e); if (r < 0) { if (r != -EBADR) /* job type not applicable */ @@ -1032,7 +1021,7 @@ int transaction_add_job_and_dependencies( } } - HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_BINDS_TO], i) { + HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_BINDS_TO]) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e); if (r < 0) { if (r != -EBADR) /* job type not applicable */ @@ -1042,7 +1031,7 @@ int transaction_add_job_and_dependencies( } } - HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_WANTS], i) { + HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_WANTS]) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, ignore_order, e); if (r < 0) { /* unit masked, job type not applicable and unit not found are not considered as errors. */ @@ -1054,7 +1043,7 @@ int transaction_add_job_and_dependencies( } } - HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_REQUISITE], i) { + HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_REQUISITE]) { r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, false, false, ignore_order, e); if (r < 0) { if (r != -EBADR) /* job type not applicable */ @@ -1064,7 +1053,7 @@ int transaction_add_job_and_dependencies( } } - HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_CONFLICTS], i) { + HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_CONFLICTS]) { r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, true, false, ignore_order, e); if (r < 0) { if (r != -EBADR) /* job type not applicable */ @@ -1074,7 +1063,7 @@ int transaction_add_job_and_dependencies( } } - HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_CONFLICTED_BY], i) { + HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[UNIT_CONFLICTED_BY]) { r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, false, false, false, ignore_order, e); if (r < 0) { log_unit_warning(dep, @@ -1103,7 +1092,7 @@ int transaction_add_job_and_dependencies( ptype = type == JOB_RESTART ? JOB_TRY_RESTART : type; for (j = 0; j < ELEMENTSOF(propagate_deps); j++) - HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[propagate_deps[j]], i) { + HASHMAP_FOREACH_KEY(v, dep, ret->unit->dependencies[propagate_deps[j]]) { JobType nt; nt = job_type_collapse(ptype, dep); @@ -1133,7 +1122,6 @@ fail: } int transaction_add_isolate_jobs(Transaction *tr, Manager *m) { - Iterator i; Unit *u; char *k; int r; @@ -1141,7 +1129,7 @@ int transaction_add_isolate_jobs(Transaction *tr, Manager *m) { assert(tr); assert(m); - HASHMAP_FOREACH_KEY(u, k, m->units, i) { + HASHMAP_FOREACH_KEY(u, k, m->units) { /* ignore aliases */ if (u->id != k) @@ -1167,7 +1155,6 @@ int transaction_add_isolate_jobs(Transaction *tr, Manager *m) { } int transaction_add_triggering_jobs(Transaction *tr, Unit *u) { - Iterator i; void *v; Unit *trigger; int r; @@ -1175,7 +1162,7 @@ int transaction_add_triggering_jobs(Transaction *tr, Unit *u) { assert(tr); assert(u); - HASHMAP_FOREACH_KEY(v, trigger, u->dependencies[UNIT_TRIGGERED_BY], i) { + HASHMAP_FOREACH_KEY(v, trigger, u->dependencies[UNIT_TRIGGERED_BY]) { /* No need to stop inactive jobs */ if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(trigger)) && !trigger->job) continue; diff --git a/src/core/unit.c b/src/core/unit.c index eb8d5d6a82..96a21b95b3 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -510,14 +510,13 @@ void unit_submit_to_stop_when_unneeded_queue(Unit *u) { static void bidi_set_free(Unit *u, Hashmap *h) { Unit *other; - Iterator i; void *v; assert(u); /* Frees the hashmap and makes sure we are dropped from the inverse pointers */ - HASHMAP_FOREACH_KEY(v, other, h, i) { + HASHMAP_FOREACH_KEY(v, other, h) { for (UnitDependency d = 0; d < _UNIT_DEPENDENCY_MAX; d++) hashmap_remove(other->dependencies[d], u); @@ -614,7 +613,6 @@ static void unit_done(Unit *u) { } void unit_free(Unit *u) { - Iterator i; char *t; if (!u) @@ -638,7 +636,7 @@ void unit_free(Unit *u) { unit_free_requires_mounts_for(u); - SET_FOREACH(t, u->aliases, i) + SET_FOREACH(t, u->aliases) hashmap_remove_value(u->manager->units, t, u); if (u->id) hashmap_remove_value(u->manager->units, u->id, u); @@ -819,7 +817,6 @@ static int hashmap_complete_move(Hashmap **s, Hashmap **other) { static int merge_names(Unit *u, Unit *other) { char *name; - Iterator i; int r; assert(u); @@ -838,7 +835,7 @@ static int merge_names(Unit *u, Unit *other) { TAKE_PTR(other->id); other->aliases = set_free_free(other->aliases); - SET_FOREACH(name, u->aliases, i) + SET_FOREACH(name, u->aliases) assert_se(hashmap_replace(u->manager->units, name, u) == 0); return 0; @@ -866,7 +863,6 @@ static int reserve_dependencies(Unit *u, Unit *other, UnitDependency d) { } static void merge_dependencies(Unit *u, Unit *other, const char *other_id, UnitDependency d) { - Iterator i; Unit *back; void *v; int r; @@ -878,7 +874,7 @@ static void merge_dependencies(Unit *u, Unit *other, const char *other_id, UnitD assert(d < _UNIT_DEPENDENCY_MAX); /* Fix backwards pointers. Let's iterate through all dependent units of the other unit. */ - HASHMAP_FOREACH_KEY(v, back, other->dependencies[d], i) + HASHMAP_FOREACH_KEY(v, back, other->dependencies[d]) /* Let's now iterate through the dependencies of that dependencies of the other units, * looking for pointers back, and let's fix them up, to instead point to 'u'. */ @@ -1216,7 +1212,6 @@ static void print_unit_dependency_mask(FILE *f, const char *kind, UnitDependency void unit_dump(Unit *u, FILE *f, const char *prefix) { char *t, **j; - Iterator i; const char *prefix2; char timestamp[5][FORMAT_TIMESTAMP_MAX], timespan[FORMAT_TIMESPAN_MAX]; Unit *following; @@ -1234,7 +1229,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { "%s-> Unit %s:\n", prefix, u->id); - SET_FOREACH(t, u->aliases, i) + SET_FOREACH(t, u->aliases) fprintf(f, "%s\tAlias: %s\n", prefix, t); fprintf(f, @@ -1321,7 +1316,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { if (r >= 0) { Unit *other; - SET_FOREACH(other, following_set, i) + SET_FOREACH(other, following_set) fprintf(f, "%s\tFollowing Set Member: %s\n", prefix, other->id); } @@ -1373,7 +1368,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { UnitDependencyInfo di; Unit *other; - HASHMAP_FOREACH_KEY(di.data, other, u->dependencies[d], i) { + HASHMAP_FOREACH_KEY(di.data, other, u->dependencies[d]) { bool space = false; fprintf(f, "%s\t%s: %s (", prefix, unit_dependency_to_string(d), other->id); @@ -1389,7 +1384,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { UnitDependencyInfo di; const char *path; - HASHMAP_FOREACH_KEY(di.data, path, u->requires_mounts_for, i) { + HASHMAP_FOREACH_KEY(di.data, path, u->requires_mounts_for) { bool space = false; fprintf(f, "%s\tRequiresMountsFor: %s (", prefix, path); @@ -1536,12 +1531,11 @@ static int unit_add_slice_dependencies(Unit *u) { static int unit_add_mount_dependencies(Unit *u) { UnitDependencyInfo di; const char *path; - Iterator i; int r; assert(u); - HASHMAP_FOREACH_KEY(di.data, path, u->requires_mounts_for, i) { + HASHMAP_FOREACH_KEY(di.data, path, u->requires_mounts_for) { char prefix[strlen(path) + 1]; PATH_FOREACH_PREFIX_MORE(prefix, path) { @@ -1804,7 +1798,6 @@ bool unit_shall_confirm_spawn(Unit *u) { static bool unit_verify_deps(Unit *u) { Unit *other; - Iterator j; void *v; assert(u); @@ -1814,7 +1807,7 @@ static bool unit_verify_deps(Unit *u) { * processing, but do not have any effect afterwards. We don't check BindsTo= dependencies that are not used in * conjunction with After= as for them any such check would make things entirely racy. */ - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BINDS_TO], j) { + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BINDS_TO]) { if (!hashmap_contains(u->dependencies[UNIT_AFTER], other)) continue; @@ -2055,13 +2048,12 @@ bool unit_is_unneeded(Unit *u) { for (size_t j = 0; j < ELEMENTSOF(deps); j++) { Unit *other; - Iterator i; void *v; /* If a dependent unit has a job queued, is active or transitioning, or is marked for * restart, then don't clean this one up. */ - HASHMAP_FOREACH_KEY(v, other, u->dependencies[deps[j]], i) { + HASHMAP_FOREACH_KEY(v, other, u->dependencies[deps[j]]) { if (other->job) return false; @@ -2091,10 +2083,9 @@ static void check_unneeded_dependencies(Unit *u) { for (size_t j = 0; j < ELEMENTSOF(deps); j++) { Unit *other; - Iterator i; void *v; - HASHMAP_FOREACH_KEY(v, other, u->dependencies[deps[j]], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[deps[j]]) unit_submit_to_stop_when_unneeded_queue(other); } } @@ -2103,7 +2094,6 @@ static void unit_check_binds_to(Unit *u) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; bool stop = false; Unit *other; - Iterator i; void *v; int r; @@ -2115,7 +2105,7 @@ static void unit_check_binds_to(Unit *u) { if (unit_active_state(u) != UNIT_ACTIVE) return; - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BINDS_TO], i) { + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BINDS_TO]) { if (other->job) continue; @@ -2151,54 +2141,51 @@ static void unit_check_binds_to(Unit *u) { } static void retroactively_start_dependencies(Unit *u) { - Iterator i; Unit *other; void *v; assert(u); assert(UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u))); - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REQUIRES], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REQUIRES]) if (!hashmap_get(u->dependencies[UNIT_AFTER], other) && !UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other))) manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, NULL, NULL, NULL); - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BINDS_TO], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BINDS_TO]) if (!hashmap_get(u->dependencies[UNIT_AFTER], other) && !UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other))) manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, NULL, NULL, NULL); - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_WANTS], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_WANTS]) if (!hashmap_get(u->dependencies[UNIT_AFTER], other) && !UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other))) manager_add_job(u->manager, JOB_START, other, JOB_FAIL, NULL, NULL, NULL); - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_CONFLICTS], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_CONFLICTS]) if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other))) manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL, NULL); - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_CONFLICTED_BY], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_CONFLICTED_BY]) if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other))) manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL, NULL); } static void retroactively_stop_dependencies(Unit *u) { Unit *other; - Iterator i; void *v; assert(u); assert(UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u))); /* Pull down units which are bound to us recursively if enabled */ - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BOUND_BY], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BOUND_BY]) if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other))) manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL, NULL); } void unit_start_on_failure(Unit *u) { Unit *other; - Iterator i; void *v; int r; @@ -2209,7 +2196,7 @@ void unit_start_on_failure(Unit *u) { log_unit_info(u, "Triggering OnFailure= dependencies."); - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_ON_FAILURE], i) { + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_ON_FAILURE]) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; r = manager_add_job(u->manager, JOB_START, other, u->on_failure_job_mode, NULL, &error, NULL); @@ -2220,12 +2207,11 @@ void unit_start_on_failure(Unit *u) { void unit_trigger_notify(Unit *u) { Unit *other; - Iterator i; void *v; assert(u); - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_TRIGGERED_BY], i) + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_TRIGGERED_BY]) if (UNIT_VTABLE(other)->trigger_notify) UNIT_VTABLE(other)->trigger_notify(other, u); } @@ -2820,7 +2806,6 @@ void unit_unwatch_all_pids(Unit *u) { static void unit_tidy_watch_pids(Unit *u) { pid_t except1, except2; - Iterator i; void *e; assert(u); @@ -2830,7 +2815,7 @@ static void unit_tidy_watch_pids(Unit *u) { except1 = unit_main_pid(u); except2 = unit_control_pid(u); - SET_FOREACH(e, u->pids, i) { + SET_FOREACH(e, u->pids) { pid_t pid = PTR_TO_PID(e); if (pid == except1 || pid == except2) @@ -5102,7 +5087,6 @@ int unit_setup_exec_runtime(Unit *u) { ExecRuntime **rt; size_t offset; Unit *other; - Iterator i; void *v; int r; @@ -5115,7 +5099,7 @@ int unit_setup_exec_runtime(Unit *u) { return 0; /* Try to get it from somebody else */ - HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_JOINS_NAMESPACE_OF], i) { + HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_JOINS_NAMESPACE_OF]) { r = exec_runtime_acquire(u->manager, NULL, other->id, false, rt); if (r == 1) return 1; @@ -5518,11 +5502,10 @@ void unit_remove_dependencies(Unit *u, UnitDependencyMask mask) { do { UnitDependencyInfo di; Unit *other; - Iterator i; done = true; - HASHMAP_FOREACH_KEY(di.data, other, u->dependencies[d], i) { + HASHMAP_FOREACH_KEY(di.data, other, u->dependencies[d]) { if ((di.origin_mask & ~mask) == di.origin_mask) continue; di.origin_mask &= ~mask; diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index b93fbb8660..e8550d2f75 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -644,10 +644,9 @@ static int add_crypttab_devices(void) { static int add_proc_cmdline_devices(void) { int r; - Iterator i; crypto_device *d; - HASHMAP_FOREACH(d, arg_disks, i) { + HASHMAP_FOREACH(d, arg_disks) { _cleanup_free_ char *device = NULL; if (!d->create) diff --git a/src/delta/delta.c b/src/delta/delta.c index 29e5120375..acb6020715 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -401,13 +401,9 @@ static int should_skip_path(const char *prefix, const char *suffix) { static int process_suffix(const char *suffix, const char *onlyprefix) { const char *p; - char *f; - OrderedHashmap *top, *bottom, *drops; - OrderedHashmap *h; - char *key; - int r = 0, k; - Iterator i, j; - int n_found = 0; + char *f, *key; + OrderedHashmap *top, *bottom, *drops, *h; + int r = 0, k, n_found = 0; bool dropins; assert(suffix); @@ -441,7 +437,7 @@ static int process_suffix(const char *suffix, const char *onlyprefix) { r = k; } - ORDERED_HASHMAP_FOREACH_KEY(f, key, top, i) { + ORDERED_HASHMAP_FOREACH_KEY(f, key, top) { char *o; o = ordered_hashmap_get(bottom, key); @@ -461,7 +457,7 @@ static int process_suffix(const char *suffix, const char *onlyprefix) { h = ordered_hashmap_get(drops, key); if (h) - ORDERED_HASHMAP_FOREACH(o, h, j) + ORDERED_HASHMAP_FOREACH(o, h) if (!onlyprefix || startswith(o, onlyprefix)) n_found += notify_override_extended(f, o); } @@ -470,7 +466,7 @@ finish: ordered_hashmap_free_free(top); ordered_hashmap_free_free(bottom); - ORDERED_HASHMAP_FOREACH_KEY(h, key, drops, i) { + ORDERED_HASHMAP_FOREACH_KEY(h, key, drops) { ordered_hashmap_free_free(ordered_hashmap_remove(drops, key)); ordered_hashmap_remove(drops, key); free(key); diff --git a/src/home/homed-home-bus.c b/src/home/homed-home-bus.c index 015eefb718..08f77b4f51 100644 --- a/src/home/homed-home-bus.c +++ b/src/home/homed-home-bus.c @@ -758,7 +758,6 @@ static int bus_home_node_enumerator( _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; size_t k = 0; - Iterator i; Home *h; int r; @@ -768,7 +767,7 @@ static int bus_home_node_enumerator( if (!l) return -ENOMEM; - HASHMAP_FOREACH(h, m->homes_by_uid, i) { + HASHMAP_FOREACH(h, m->homes_by_uid) { r = bus_home_path(h, l + k); if (r < 0) return r; diff --git a/src/home/homed-manager-bus.c b/src/home/homed-manager-bus.c index ce6919a1a7..fa3acb5244 100644 --- a/src/home/homed-manager-bus.c +++ b/src/home/homed-manager-bus.c @@ -25,7 +25,6 @@ static int property_get_auto_login( sd_bus_error *error) { Manager *m = userdata; - Iterator i; Home *h; int r; @@ -37,7 +36,7 @@ static int property_get_auto_login( if (r < 0) return r; - HASHMAP_FOREACH(h, m->homes_by_name, i) { + HASHMAP_FOREACH(h, m->homes_by_name) { _cleanup_(strv_freep) char **seats = NULL; _cleanup_free_ char *home_path = NULL; char **s; @@ -151,7 +150,6 @@ static int method_list_homes( _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; - Iterator i; Home *h; int r; @@ -166,7 +164,7 @@ static int method_list_homes( if (r < 0) return r; - HASHMAP_FOREACH(h, m->homes_by_uid, i) { + HASHMAP_FOREACH(h, m->homes_by_uid) { _cleanup_free_ char *path = NULL; r = bus_home_path(h, &path); @@ -560,7 +558,6 @@ static int method_lock_all_homes(sd_bus_message *message, void *userdata, sd_bus _cleanup_(operation_unrefp) Operation *o = NULL; bool waiting = false; Manager *m = userdata; - Iterator i; Home *h; int r; @@ -570,7 +567,7 @@ static int method_lock_all_homes(sd_bus_message *message, void *userdata, sd_bus * for every suitable home we have and only when all of them completed we send a reply indicating * completion. */ - HASHMAP_FOREACH(h, m->homes_by_name, i) { + HASHMAP_FOREACH(h, m->homes_by_name) { /* Automatically suspend all homes that have at least one client referencing it that asked * for "please suspend", and no client that asked for "please do not suspend". */ diff --git a/src/home/homed-manager.c b/src/home/homed-manager.c index 54761175c3..9ac375abd6 100644 --- a/src/home/homed-manager.c +++ b/src/home/homed-manager.c @@ -267,7 +267,6 @@ Manager* manager_free(Manager *m) { int manager_verify_user_record(Manager *m, UserRecord *hr) { EVP_PKEY *pkey; - Iterator i; int r; assert(m); @@ -298,7 +297,7 @@ int manager_verify_user_record(Manager *m, UserRecord *hr) { } } - HASHMAP_FOREACH(pkey, m->public_keys, i) { + HASHMAP_FOREACH(pkey, m->public_keys) { r = user_record_verify(hr, pkey); switch (r) { @@ -1606,9 +1605,8 @@ int manager_gc_images(Manager *m) { manager_revalidate_image(m, h); } else { /* Gc all */ - Iterator i; - HASHMAP_FOREACH(h, m->homes_by_name, i) + HASHMAP_FOREACH(h, m->homes_by_name) manager_revalidate_image(m, h); } diff --git a/src/home/homed-varlink.c b/src/home/homed-varlink.c index c5bbba6852..8131a16bc0 100644 --- a/src/home/homed-varlink.c +++ b/src/home/homed-varlink.c @@ -103,13 +103,12 @@ int vl_method_get_user_record(Varlink *link, JsonVariant *parameters, VarlinkMet else if (p.user_name) h = hashmap_get(m->homes_by_name, p.user_name); else { - Iterator i; /* If neither UID nor name was specified, then dump all homes. Do so with varlink_notify() * for all entries but the last, so that clients can stream the results, and easily process * them piecemeal. */ - HASHMAP_FOREACH(h, m->homes_by_name, i) { + HASHMAP_FOREACH(h, m->homes_by_name) { if (!home_user_match_lookup_parameters(&p, h)) continue; @@ -219,9 +218,8 @@ int vl_method_get_group_record(Varlink *link, JsonVariant *parameters, VarlinkMe else if (p.group_name) h = hashmap_get(m->homes_by_name, p.group_name); else { - Iterator i; - HASHMAP_FOREACH(h, m->homes_by_name, i) { + HASHMAP_FOREACH(h, m->homes_by_name) { if (!home_group_match_lookup_parameters(&p, h)) continue; @@ -315,9 +313,8 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet } else if (p.group_name) { const char *last = NULL; - Iterator i; - HASHMAP_FOREACH(h, m->homes_by_name, i) { + HASHMAP_FOREACH(h, m->homes_by_name) { if (!strv_contains(h->record->member_of, p.group_name)) continue; @@ -337,9 +334,8 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(p.group_name)))); } else { const char *last_user_name = NULL, *last_group_name = NULL; - Iterator i; - HASHMAP_FOREACH(h, m->homes_by_name, i) { + HASHMAP_FOREACH(h, m->homes_by_name) { char **j; STRV_FOREACH(j, h->record->member_of) { diff --git a/src/import/importd.c b/src/import/importd.c index 038dd3a6c6..17944b8dd3 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -562,7 +562,6 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void Manager *m = userdata; char *p, *e; Transfer *t; - Iterator i; ssize_t n; int r; @@ -585,7 +584,7 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void return 0; } - HASHMAP_FOREACH(t, m->transfers, i) + HASHMAP_FOREACH(t, m->transfers) if (ucred->pid == t->pid) break; @@ -670,13 +669,12 @@ static int manager_new(Manager **ret) { static Transfer *manager_find(Manager *m, TransferType type, const char *remote) { Transfer *t; - Iterator i; assert(m); assert(type >= 0); assert(type < _TRANSFER_TYPE_MAX); - HASHMAP_FOREACH(t, m->transfers, i) + HASHMAP_FOREACH(t, m->transfers) if (t->type == type && streq_ptr(t->remote, remote)) return t; @@ -990,7 +988,6 @@ static int method_list_transfers(sd_bus_message *msg, void *userdata, sd_bus_err _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; Transfer *t; - Iterator i; int r; assert(msg); @@ -1004,7 +1001,7 @@ static int method_list_transfers(sd_bus_message *msg, void *userdata, sd_bus_err if (r < 0) return r; - HASHMAP_FOREACH(t, m->transfers, i) { + HASHMAP_FOREACH(t, m->transfers) { r = sd_bus_message_append( reply, @@ -1162,13 +1159,12 @@ static int transfer_node_enumerator( Manager *m = userdata; Transfer *t; unsigned k = 0; - Iterator i; l = new0(char*, hashmap_size(m->transfers) + 1); if (!l) return -ENOMEM; - HASHMAP_FOREACH(t, m->transfers, i) { + HASHMAP_FOREACH(t, m->transfers) { l[k] = strdup(t->object_path); if (!l[k]) diff --git a/src/journal/catalog.c b/src/journal/catalog.c index b2589271ca..b0416da0c6 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -450,7 +450,6 @@ int catalog_update(const char* database, const char* root, const char* const* di ssize_t offset; char *payload; CatalogItem *i; - Iterator j; unsigned n; int r; int64_t sz; @@ -482,7 +481,7 @@ int catalog_update(const char* database, const char* root, const char* const* di return log_oom(); n = 0; - ORDERED_HASHMAP_FOREACH_KEY(payload, i, h, j) { + ORDERED_HASHMAP_FOREACH_KEY(payload, i, h) { log_debug("Found " SD_ID128_FORMAT_STR ", language %s", SD_ID128_FORMAT_VAL(i->id), isempty(i->language) ? "C" : i->language); diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 9d0048b8bc..52e204ee11 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1644,14 +1644,13 @@ static int add_units(sd_journal *j) { if (!strv_isempty(patterns)) { _cleanup_set_free_free_ Set *units = NULL; - Iterator it; char *u; r = get_possible_units(j, SYSTEM_UNITS, patterns, &units); if (r < 0) return r; - SET_FOREACH(u, units, it) { + SET_FOREACH(u, units) { r = add_matches_for_unit(j, u); if (r < 0) return r; @@ -1689,14 +1688,13 @@ static int add_units(sd_journal *j) { if (!strv_isempty(patterns)) { _cleanup_set_free_free_ Set *units = NULL; - Iterator it; char *u; r = get_possible_units(j, USER_UNITS, patterns, &units); if (r < 0) return r; - SET_FOREACH(u, units, it) { + SET_FOREACH(u, units) { r = add_matches_for_user_unit(j, u, getuid()); if (r < 0) return r; @@ -1745,10 +1743,9 @@ static int add_priorities(sd_journal *j) { static int add_facilities(sd_journal *j) { void *p; - Iterator it; int r; - SET_FOREACH(p, arg_facilities, it) { + SET_FOREACH(p, arg_facilities) { char match[STRLEN("SYSLOG_FACILITY=") + DECIMAL_STR_MAX(int)]; xsprintf(match, "SYSLOG_FACILITY=%d", PTR_TO_INT(p)); @@ -1960,14 +1957,13 @@ static int setup_keys(void) { static int verify(sd_journal *j) { int r = 0; - Iterator i; JournalFile *f; assert(j); log_show_color(true); - ORDERED_HASHMAP_FOREACH(f, j->files, i) { + ORDERED_HASHMAP_FOREACH(f, j->files) { int k; usec_t first = 0, validated = 0, last = 0; @@ -2327,9 +2323,8 @@ int main(int argc, char *argv[]) { case ACTION_VACUUM: { Directory *d; - Iterator i; - HASHMAP_FOREACH(d, j->directories_by_path, i) { + HASHMAP_FOREACH(d, j->directories_by_path) { int q; q = journal_directory_vacuum(d->path, arg_vacuum_size, arg_vacuum_n_files, arg_vacuum_time, NULL, !arg_quiet); diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 6df43085ec..105aefdd6e 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -473,10 +473,9 @@ static int do_rotate( static void server_process_deferred_closes(Server *s) { JournalFile *f; - Iterator i; /* Perform any deferred closes which aren't still offlining. */ - SET_FOREACH(f, s->deferred_closes, i) { + SET_FOREACH(f, s->deferred_closes) { if (journal_file_is_offlining(f)) continue; @@ -609,7 +608,6 @@ static int vacuum_offline_user_journals(Server *s) { void server_rotate(Server *s) { JournalFile *f; - Iterator i; void *k; int r; @@ -620,7 +618,7 @@ void server_rotate(Server *s) { (void) do_rotate(s, &s->system_journal, "system", s->seal, 0); /* Then, rotate all user journals we have open (keeping them open) */ - ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) { + ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals) { r = do_rotate(s, &f, "user", s->seal, PTR_TO_UID(k)); if (r >= 0) ordered_hashmap_replace(s->user_journals, k, f); @@ -639,7 +637,6 @@ void server_rotate(Server *s) { void server_sync(Server *s) { JournalFile *f; - Iterator i; int r; if (s->system_journal) { @@ -648,7 +645,7 @@ void server_sync(Server *s) { log_warning_errno(r, "Failed to sync system journal, ignoring: %m"); } - ORDERED_HASHMAP_FOREACH(f, s->user_journals, i) { + ORDERED_HASHMAP_FOREACH(f, s->user_journals) { r = journal_file_set_offline(f, false); if (r < 0) log_warning_errno(r, "Failed to sync user journal, ignoring: %m"); @@ -2433,7 +2430,6 @@ int server_init(Server *s, const char *namespace) { void server_maybe_append_tags(Server *s) { #if HAVE_GCRYPT JournalFile *f; - Iterator i; usec_t n; n = now(CLOCK_REALTIME); @@ -2441,7 +2437,7 @@ void server_maybe_append_tags(Server *s) { if (s->system_journal) journal_file_maybe_append_tag(s->system_journal, n); - ORDERED_HASHMAP_FOREACH(f, s->user_journals, i) + ORDERED_HASHMAP_FOREACH(f, s->user_journals) journal_file_maybe_append_tag(f, n); #endif } diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index 241e2572e6..b1c35a1af2 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -834,13 +834,12 @@ int server_restore_streams(Server *s, FDSet *fds) { FOREACH_DIRENT(de, d, goto fail) { unsigned long st_dev, st_ino; bool found = false; - Iterator i; int fd; if (sscanf(de->d_name, "%lu:%lu", &st_dev, &st_ino) != 2) continue; - FDSET_FOREACH(fd, fds, i) { + FDSET_FOREACH(fd, fds) { struct stat st; if (fstat(fd, &st) < 0) diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c index 9eb3e1a626..f627630c9c 100644 --- a/src/journal/mmap-cache.c +++ b/src/journal/mmap-cache.c @@ -552,7 +552,6 @@ unsigned mmap_cache_get_missed(MMapCache *m) { static void mmap_cache_process_sigbus(MMapCache *m) { bool found = false; MMapFileDescriptor *f; - Iterator i; int r; assert(m); @@ -572,7 +571,7 @@ static void mmap_cache_process_sigbus(MMapCache *m) { } ours = false; - HASHMAP_FOREACH(f, m->fds, i) { + HASHMAP_FOREACH(f, m->fds) { Window *w; LIST_FOREACH(by_fd, w, f->windows) { @@ -601,7 +600,7 @@ static void mmap_cache_process_sigbus(MMapCache *m) { if (_likely_(!found)) return; - HASHMAP_FOREACH(f, m->fds, i) { + HASHMAP_FOREACH(f, m->fds) { Window *w; if (!f->sigbus) diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 2023cc0c01..234e81445b 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -105,7 +105,6 @@ static int journal_put_error(sd_journal *j, int r, const char *path) { } static void detach_location(sd_journal *j) { - Iterator i; JournalFile *f; assert(j); @@ -113,7 +112,7 @@ static void detach_location(sd_journal *j) { j->current_file = NULL; j->current_field = 0; - ORDERED_HASHMAP_FOREACH(f, j->files, i) + ORDERED_HASHMAP_FOREACH(f, j->files) journal_file_reset_location(f); } @@ -1859,7 +1858,6 @@ static int add_search_paths(sd_journal *j) { } static int add_current_paths(sd_journal *j) { - Iterator i; JournalFile *f; assert(j); @@ -1868,7 +1866,7 @@ static int add_current_paths(sd_journal *j) { /* Simply adds all directories for files we have open as directories. We don't expect errors here, so we * treat them as fatal. */ - ORDERED_HASHMAP_FOREACH(f, j->files, i) { + ORDERED_HASHMAP_FOREACH(f, j->files) { _cleanup_free_ char *dir; int r; @@ -2103,7 +2101,6 @@ _public_ int sd_journal_open_directory_fd(sd_journal **ret, int fd, int flags) { } _public_ int sd_journal_open_files_fd(sd_journal **ret, int fds[], unsigned n_fds, int flags) { - Iterator iterator; JournalFile *f; _cleanup_(sd_journal_closep) sd_journal *j = NULL; unsigned i; @@ -2148,7 +2145,7 @@ _public_ int sd_journal_open_files_fd(sd_journal **ret, int fds[], unsigned n_fd fail: /* If we fail, make sure we don't take possession of the files we managed to make use of successfully, and they * remain open */ - ORDERED_HASHMAP_FOREACH(f, j->files, iterator) + ORDERED_HASHMAP_FOREACH(f, j->files) f->close_fd = false; return r; @@ -2566,7 +2563,6 @@ _public_ int sd_journal_get_timeout(sd_journal *j, uint64_t *timeout_usec) { static void process_q_overflow(sd_journal *j) { JournalFile *f; Directory *m; - Iterator i; assert(j); @@ -2580,7 +2576,7 @@ static void process_q_overflow(sd_journal *j) { j->generation++; (void) reiterate_all_paths(j); - ORDERED_HASHMAP_FOREACH(f, j->files, i) { + ORDERED_HASHMAP_FOREACH(f, j->files) { if (f->last_seen_generation == j->generation) continue; @@ -2589,7 +2585,7 @@ static void process_q_overflow(sd_journal *j) { remove_file_real(j, f); } - HASHMAP_FOREACH(m, j->directories_by_path, i) { + HASHMAP_FOREACH(m, j->directories_by_path) { if (m->last_seen_generation == j->generation) continue; @@ -2704,7 +2700,6 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) { assert_return(!journal_pid_changed(j), -ECHILD); if (j->inotify_fd < 0) { - Iterator i; JournalFile *f; /* This is the first invocation, hence create the @@ -2715,7 +2710,7 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) { /* Server might have done some vacuuming while we weren't watching. Get rid of the deleted files now so they don't stay around indefinitely. */ - ORDERED_HASHMAP_FOREACH(f, j->files, i) { + ORDERED_HASHMAP_FOREACH(f, j->files) { r = journal_file_fstat(f); if (r == -EIDRM) remove_file_real(j, f); @@ -2757,7 +2752,6 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) { } _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, uint64_t *to) { - Iterator i; JournalFile *f; bool first = true; uint64_t fmin = 0, tmax = 0; @@ -2768,7 +2762,7 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, assert_return(from || to, -EINVAL); assert_return(from != to, -EINVAL); - ORDERED_HASHMAP_FOREACH(f, j->files, i) { + ORDERED_HASHMAP_FOREACH(f, j->files) { usec_t fr, t; r = journal_file_get_cutoff_realtime_usec(f, &fr, &t); @@ -2798,7 +2792,6 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, } _public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t *from, uint64_t *to) { - Iterator i; JournalFile *f; bool found = false; int r; @@ -2808,7 +2801,7 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot assert_return(from || to, -EINVAL); assert_return(from != to, -EINVAL); - ORDERED_HASHMAP_FOREACH(f, j->files, i) { + ORDERED_HASHMAP_FOREACH(f, j->files) { usec_t fr, t; r = journal_file_get_cutoff_monotonic_usec(f, boot_id, &fr, &t); @@ -2837,13 +2830,12 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot } void journal_print_header(sd_journal *j) { - Iterator i; JournalFile *f; bool newline = false; assert(j); - ORDERED_HASHMAP_FOREACH(f, j->files, i) { + ORDERED_HASHMAP_FOREACH(f, j->files) { if (newline) putchar('\n'); else @@ -2854,7 +2846,6 @@ void journal_print_header(sd_journal *j) { } _public_ int sd_journal_get_usage(sd_journal *j, uint64_t *bytes) { - Iterator i; JournalFile *f; uint64_t sum = 0; @@ -2862,7 +2853,7 @@ _public_ int sd_journal_get_usage(sd_journal *j, uint64_t *bytes) { assert_return(!journal_pid_changed(j), -ECHILD); assert_return(bytes, -EINVAL); - ORDERED_HASHMAP_FOREACH(f, j->files, i) { + ORDERED_HASHMAP_FOREACH(f, j->files) { struct stat st; if (fstat(f->fd, &st) < 0) @@ -2920,7 +2911,6 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_ for (;;) { JournalFile *of; - Iterator i; Object *o; const void *odata; size_t ol; @@ -2988,7 +2978,7 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_ * object by checking if it exists in the earlier * traversed files. */ found = false; - ORDERED_HASHMAP_FOREACH(of, j->files, i) { + ORDERED_HASHMAP_FOREACH(of, j->files) { if (of == j->unique_file) break; @@ -3060,7 +3050,6 @@ _public_ int sd_journal_enumerate_fields(sd_journal *j, const char **field) { for (;;) { JournalFile *f, *of; - Iterator i; uint64_t m; Object *o; size_t sz; @@ -3137,7 +3126,7 @@ _public_ int sd_journal_enumerate_fields(sd_journal *j, const char **field) { /* Let's see if we already returned this field name before. */ found = false; - ORDERED_HASHMAP_FOREACH(of, j->files, i) { + ORDERED_HASHMAP_FOREACH(of, j->files) { if (of == f) break; diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c index 158847f3ea..0f1447af28 100644 --- a/src/journal/test-catalog.c +++ b/src/journal/test-catalog.c @@ -65,7 +65,6 @@ static void test_catalog_import_badid(void) { static void test_catalog_import_one(void) { _cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL; char *payload; - Iterator j; const char *input = "-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \ @@ -80,7 +79,7 @@ static void test_catalog_import_one(void) { h = test_import(input, -1, 0); assert_se(ordered_hashmap_size(h) == 1); - ORDERED_HASHMAP_FOREACH(payload, h, j) { + ORDERED_HASHMAP_FOREACH(payload, h) { printf("expect: %s\n", expect); printf("actual: %s\n", payload); assert_se(streq(expect, payload)); @@ -90,7 +89,6 @@ static void test_catalog_import_one(void) { static void test_catalog_import_merge(void) { _cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL; char *payload; - Iterator j; const char *input = "-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \ @@ -116,14 +114,13 @@ static void test_catalog_import_merge(void) { h = test_import(input, -1, 0); assert_se(ordered_hashmap_size(h) == 1); - ORDERED_HASHMAP_FOREACH(payload, h, j) + ORDERED_HASHMAP_FOREACH(payload, h) assert_se(streq(combined, payload)); } static void test_catalog_import_merge_no_body(void) { _cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL; char *payload; - Iterator j; const char *input = "-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \ @@ -148,7 +145,7 @@ static void test_catalog_import_merge_no_body(void) { h = test_import(input, -1, 0); assert_se(ordered_hashmap_size(h) == 1); - ORDERED_HASHMAP_FOREACH(payload, h, j) + ORDERED_HASHMAP_FOREACH(payload, h) assert_se(streq(combined, payload)); } diff --git a/src/libsystemd-network/dhcp-option.c b/src/libsystemd-network/dhcp-option.c index e03c1a894d..6fe8a3779d 100644 --- a/src/libsystemd-network/dhcp-option.c +++ b/src/libsystemd-network/dhcp-option.c @@ -81,9 +81,8 @@ static int option_append(uint8_t options[], size_t size, size_t *offset, OrderedHashmap *s = (OrderedHashmap *) optval; struct sd_dhcp_option *p; size_t l = 0; - Iterator i; - ORDERED_HASHMAP_FOREACH(p, s, i) + ORDERED_HASHMAP_FOREACH(p, s) l += p->length + 2; if (*offset + l + 2 > size) @@ -94,7 +93,7 @@ static int option_append(uint8_t options[], size_t size, size_t *offset, *offset += 2; - ORDERED_HASHMAP_FOREACH(p, s, i) { + ORDERED_HASHMAP_FOREACH(p, s) { options[*offset] = p->option; options[*offset + 1] = p->length; memcpy(&options[*offset + 2], p->data, p->length); diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c index cfa6bb5008..030173a58a 100644 --- a/src/libsystemd-network/dhcp6-option.c +++ b/src/libsystemd-network/dhcp6-option.c @@ -81,7 +81,6 @@ int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code, int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHashmap *vendor_options) { sd_dhcp6_option *options; - Iterator i; int r; assert(buf); @@ -89,7 +88,7 @@ int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHash assert(buflen); assert(vendor_options); - ORDERED_HASHMAP_FOREACH(options, vendor_options, i) { + ORDERED_HASHMAP_FOREACH(options, vendor_options) { _cleanup_free_ uint8_t *p = NULL; size_t total; diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index a83ffc3423..265b6eab44 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -919,7 +919,6 @@ static int dhcp_client_send_raw( static int client_append_common_discover_request_options(sd_dhcp_client *client, DHCPPacket *packet, size_t *optoffset, size_t optlen) { sd_dhcp_option *j; - Iterator i; int r; assert(client); @@ -970,7 +969,7 @@ static int client_append_common_discover_request_options(sd_dhcp_client *client, return r; } - ORDERED_HASHMAP_FOREACH(j, client->extra_options, i) { + ORDERED_HASHMAP_FOREACH(j, client->extra_options) { r = dhcp_option_append(&packet->dhcp, optlen, optoffset, 0, j->option, j->length, j->data); if (r < 0) diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index ec20b936b8..a34a55919e 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -479,7 +479,6 @@ static int server_send_ack( _cleanup_free_ DHCPPacket *packet = NULL; be32_t lease_time; sd_dhcp_option *j; - Iterator i; size_t offset; int r; @@ -531,7 +530,7 @@ static int server_send_ack( return r; } - ORDERED_HASHMAP_FOREACH(j, server->extra_options, i) { + ORDERED_HASHMAP_FOREACH(j, server->extra_options) { r = dhcp_option_append(&packet->dhcp, req->max_optlen, &offset, 0, j->option, j->length, j->data); if (r < 0) diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 37f3c39d5a..7b5b96b1a8 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -624,7 +624,6 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) { IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT; struct sd_dhcp6_option *j; size_t len, optlen = 512; - Iterator i; uint8_t *opt; int r; usec_t elapsed_usec; @@ -859,7 +858,7 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) { if (r < 0) return r; - ORDERED_HASHMAP_FOREACH(j, client->extra_options, i) { + ORDERED_HASHMAP_FOREACH(j, client->extra_options) { r = dhcp6_option_append(&opt, &optlen, j->option, j->length, j->data); if (r < 0) return r; diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c index d3606cf501..b0a11fe20b 100644 --- a/src/libsystemd-network/sd-lldp.c +++ b/src/libsystemd-network/sd-lldp.c @@ -431,7 +431,6 @@ static int lldp_start_timer(sd_lldp *lldp, sd_lldp_neighbor *neighbor) { _public_ int sd_lldp_get_neighbors(sd_lldp *lldp, sd_lldp_neighbor ***ret) { sd_lldp_neighbor **l = NULL, *n; - Iterator i; int k = 0, r; assert_return(lldp, -EINVAL); @@ -452,7 +451,7 @@ _public_ int sd_lldp_get_neighbors(sd_lldp *lldp, sd_lldp_neighbor ***ret) { return r; } - HASHMAP_FOREACH(n, lldp->neighbor_by_id, i) + HASHMAP_FOREACH(n, lldp->neighbor_by_id) l[k++] = sd_lldp_neighbor_ref(n); assert((size_t) k == hashmap_size(lldp->neighbor_by_id)); diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c index 57ce8cca04..20a4b46773 100644 --- a/src/libsystemd/sd-bus/bus-match.c +++ b/src/libsystemd/sd-bus/bus-match.c @@ -961,9 +961,8 @@ void bus_match_free(struct bus_match_node *node) { return; if (BUS_MATCH_CAN_HASH(node->type)) { - Iterator i; - HASHMAP_FOREACH(c, node->compare.children, i) + HASHMAP_FOREACH(c, node->compare.children) bus_match_free(c); assert(hashmap_isempty(node->compare.children)); @@ -1054,9 +1053,8 @@ void bus_match_dump(struct bus_match_node *node, unsigned level) { putchar('\n'); if (BUS_MATCH_CAN_HASH(node->type)) { - Iterator i; - HASHMAP_FOREACH(c, node->compare.children, i) + HASHMAP_FOREACH(c, node->compare.children) bus_match_dump(c, level + 1); } diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index 6abac8822c..33284d7301 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -1235,7 +1235,6 @@ static int process_get_managed_objects( _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_set_free_free_ Set *s = NULL; - Iterator i; char *path; int r; @@ -1265,7 +1264,7 @@ static int process_get_managed_objects( if (r < 0) return r; - SET_FOREACH(path, s, i) { + SET_FOREACH(path, s) { r = object_manager_serialize_path_and_fallbacks(bus, reply, path, &error); if (r < 0) return bus_maybe_reply_error(m, r, &error); diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 9de5e454a6..272b97e17a 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -597,7 +597,6 @@ static int bus_send_hello(sd_bus *bus) { int bus_start_running(sd_bus *bus) { struct reply_callback *c; - Iterator i; usec_t n; int r; @@ -609,7 +608,7 @@ int bus_start_running(sd_bus *bus) { * adding a fixed value to all entries should not alter the internal order. */ n = now(CLOCK_MONOTONIC); - ORDERED_HASHMAP_FOREACH(c, bus->reply_callbacks, i) { + ORDERED_HASHMAP_FOREACH(c, bus->reply_callbacks) { if (c->timeout_usec == 0) continue; diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 95dfc2f077..f3bac17ca3 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -308,16 +308,15 @@ static bool match_sysattr_value(sd_device *device, const char *sysattr, const ch static bool match_sysattr(sd_device_enumerator *enumerator, sd_device *device) { const char *sysattr; const char *value; - Iterator i; assert(enumerator); assert(device); - HASHMAP_FOREACH_KEY(value, sysattr, enumerator->nomatch_sysattr, i) + HASHMAP_FOREACH_KEY(value, sysattr, enumerator->nomatch_sysattr) if (match_sysattr_value(device, sysattr, value)) return false; - HASHMAP_FOREACH_KEY(value, sysattr, enumerator->match_sysattr, i) + HASHMAP_FOREACH_KEY(value, sysattr, enumerator->match_sysattr) if (!match_sysattr_value(device, sysattr, value)) return false; @@ -327,7 +326,6 @@ static bool match_sysattr(sd_device_enumerator *enumerator, sd_device *device) { static bool match_property(sd_device_enumerator *enumerator, sd_device *device) { const char *property; const char *value; - Iterator i; assert(enumerator); assert(device); @@ -335,7 +333,7 @@ static bool match_property(sd_device_enumerator *enumerator, sd_device *device) if (hashmap_isempty(enumerator->match_property)) return true; - HASHMAP_FOREACH_KEY(value, property, enumerator->match_property, i) { + HASHMAP_FOREACH_KEY(value, property, enumerator->match_property) { const char *property_dev, *value_dev; FOREACH_DEVICE_PROPERTY(device, property_dev, value_dev) { @@ -358,12 +356,11 @@ static bool match_property(sd_device_enumerator *enumerator, sd_device *device) static bool match_tag(sd_device_enumerator *enumerator, sd_device *device) { const char *tag; - Iterator i; assert(enumerator); assert(device); - SET_FOREACH(tag, enumerator->match_tag, i) + SET_FOREACH(tag, enumerator->match_tag) if (!sd_device_has_tag(device, tag)) return false; @@ -372,7 +369,6 @@ static bool match_tag(sd_device_enumerator *enumerator, sd_device *device) { static bool match_parent(sd_device_enumerator *enumerator, sd_device *device) { const char *syspath_parent, *syspath; - Iterator i; assert(enumerator); assert(device); @@ -382,7 +378,7 @@ static bool match_parent(sd_device_enumerator *enumerator, sd_device *device) { assert_se(sd_device_get_syspath(device, &syspath) >= 0); - SET_FOREACH(syspath_parent, enumerator->match_parent, i) + SET_FOREACH(syspath_parent, enumerator->match_parent) if (path_startswith(syspath, syspath_parent)) return true; @@ -391,7 +387,6 @@ static bool match_parent(sd_device_enumerator *enumerator, sd_device *device) { static bool match_sysname(sd_device_enumerator *enumerator, const char *sysname) { const char *sysname_match; - Iterator i; assert(enumerator); assert(sysname); @@ -399,7 +394,7 @@ static bool match_sysname(sd_device_enumerator *enumerator, const char *sysname) if (set_isempty(enumerator->match_sysname)) return true; - SET_FOREACH(sysname_match, enumerator->match_sysname, i) + SET_FOREACH(sysname_match, enumerator->match_sysname) if (fnmatch(sysname_match, sysname, 0) == 0) return true; @@ -496,21 +491,20 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator, static bool match_subsystem(sd_device_enumerator *enumerator, const char *subsystem) { const char *subsystem_match; - Iterator i; assert(enumerator); if (!subsystem) return false; - SET_FOREACH(subsystem_match, enumerator->nomatch_subsystem, i) + SET_FOREACH(subsystem_match, enumerator->nomatch_subsystem) if (fnmatch(subsystem_match, subsystem, 0) == 0) return false; if (set_isempty(enumerator->match_subsystem)) return true; - SET_FOREACH(subsystem_match, enumerator->match_subsystem, i) + SET_FOREACH(subsystem_match, enumerator->match_subsystem) if (fnmatch(subsystem_match, subsystem, 0) == 0) return true; @@ -626,12 +620,11 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c static int enumerator_scan_devices_tags(sd_device_enumerator *enumerator) { const char *tag; - Iterator i; int r = 0; assert(enumerator); - SET_FOREACH(tag, enumerator->match_tag, i) { + SET_FOREACH(tag, enumerator->match_tag) { int k; k = enumerator_scan_devices_tag(enumerator, tag); @@ -722,9 +715,8 @@ static int parent_crawl_children(sd_device_enumerator *enumerator, const char *p static int enumerator_scan_devices_children(sd_device_enumerator *enumerator) { const char *path; int r = 0, k; - Iterator i; - SET_FOREACH(path, enumerator->match_parent, i) { + SET_FOREACH(path, enumerator->match_parent) { k = parent_add_child(enumerator, path); if (k < 0) r = k; diff --git a/src/libsystemd/sd-device/device-monitor.c b/src/libsystemd/sd-device/device-monitor.c index bed45da8e4..cb6f1a70f8 100644 --- a/src/libsystemd/sd-device/device-monitor.c +++ b/src/libsystemd/sd-device/device-monitor.c @@ -353,7 +353,6 @@ DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_device_monitor, sd_device_monitor, devic static int passes_filter(sd_device_monitor *m, sd_device *device) { const char *tag, *subsystem, *devtype, *s, *d = NULL; - Iterator i; int r; assert_return(m, -EINVAL); @@ -370,7 +369,7 @@ static int passes_filter(sd_device_monitor *m, sd_device *device) { if (r < 0 && r != -ENOENT) return r; - HASHMAP_FOREACH_KEY(devtype, subsystem, m->subsystem_filter, i) { + HASHMAP_FOREACH_KEY(devtype, subsystem, m->subsystem_filter) { if (!streq(s, subsystem)) continue; @@ -390,7 +389,7 @@ tag: if (set_isempty(m->tag_filter)) return 1; - SET_FOREACH(tag, m->tag_filter, i) + SET_FOREACH(tag, m->tag_filter) if (sd_device_has_tag(device, tag) > 0) return 1; @@ -631,7 +630,6 @@ _public_ int sd_device_monitor_filter_update(sd_device_monitor *m) { struct sock_fprog filter; const char *subsystem, *devtype, *tag; unsigned i = 0; - Iterator it; assert_return(m, -EINVAL); @@ -655,7 +653,7 @@ _public_ int sd_device_monitor_filter_update(sd_device_monitor *m) { int tag_matches = set_size(m->tag_filter); /* add all tags matches */ - SET_FOREACH(tag, m->tag_filter, it) { + SET_FOREACH(tag, m->tag_filter) { uint64_t tag_bloom_bits = string_bloom64(tag); uint32_t tag_bloom_hi = tag_bloom_bits >> 32; uint32_t tag_bloom_lo = tag_bloom_bits & 0xffffffff; @@ -682,7 +680,7 @@ _public_ int sd_device_monitor_filter_update(sd_device_monitor *m) { /* add all subsystem matches */ if (!hashmap_isempty(m->subsystem_filter)) { - HASHMAP_FOREACH_KEY(devtype, subsystem, m->subsystem_filter, it) { + HASHMAP_FOREACH_KEY(devtype, subsystem, m->subsystem_filter) { uint32_t hash = string_hash32(subsystem); /* load device subsystem value in A */ diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 1ad7713ec7..44d1fd9839 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -732,7 +732,6 @@ int device_new_from_stat_rdev(sd_device **ret, const struct stat *st) { int device_copy_properties(sd_device *device_dst, sd_device *device_src) { const char *property, *value; - Iterator i; int r; assert(device_dst); @@ -742,13 +741,13 @@ int device_copy_properties(sd_device *device_dst, sd_device *device_src) { if (r < 0) return r; - ORDERED_HASHMAP_FOREACH_KEY(value, property, device_src->properties_db, i) { + ORDERED_HASHMAP_FOREACH_KEY(value, property, device_src->properties_db) { r = device_add_property_aux(device_dst, property, value, true); if (r < 0) return r; } - ORDERED_HASHMAP_FOREACH_KEY(value, property, device_src->properties, i) { + ORDERED_HASHMAP_FOREACH_KEY(value, property, device_src->properties) { r = device_add_property_aux(device_dst, property, value, false); if (r < 0) return r; @@ -921,7 +920,6 @@ int device_update_db(sd_device *device) { if (has_info) { const char *property, *value, *tag; - Iterator i; if (major(device->devnum) > 0) { const char *devlink; @@ -939,13 +937,13 @@ int device_update_db(sd_device *device) { if (device->usec_initialized > 0) fprintf(f, "I:"USEC_FMT"\n", device->usec_initialized); - ORDERED_HASHMAP_FOREACH_KEY(value, property, device->properties_db, i) + ORDERED_HASHMAP_FOREACH_KEY(value, property, device->properties_db) fprintf(f, "E:%s=%s\n", property, value); FOREACH_DEVICE_TAG(device, tag) fprintf(f, "G:%s\n", tag); /* Any tag */ - SET_FOREACH(tag, device->current_tags, i) + SET_FOREACH(tag, device->current_tags) fprintf(f, "Q:%s\n", tag); /* Current tag */ } diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 3041ce2e9c..bf92fda6d9 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1502,7 +1502,6 @@ static char *join_string_set(Set *s) { size_t ret_allocated = 0, ret_len; _cleanup_free_ char *ret = NULL; const char *tag; - Iterator i; if (!GREEDY_REALLOC(ret, ret_allocated, 2)) return NULL; @@ -1510,7 +1509,7 @@ static char *join_string_set(Set *s) { strcpy(ret, ":"); ret_len = 1; - SET_FOREACH(tag, s, i) { + SET_FOREACH(tag, s) { char *e; if (!GREEDY_REALLOC(ret, ret_allocated, ret_len + strlen(tag) + 2)) diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 8b338f5db6..7dd43f2ddc 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -2870,7 +2870,6 @@ static int process_timer( static int process_child(sd_event *e) { sd_event_source *s; - Iterator i; int r; assert(e); @@ -2895,7 +2894,7 @@ static int process_child(sd_event *e) { the callback still sees the process as a zombie. */ - HASHMAP_FOREACH(s, e->child_sources, i) { + HASHMAP_FOREACH(s, e->child_sources) { assert(s->type == SOURCE_CHILD); if (s->pending) @@ -3100,12 +3099,11 @@ static int event_inotify_data_process(sd_event *e, struct inotify_data *d) { if (d->buffer.ev.mask & IN_Q_OVERFLOW) { struct inode_data *inode_data; - Iterator i; /* The queue overran, let's pass this event to all event sources connected to this inotify * object */ - HASHMAP_FOREACH(inode_data, d->inodes, i) { + HASHMAP_FOREACH(inode_data, d->inodes) { sd_event_source *s; LIST_FOREACH(inotify.by_inode_data, s, inode_data->event_sources) { @@ -3203,12 +3201,11 @@ static int source_dispatch(sd_event_source *s) { if (s->type != SOURCE_POST) { sd_event_source *z; - Iterator i; /* If we execute a non-post source, let's mark all * post sources as pending */ - SET_FOREACH(z, s->event->post_sources, i) { + SET_FOREACH(z, s->event->post_sources) { if (z->enabled == SD_EVENT_OFF) continue; diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c index 95a9942f64..3b22976c9f 100644 --- a/src/libudev/libudev-list.c +++ b/src/libudev/libudev-list.c @@ -157,7 +157,6 @@ struct udev_list_entry *udev_list_get_entry(struct udev_list *list) { else { _cleanup_free_ struct udev_list_entry **buf = NULL; struct udev_list_entry *entry, **p; - Iterator i; size_t j; buf = new(struct udev_list_entry *, n); @@ -165,7 +164,7 @@ struct udev_list_entry *udev_list_get_entry(struct udev_list *list) { return NULL; p = buf; - HASHMAP_FOREACH(entry, list->unique_entries, i) + HASHMAP_FOREACH(entry, list->unique_entries) *p++ = entry; typesafe_qsort(buf, n, udev_list_entry_compare_func); diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c index 5b75d8f362..0cb3b0bec3 100644 --- a/src/login/logind-acl.c +++ b/src/login/logind-acl.c @@ -168,7 +168,6 @@ int devnode_acl_all(const char *seat, _cleanup_closedir_ DIR *dir = NULL; struct dirent *dent; sd_device *d; - Iterator i; char *n; int r; @@ -239,7 +238,7 @@ int devnode_acl_all(const char *seat, } r = 0; - SET_FOREACH(n, nodes, i) { + SET_FOREACH(n, nodes) { int k; log_debug("Changing ACLs at %s for seat %s (uid "UID_FMT"→"UID_FMT"%s%s)", diff --git a/src/login/logind-core.c b/src/login/logind-core.c index 0487182225..3ea6f18aa8 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -391,13 +391,12 @@ int manager_get_idle_hint(Manager *m, dual_timestamp *t) { Session *s; bool idle_hint; dual_timestamp ts = DUAL_TIMESTAMP_NULL; - Iterator i; assert(m); idle_hint = !manager_is_inhibited(m, INHIBIT_IDLE, INHIBIT_BLOCK, t, false, false, 0, NULL); - HASHMAP_FOREACH(s, m->sessions, i) { + HASHMAP_FOREACH(s, m->sessions) { dual_timestamp k; int ih; @@ -547,10 +546,9 @@ int manager_spawn_autovt(Manager *m, unsigned vtnr) { } bool manager_is_lid_closed(Manager *m) { - Iterator i; Button *b; - HASHMAP_FOREACH(b, m->buttons, i) + HASHMAP_FOREACH(b, m->buttons) if (b->lid_closed) return true; @@ -558,10 +556,9 @@ bool manager_is_lid_closed(Manager *m) { } static bool manager_is_docked(Manager *m) { - Iterator i; Button *b; - HASHMAP_FOREACH(b, m->buttons, i) + HASHMAP_FOREACH(b, m->buttons) if (b->docked) return true; diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index bbec23c850..71156e610c 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -516,7 +516,6 @@ static int method_list_sessions(sd_bus_message *message, void *userdata, sd_bus_ _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; Session *session; - Iterator i; int r; assert(message); @@ -530,7 +529,7 @@ static int method_list_sessions(sd_bus_message *message, void *userdata, sd_bus_ if (r < 0) return r; - HASHMAP_FOREACH(session, m->sessions, i) { + HASHMAP_FOREACH(session, m->sessions) { _cleanup_free_ char *p = NULL; p = session_bus_path(session); @@ -558,7 +557,6 @@ static int method_list_users(sd_bus_message *message, void *userdata, sd_bus_err _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; User *user; - Iterator i; int r; assert(message); @@ -572,7 +570,7 @@ static int method_list_users(sd_bus_message *message, void *userdata, sd_bus_err if (r < 0) return r; - HASHMAP_FOREACH(user, m->users, i) { + HASHMAP_FOREACH(user, m->users) { _cleanup_free_ char *p = NULL; p = user_bus_path(user); @@ -598,7 +596,6 @@ static int method_list_seats(sd_bus_message *message, void *userdata, sd_bus_err _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; Seat *seat; - Iterator i; int r; assert(message); @@ -612,7 +609,7 @@ static int method_list_seats(sd_bus_message *message, void *userdata, sd_bus_err if (r < 0) return r; - HASHMAP_FOREACH(seat, m->seats, i) { + HASHMAP_FOREACH(seat, m->seats) { _cleanup_free_ char *p = NULL; p = seat_bus_path(seat); @@ -635,7 +632,6 @@ static int method_list_inhibitors(sd_bus_message *message, void *userdata, sd_bu _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; Inhibitor *inhibitor; - Iterator i; int r; assert(message); @@ -649,7 +645,7 @@ static int method_list_inhibitors(sd_bus_message *message, void *userdata, sd_bu if (r < 0) return r; - HASHMAP_FOREACH(inhibitor, m->inhibitors, i) { + HASHMAP_FOREACH(inhibitor, m->inhibitors) { r = sd_bus_message_append(reply, "(ssssuu)", strempty(inhibit_what_to_string(inhibitor->what)), @@ -1499,13 +1495,12 @@ static int have_multiple_sessions( uid_t uid) { Session *session; - Iterator i; assert(m); /* Check for other users' sessions. Greeter sessions do not * count, and non-login sessions do not count either. */ - HASHMAP_FOREACH(session, m->sessions, i) + HASHMAP_FOREACH(session, m->sessions) if (session->class == SESSION_USER && session->user->user_record->uid != uid) return true; @@ -3900,7 +3895,6 @@ int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_err int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Session *session; - Iterator i; int b, r; assert(message); @@ -3918,7 +3912,7 @@ int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error /* systemd finished reloading, let's recheck all our sessions */ log_debug("System manager has been reloaded, rechecking sessions..."); - HASHMAP_FOREACH(session, m->sessions, i) + HASHMAP_FOREACH(session, m->sessions) session_add_to_gc_queue(session); return 0; diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 1d335f914c..ff16bc4b3d 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -372,12 +372,11 @@ bool inhibitor_is_orphan(Inhibitor *i) { InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm) { Inhibitor *i; - Iterator j; InhibitWhat what = 0; assert(m); - HASHMAP_FOREACH(i, m->inhibitors, j) + HASHMAP_FOREACH(i, m->inhibitors) if (i->mode == mm && i->started) what |= i->what; @@ -413,14 +412,13 @@ bool manager_is_inhibited( Inhibitor **offending) { Inhibitor *i; - Iterator j; struct dual_timestamp ts = DUAL_TIMESTAMP_NULL; bool inhibited = false; assert(m); assert(w > 0 && w < _INHIBIT_WHAT_MAX); - HASHMAP_FOREACH(i, m->inhibitors, j) { + HASHMAP_FOREACH(i, m->inhibitors) { if (!i->started) continue; diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c index a91765205c..ee2088018c 100644 --- a/src/login/logind-seat-dbus.c +++ b/src/login/logind-seat-dbus.c @@ -345,14 +345,13 @@ static int seat_node_enumerator(sd_bus *bus, const char *path, void *userdata, c sd_bus_message *message; Manager *m = userdata; Seat *seat; - Iterator i; int r; assert(bus); assert(path); assert(nodes); - HASHMAP_FOREACH(seat, m->seats, i) { + HASHMAP_FOREACH(seat, m->seats) { char *p; p = seat_bus_path(seat); diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c index 5ed20ebd26..d505dac8d0 100644 --- a/src/login/logind-session-dbus.c +++ b/src/login/logind-session-dbus.c @@ -635,14 +635,13 @@ static int session_node_enumerator(sd_bus *bus, const char *path, void *userdata sd_bus_message *message; Manager *m = userdata; Session *session; - Iterator i; int r; assert(bus); assert(path); assert(nodes); - HASHMAP_FOREACH(session, m->sessions, i) { + HASHMAP_FOREACH(session, m->sessions) { char *p; p = session_bus_path(session); @@ -753,12 +752,11 @@ int session_send_lock(Session *s, bool lock) { int session_send_lock_all(Manager *m, bool lock) { Session *session; - Iterator i; int r = 0; assert(m); - HASHMAP_FOREACH(session, m->sessions, i) { + HASHMAP_FOREACH(session, m->sessions) { int k; k = session_send_lock(session, lock); diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index 23df756ae2..5cef5169b9 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -408,7 +408,6 @@ void session_device_free(SessionDevice *sd) { void session_device_complete_pause(SessionDevice *sd) { SessionDevice *iter; - Iterator i; if (!sd->active) return; @@ -416,7 +415,7 @@ void session_device_complete_pause(SessionDevice *sd) { session_device_stop(sd); /* if not all devices are paused, wait for further completion events */ - HASHMAP_FOREACH(iter, sd->session->devices, i) + HASHMAP_FOREACH(iter, sd->session->devices) if (iter->active) return; @@ -426,11 +425,10 @@ void session_device_complete_pause(SessionDevice *sd) { void session_device_resume_all(Session *s) { SessionDevice *sd; - Iterator i; assert(s); - HASHMAP_FOREACH(sd, s->devices, i) { + HASHMAP_FOREACH(sd, s->devices) { if (sd->active) continue; @@ -445,11 +443,10 @@ void session_device_resume_all(Session *s) { void session_device_pause_all(Session *s) { SessionDevice *sd; - Iterator i; assert(s); - HASHMAP_FOREACH(sd, s->devices, i) { + HASHMAP_FOREACH(sd, s->devices) { if (!sd->active) continue; @@ -461,11 +458,10 @@ void session_device_pause_all(Session *s) { unsigned session_device_try_pause_all(Session *s) { unsigned num_pending = 0; SessionDevice *sd; - Iterator i; assert(s); - HASHMAP_FOREACH(sd, s->devices, i) { + HASHMAP_FOREACH(sd, s->devices) { if (!sd->active) continue; diff --git a/src/login/logind-session.c b/src/login/logind-session.c index e323d0e6de..6eadfe83d4 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -189,11 +189,10 @@ int session_set_leader(Session *s, pid_t pid) { static void session_save_devices(Session *s, FILE *f) { SessionDevice *sd; - Iterator i; if (!hashmap_isempty(s->devices)) { fprintf(f, "DEVICES="); - HASHMAP_FOREACH(sd, s->devices, i) + HASHMAP_FOREACH(sd, s->devices) fprintf(f, "%u:%u ", major(sd->dev), minor(sd->dev)); fprintf(f, "\n"); } diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c index 237723729e..5141ac0476 100644 --- a/src/login/logind-user-dbus.c +++ b/src/login/logind-user-dbus.c @@ -319,14 +319,13 @@ static int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, c sd_bus_message *message; Manager *m = userdata; User *user; - Iterator i; int r; assert(bus); assert(path); assert(nodes); - HASHMAP_FOREACH(user, m->users, i) { + HASHMAP_FOREACH(user, m->users) { char *p; p = user_bus_path(user); diff --git a/src/login/logind.c b/src/login/logind.c index c50a083b03..9fd862e23c 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -1032,7 +1032,6 @@ static int manager_startup(Manager *m) { User *user; Button *button; Inhibitor *inhibitor; - Iterator i; assert(m); @@ -1102,16 +1101,16 @@ static int manager_startup(Manager *m) { manager_read_utmp(m); /* And start everything */ - HASHMAP_FOREACH(seat, m->seats, i) + HASHMAP_FOREACH(seat, m->seats) (void) seat_start(seat); - HASHMAP_FOREACH(user, m->users, i) + HASHMAP_FOREACH(user, m->users) (void) user_start(user); - HASHMAP_FOREACH(session, m->sessions, i) + HASHMAP_FOREACH(session, m->sessions) (void) session_start(session, NULL, NULL); - HASHMAP_FOREACH(inhibitor, m->inhibitors, i) { + HASHMAP_FOREACH(inhibitor, m->inhibitors) { (void) inhibitor_start(inhibitor); /* Let's see if the inhibitor is dead now, then remove it */ @@ -1121,7 +1120,7 @@ static int manager_startup(Manager *m) { } } - HASHMAP_FOREACH(button, m->buttons, i) + HASHMAP_FOREACH(button, m->buttons) button_check_switches(button); manager_dispatch_idle_action(NULL, 0, m); diff --git a/src/machine/image-dbus.c b/src/machine/image-dbus.c index 7a15bcc49a..740684ce33 100644 --- a/src/machine/image-dbus.c +++ b/src/machine/image-dbus.c @@ -442,7 +442,6 @@ static int image_node_enumerator(sd_bus *bus, const char *path, void *userdata, _cleanup_hashmap_free_ Hashmap *images = NULL; _cleanup_strv_free_ char **l = NULL; Image *image; - Iterator i; int r; assert(bus); @@ -457,7 +456,7 @@ static int image_node_enumerator(sd_bus *bus, const char *path, void *userdata, if (r < 0) return r; - HASHMAP_FOREACH(image, images, i) { + HASHMAP_FOREACH(image, images) { char *p; p = image_bus_path(image->name); diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index f2285abc0e..d203ac0bd4 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -1382,14 +1382,13 @@ static int machine_node_enumerator(sd_bus *bus, const char *path, void *userdata _cleanup_strv_free_ char **l = NULL; Machine *machine = NULL; Manager *m = userdata; - Iterator i; int r; assert(bus); assert(path); assert(nodes); - HASHMAP_FOREACH(machine, m->machines, i) { + HASHMAP_FOREACH(machine, m->machines) { char *p; p = machine_bus_path(machine); diff --git a/src/machine/machined-core.c b/src/machine/machined-core.c index c44bb94d8a..2ff155d47c 100644 --- a/src/machine/machined-core.c +++ b/src/machine/machined-core.c @@ -38,7 +38,6 @@ int manager_enqueue_nscd_cache_flush(Manager *m) { int manager_find_machine_for_uid(Manager *m, uid_t uid, Machine **ret_machine, uid_t *ret_internal_uid) { Machine *machine; - Iterator i; int r; assert(m); @@ -47,7 +46,7 @@ int manager_find_machine_for_uid(Manager *m, uid_t uid, Machine **ret_machine, u /* Finds the machine for the specified host UID and returns it along with the UID translated into the * internal UID inside the machine */ - HASHMAP_FOREACH(machine, m->machines, i) { + HASHMAP_FOREACH(machine, m->machines) { uid_t converted; r = machine_owns_uid(machine, uid, &converted); @@ -74,13 +73,12 @@ int manager_find_machine_for_uid(Manager *m, uid_t uid, Machine **ret_machine, u int manager_find_machine_for_gid(Manager *m, gid_t gid, Machine **ret_machine, gid_t *ret_internal_gid) { Machine *machine; - Iterator i; int r; assert(m); assert(gid_is_valid(gid)); - HASHMAP_FOREACH(machine, m->machines, i) { + HASHMAP_FOREACH(machine, m->machines) { gid_t converted; r = machine_owns_gid(machine, gid, &converted); diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 9efae8e19c..6d4a705c47 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -185,7 +185,6 @@ static int method_list_machines(sd_bus_message *message, void *userdata, sd_bus_ _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *m = userdata; Machine *machine; - Iterator i; int r; assert(message); @@ -199,7 +198,7 @@ static int method_list_machines(sd_bus_message *message, void *userdata, sd_bus_ if (r < 0) return sd_bus_error_set_errno(error, r); - HASHMAP_FOREACH(machine, m->machines, i) { + HASHMAP_FOREACH(machine, m->machines) { _cleanup_free_ char *p = NULL; p = machine_bus_path(machine); @@ -474,7 +473,6 @@ static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_er _cleanup_hashmap_free_ Hashmap *images = NULL; _unused_ Manager *m = userdata; Image *image; - Iterator i; int r; assert(message); @@ -496,7 +494,7 @@ static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_er if (r < 0) return r; - HASHMAP_FOREACH(image, images, i) { + HASHMAP_FOREACH(image, images) { _cleanup_free_ char *p = NULL; p = image_bus_path(image->name); @@ -749,7 +747,6 @@ static int method_clean_pool(sd_bus_message *message, void *userdata, sd_bus_err _cleanup_hashmap_free_ Hashmap *images = NULL; bool success = true; Image *image; - Iterator i; ssize_t l; errno_pipe_fd[0] = safe_close(errno_pipe_fd[0]); @@ -770,7 +767,7 @@ static int method_clean_pool(sd_bus_message *message, void *userdata, sd_bus_err goto child_fail; } - HASHMAP_FOREACH(image, images, i) { + HASHMAP_FOREACH(image, images) { /* We can't remove vendor images (i.e. those in /usr) */ if (IMAGE_IS_VENDOR(image)) @@ -1421,7 +1418,6 @@ int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *er int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; - Iterator i; int b, r; assert(message); @@ -1438,7 +1434,7 @@ int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error /* systemd finished reloading, let's recheck all our machines */ log_debug("System manager has been reloaded, rechecking machines..."); - HASHMAP_FOREACH(machine, m->machines, i) + HASHMAP_FOREACH(machine, m->machines) machine_add_to_gc_queue(machine); return 0; diff --git a/src/machine/machined.c b/src/machine/machined.c index 8ea857eb48..2828ed61b0 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -265,7 +265,6 @@ static void manager_gc(Manager *m, bool drop_not_started) { static int manager_startup(Manager *m) { Machine *machine; - Iterator i; int r; assert(m); @@ -287,7 +286,7 @@ static int manager_startup(Manager *m) { manager_gc(m, false); /* And start everything */ - HASHMAP_FOREACH(machine, m->machines, i) + HASHMAP_FOREACH(machine, m->machines) machine_start(machine, NULL, NULL); return 0; diff --git a/src/network/generator/main.c b/src/network/generator/main.c index 6662df34c1..61a741e5d2 100644 --- a/src/network/generator/main.c +++ b/src/network/generator/main.c @@ -83,7 +83,6 @@ static int context_save(Context *context) { Network *network; NetDev *netdev; Link *link; - Iterator i; int k, r; const char *p; @@ -93,19 +92,19 @@ static int context_save(Context *context) { if (r < 0) return log_error_errno(r, "Failed to create directory " NETWORKD_UNIT_DIRECTORY ": %m"); - HASHMAP_FOREACH(network, context->networks_by_name, i) { + HASHMAP_FOREACH(network, context->networks_by_name) { k = network_save(network, p); if (k < 0 && r >= 0) r = k; } - HASHMAP_FOREACH(netdev, context->netdevs_by_name, i) { + HASHMAP_FOREACH(netdev, context->netdevs_by_name) { k = netdev_save(netdev, p); if (k < 0 && r >= 0) r = k; } - HASHMAP_FOREACH(link, context->links_by_name, i) { + HASHMAP_FOREACH(link, context->links_by_name) { k = link_save(link, p); if (k < 0 && r >= 0) r = k; diff --git a/src/network/generator/network-generator.c b/src/network/generator/network-generator.c index bed1e42697..465b3eddc2 100644 --- a/src/network/generator/network-generator.c +++ b/src/network/generator/network-generator.c @@ -957,7 +957,6 @@ int parse_cmdline_item(const char *key, const char *value, void *data) { int context_merge_networks(Context *context) { Network *all, *network; Route *route; - Iterator i; int r; assert(context); @@ -974,7 +973,7 @@ int context_merge_networks(Context *context) { if (hashmap_size(context->networks_by_name) <= 1) return 0; - HASHMAP_FOREACH(network, context->networks_by_name, i) { + HASHMAP_FOREACH(network, context->networks_by_name) { if (network == all) continue; diff --git a/src/network/netdev/bond.c b/src/network/netdev/bond.c index b5cf162704..3007d6913a 100644 --- a/src/network/netdev/bond.c +++ b/src/network/netdev/bond.c @@ -201,7 +201,6 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin } if (b->arp_interval > 0 && !ordered_set_isempty(b->arp_ip_targets)) { - Iterator i; void *val; int n = 0; @@ -209,7 +208,7 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin if (r < 0) return log_netdev_error_errno(netdev, r, "Could not open contaniner IFLA_BOND_ARP_IP_TARGET : %m"); - ORDERED_SET_FOREACH(val, b->arp_ip_targets, i) { + ORDERED_SET_FOREACH(val, b->arp_ip_targets) { r = sd_netlink_message_append_u32(m, n++, PTR_TO_UINT32(val)); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %m"); diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c index 0d670cb2a5..949f124ccd 100644 --- a/src/network/netdev/l2tp-tunnel.c +++ b/src/network/netdev/l2tp-tunnel.c @@ -275,7 +275,6 @@ static int l2tp_acquire_local_address_one(L2tpTunnel *t, Address *a, union in_ad static int l2tp_acquire_local_address(L2tpTunnel *t, Link *link, union in_addr_union *ret) { Address *a; - Iterator i; assert(t); assert(link); @@ -288,11 +287,11 @@ static int l2tp_acquire_local_address(L2tpTunnel *t, Link *link, union in_addr_u return 0; } - SET_FOREACH(a, link->addresses, i) + SET_FOREACH(a, link->addresses) if (l2tp_acquire_local_address_one(t, a, ret) >= 0) return 1; - SET_FOREACH(a, link->addresses_foreign, i) + SET_FOREACH(a, link->addresses_foreign) if (l2tp_acquire_local_address_one(t, a, ret) >= 0) return 1; @@ -348,7 +347,6 @@ static int l2tp_create_session(NetDev *netdev, L2tpSession *session) { static int l2tp_create_tunnel_handler(sd_netlink *rtnl, sd_netlink_message *m, NetDev *netdev) { L2tpSession *session; L2tpTunnel *t; - Iterator i; int r; assert(netdev); @@ -370,7 +368,7 @@ static int l2tp_create_tunnel_handler(sd_netlink *rtnl, sd_netlink_message *m, N log_netdev_debug(netdev, "L2TP tunnel is created"); - ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section, i) + ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section) (void) l2tp_create_session(netdev, session); return 1; @@ -677,7 +675,6 @@ static int l2tp_session_verify(L2tpSession *session) { static int netdev_l2tp_tunnel_verify(NetDev *netdev, const char *filename) { L2tpTunnel *t; L2tpSession *session; - Iterator i; assert(netdev); assert(filename); @@ -701,7 +698,7 @@ static int netdev_l2tp_tunnel_verify(NetDev *netdev, const char *filename) { "%s: L2TP tunnel without tunnel IDs configured. Ignoring", filename); - ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section, i) + ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section) if (l2tp_session_verify(session) < 0) l2tp_session_free(session); diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c index 2ffa5ec8c6..6fc316b3a0 100644 --- a/src/network/netdev/macsec.c +++ b/src/network/netdev/macsec.c @@ -494,7 +494,6 @@ static int netdev_macsec_configure_transmit_association(NetDev *netdev, Transmit static int netdev_macsec_configure(NetDev *netdev, Link *link, sd_netlink_message *m) { TransmitAssociation *a; ReceiveChannel *c; - Iterator i; MACsec *s; int r; @@ -502,13 +501,13 @@ static int netdev_macsec_configure(NetDev *netdev, Link *link, sd_netlink_messag s = MACSEC(netdev); assert(s); - ORDERED_HASHMAP_FOREACH(a, s->transmit_associations_by_section, i) { + ORDERED_HASHMAP_FOREACH(a, s->transmit_associations_by_section) { r = netdev_macsec_configure_transmit_association(netdev, a); if (r < 0) return r; } - ORDERED_HASHMAP_FOREACH(c, s->receive_channels, i) { + ORDERED_HASHMAP_FOREACH(c, s->receive_channels) { r = netdev_macsec_configure_receive_channel(netdev, c); if (r < 0) return r; @@ -1148,7 +1147,6 @@ static int netdev_macsec_verify(NetDev *netdev, const char *filename) { TransmitAssociation *a; ReceiveAssociation *n; ReceiveChannel *c; - Iterator i; uint8_t an, encoding_an; bool use_for_encoding; int r; @@ -1157,7 +1155,7 @@ static int netdev_macsec_verify(NetDev *netdev, const char *filename) { assert(v); assert(filename); - ORDERED_HASHMAP_FOREACH(c, v->receive_channels_by_section, i) { + ORDERED_HASHMAP_FOREACH(c, v->receive_channels_by_section) { r = macsec_receive_channel_verify(c); if (r < 0) macsec_receive_channel_free(c); @@ -1166,7 +1164,7 @@ static int netdev_macsec_verify(NetDev *netdev, const char *filename) { an = 0; use_for_encoding = false; encoding_an = 0; - ORDERED_HASHMAP_FOREACH(a, v->transmit_associations_by_section, i) { + ORDERED_HASHMAP_FOREACH(a, v->transmit_associations_by_section) { r = macsec_transmit_association_verify(a); if (r < 0) { macsec_transmit_association_free(a); @@ -1201,7 +1199,7 @@ static int netdev_macsec_verify(NetDev *netdev, const char *filename) { assert(encoding_an < MACSEC_MAX_ASSOCIATION_NUMBER); v->encoding_an = encoding_an; - ORDERED_HASHMAP_FOREACH(n, v->receive_associations_by_section, i) { + ORDERED_HASHMAP_FOREACH(n, v->receive_associations_by_section) { r = macsec_receive_association_verify(n); if (r < 0) macsec_receive_association_free(n); diff --git a/src/network/netdev/macvlan.c b/src/network/netdev/macvlan.c index 41391788b0..8f38217789 100644 --- a/src/network/netdev/macvlan.c +++ b/src/network/netdev/macvlan.c @@ -24,7 +24,6 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_net assert(m); if (m->mode == NETDEV_MACVLAN_MODE_SOURCE && !set_isempty(m->match_source_mac)) { - Iterator i; const struct ether_addr *mac_addr; r = sd_netlink_message_append_u32(req, IFLA_MACVLAN_MACADDR_MODE, MACVLAN_MACADDR_SET); @@ -35,7 +34,7 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_net if (r < 0) return log_netdev_error_errno(netdev, r, "Could not open IFLA_MACVLAN_MACADDR_DATA container: %m"); - SET_FOREACH(mac_addr, m->match_source_mac, i) { + SET_FOREACH(mac_addr, m->match_source_mac) { r = sd_netlink_message_append_ether_addr(req, IFLA_MACVLAN_MACADDR, mac_addr); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_MACVLAN_MACADDR attribute: %m"); diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c index 6812b07bff..d15ab845ff 100644 --- a/src/network/netdev/wireguard.c +++ b/src/network/netdev/wireguard.c @@ -395,14 +395,13 @@ static void resolve_endpoints(NetDev *netdev) { }; WireguardPeer *peer; Wireguard *w; - Iterator i; int r; assert(netdev); w = WIREGUARD(netdev); assert(w); - SET_FOREACH(peer, w->peers_with_unresolved_endpoint, i) { + SET_FOREACH(peer, w->peers_with_unresolved_endpoint) { r = resolve_getaddrinfo(netdev->manager->resolve, NULL, peer->endpoint_host, diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 2e89f2d50b..0c4f93045f 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -2477,7 +2477,6 @@ static int link_up_down(int argc, char *argv[], void *userdata) { _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; _cleanup_set_free_ Set *indexes = NULL; int index, r, i; - Iterator j; void *p; r = sd_netlink_open(&rtnl); @@ -2498,7 +2497,7 @@ static int link_up_down(int argc, char *argv[], void *userdata) { return log_oom(); } - SET_FOREACH(p, indexes, j) { + SET_FOREACH(p, indexes) { index = PTR_TO_INT(p); r = link_up_down_send_message(rtnl, argv[0], index); if (r < 0) { @@ -2516,7 +2515,6 @@ static int link_delete(int argc, char *argv[], void *userdata) { _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; _cleanup_set_free_ Set *indexes = NULL; int index, r, i; - Iterator j; void *p; r = sd_netlink_open(&rtnl); @@ -2537,7 +2535,7 @@ static int link_delete(int argc, char *argv[], void *userdata) { return log_oom(); } - SET_FOREACH(p, indexes, j) { + SET_FOREACH(p, indexes) { index = PTR_TO_INT(p); r = link_delete_send_message(rtnl, index); if (r < 0) { @@ -2641,7 +2639,6 @@ static int verb_reconfigure(int argc, char *argv[], void *userdata) { _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; _cleanup_set_free_ Set *indexes = NULL; int index, i, r; - Iterator j; void *p; r = sd_bus_open_system(&bus); @@ -2662,7 +2659,7 @@ static int verb_reconfigure(int argc, char *argv[], void *userdata) { return log_oom(); } - SET_FOREACH(p, indexes, j) { + SET_FOREACH(p, indexes) { index = PTR_TO_INT(p); r = bus_call_method(bus, bus_network_mgr, "ReconfigureLink", &error, NULL, "i", index); if (r < 0) { diff --git a/src/network/networkd-address-pool.c b/src/network/networkd-address-pool.c index db6c1456dc..b4a94f0728 100644 --- a/src/network/networkd-address-pool.c +++ b/src/network/networkd-address-pool.c @@ -75,19 +75,17 @@ static bool address_pool_prefix_is_taken( const union in_addr_union *u, unsigned prefixlen) { - Iterator i; Link *l; Network *n; assert(p); assert(u); - HASHMAP_FOREACH(l, p->manager->links, i) { + HASHMAP_FOREACH(l, p->manager->links) { Address *a; - Iterator j; /* Don't clash with assigned addresses */ - SET_FOREACH(a, l->addresses, j) { + SET_FOREACH(a, l->addresses) { if (a->family != p->family) continue; @@ -106,7 +104,7 @@ static bool address_pool_prefix_is_taken( } /* And don't clash with configured but un-assigned addresses either */ - ORDERED_HASHMAP_FOREACH(n, p->manager->networks, i) { + ORDERED_HASHMAP_FOREACH(n, p->manager->networks) { Address *a; LIST_FOREACH(addresses, a, n->static_addresses) { diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index b193a8f00b..76c91ef9dd 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -125,7 +125,6 @@ void address_free(Address *address) { if (address->link && !address->acd) { NDiscAddress *n; - Iterator i; set_remove(address->link->addresses, address); set_remove(address->link->addresses_foreign, address); @@ -138,7 +137,7 @@ void address_free(Address *address) { set_remove(address->link->dhcp6_addresses_old, address); set_remove(address->link->dhcp6_pd_addresses, address); set_remove(address->link->dhcp6_pd_addresses_old, address); - SET_FOREACH(n, address->link->ndisc_addresses, i) + SET_FOREACH(n, address->link->ndisc_addresses) if (n->address == address) free(set_remove(address->link->ndisc_addresses, n)); @@ -455,9 +454,8 @@ int address_get(Link *link, static bool address_exists_internal(Set *addresses, int family, const union in_addr_union *in_addr) { Address *address; - Iterator i; - SET_FOREACH(address, addresses, i) { + SET_FOREACH(address, addresses) { if (address->family != family) continue; if (in_addr_equal(address->family, &address->in_addr, in_addr)) diff --git a/src/network/networkd-dhcp-server-bus.c b/src/network/networkd-dhcp-server-bus.c index 1731d0bea5..3de8c16d89 100644 --- a/src/network/networkd-dhcp-server-bus.c +++ b/src/network/networkd-dhcp-server-bus.c @@ -22,7 +22,6 @@ static int property_get_leases( Link *l = userdata; sd_dhcp_server *s; DHCPLease *lease; - Iterator i; int r; assert(reply); @@ -36,7 +35,7 @@ static int property_get_leases( if (r < 0) return r; - HASHMAP_FOREACH(lease, s->leases_by_client_id, i) { + HASHMAP_FOREACH(lease, s->leases_by_client_id) { r = sd_bus_message_open_container(reply, 'r', "uayayayayt"); if (r < 0) return r; diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c index 5129a2e37e..890d9b55a1 100644 --- a/src/network/networkd-dhcp-server.c +++ b/src/network/networkd-dhcp-server.c @@ -228,7 +228,6 @@ int dhcp4_server_configure(Link *link) { sd_dhcp_option *p; Link *uplink = NULL; Address *address; - Iterator i; int r; address = link_find_dhcp_server_address(link); @@ -322,7 +321,7 @@ int dhcp4_server_configure(Link *link) { return log_link_error_errno(link, r, "Failed to set timezone for DHCP server: %m"); } - ORDERED_HASHMAP_FOREACH(p, link->network->dhcp_server_send_options, i) { + ORDERED_HASHMAP_FOREACH(p, link->network->dhcp_server_send_options) { r = sd_dhcp_server_add_option(link->dhcp_server, p); if (r == -EEXIST) continue; @@ -330,7 +329,7 @@ int dhcp4_server_configure(Link *link) { return log_link_error_errno(link, r, "Failed to set DHCPv4 option: %m"); } - ORDERED_HASHMAP_FOREACH(p, link->network->dhcp_server_send_vendor_options, i) { + ORDERED_HASHMAP_FOREACH(p, link->network->dhcp_server_send_vendor_options) { r = sd_dhcp_server_add_vendor_option(link->dhcp_server, p); if (r == -EEXIST) continue; diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 8f5b08c079..167b86d0ba 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -25,7 +25,6 @@ static int dhcp4_remove_all(Link *link); static int dhcp4_release_old_lease(Link *link) { Route *route; - Iterator i; int k, r = 0; assert(link); @@ -37,7 +36,7 @@ static int dhcp4_release_old_lease(Link *link) { link_dirty(link); - SET_FOREACH(route, link->dhcp_routes_old, i) { + SET_FOREACH(route, link->dhcp_routes_old) { k = route_remove(route, link, NULL); if (k < 0) r = k; @@ -507,12 +506,11 @@ static int dhcp4_remove_address_handler(sd_netlink *rtnl, sd_netlink_message *m, static int dhcp4_remove_all(Link *link) { Route *route; - Iterator i; int k, r = 0; assert(link); - SET_FOREACH(route, link->dhcp_routes, i) { + SET_FOREACH(route, link->dhcp_routes) { k = route_remove(route, link, dhcp4_remove_route_handler); if (k < 0) r = k; @@ -1245,7 +1243,6 @@ int dhcp4_set_client_identifier(Link *link) { int dhcp4_configure(Link *link) { sd_dhcp_option *send_option; void *request_options; - Iterator i; int r; assert(link); @@ -1337,7 +1334,7 @@ int dhcp4_configure(Link *link) { return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set request flag for timezone: %m"); } - SET_FOREACH(request_options, link->network->dhcp_request_options, i) { + SET_FOREACH(request_options, link->network->dhcp_request_options) { uint32_t option = PTR_TO_UINT32(request_options); r = sd_dhcp_client_set_request_option(link->dhcp_client, option); @@ -1349,7 +1346,7 @@ int dhcp4_configure(Link *link) { return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set request flag for '%u': %m", option); } - ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp_client_send_options, i) { + ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp_client_send_options) { r = sd_dhcp_client_add_option(link->dhcp_client, send_option); if (r == -EEXIST) continue; @@ -1357,7 +1354,7 @@ int dhcp4_configure(Link *link) { return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set send option: %m"); } - ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp_client_send_vendor_options, i) { + ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp_client_send_vendor_options) { r = sd_dhcp_client_add_vendor_option(link->dhcp_client, send_option); if (r == -EEXIST) continue; diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index d969995ea8..839f51b254 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -108,13 +108,12 @@ static int dhcp6_pd_remove_old(Link *link, bool force); static int dhcp6_pd_address_callback(Address *address) { Address *a; - Iterator i; assert(address); assert(address->link); /* Make this called only once */ - SET_FOREACH(a, address->link->dhcp6_pd_addresses, i) + SET_FOREACH(a, address->link->dhcp6_pd_addresses) a->callback = NULL; return dhcp6_pd_remove_old(address->link, true); @@ -123,7 +122,6 @@ static int dhcp6_pd_address_callback(Address *address) { static int dhcp6_pd_remove_old(Link *link, bool force) { Address *address; Route *route; - Iterator i; int k, r = 0; assert(link); @@ -138,14 +136,14 @@ static int dhcp6_pd_remove_old(Link *link, bool force) { if (!force) { bool set_callback = !set_isempty(link->dhcp6_pd_addresses); - SET_FOREACH(address, link->dhcp6_pd_addresses, i) + SET_FOREACH(address, link->dhcp6_pd_addresses) if (address_is_ready(address)) { set_callback = false; break; } if (set_callback) { - SET_FOREACH(address, link->dhcp6_pd_addresses, i) + SET_FOREACH(address, link->dhcp6_pd_addresses) address->callback = dhcp6_pd_address_callback; return 0; } @@ -155,7 +153,7 @@ static int dhcp6_pd_remove_old(Link *link, bool force) { link_dirty(link); - SET_FOREACH(route, link->dhcp6_pd_routes_old, i) { + SET_FOREACH(route, link->dhcp6_pd_routes_old) { k = route_remove(route, link, NULL); if (k < 0) r = k; @@ -164,7 +162,7 @@ static int dhcp6_pd_remove_old(Link *link, bool force) { dhcp6_pd_free(hashmap_get(link->manager->dhcp6_prefixes, &route->dst.in6)); } - SET_FOREACH(address, link->dhcp6_pd_addresses_old, i) { + SET_FOREACH(address, link->dhcp6_pd_addresses_old) { k = address_remove(address, link, NULL); if (k < 0) r = k; @@ -176,7 +174,6 @@ static int dhcp6_pd_remove_old(Link *link, bool force) { int dhcp6_pd_remove(Link *link) { Address *address; Route *route; - Iterator i; int k, r = 0; assert(link); @@ -196,7 +193,7 @@ int dhcp6_pd_remove(Link *link) { link_dirty(link); - SET_FOREACH(route, link->dhcp6_pd_routes, i) { + SET_FOREACH(route, link->dhcp6_pd_routes) { k = route_remove(route, link, NULL); if (k < 0) r = k; @@ -205,7 +202,7 @@ int dhcp6_pd_remove(Link *link) { dhcp6_pd_free(hashmap_get(link->manager->dhcp6_prefixes, &route->dst.in6)); } - SET_FOREACH(address, link->dhcp6_pd_addresses, i) { + SET_FOREACH(address, link->dhcp6_pd_addresses) { k = address_remove(address, link, NULL); if (k < 0) r = k; @@ -517,7 +514,6 @@ static void dhcp6_pd_prefix_distribute(Link *dhcp6_link, uint32_t lifetime_valid, bool assign_preferred_subnet_id) { - Iterator i; Link *link; int r; @@ -526,7 +522,7 @@ static void dhcp6_pd_prefix_distribute(Link *dhcp6_link, assert(masked_pd_prefix); assert(pd_prefix_len <= 64); - HASHMAP_FOREACH(link, dhcp6_link->manager->links, i) { + HASHMAP_FOREACH(link, dhcp6_link->manager->links) { _cleanup_free_ char *assigned_buf = NULL; union in_addr_union assigned_prefix; @@ -636,13 +632,12 @@ static int dhcp6_pd_finalize(Link *link) { static void dhcp6_pd_prefix_lost(Link *dhcp6_link) { Link *link; - Iterator i; int r; assert(dhcp6_link); assert(dhcp6_link->manager); - HASHMAP_FOREACH(link, dhcp6_link->manager->links, i) { + HASHMAP_FOREACH(link, dhcp6_link->manager->links) { if (link == dhcp6_link) continue; @@ -659,13 +654,12 @@ static int dhcp6_remove_old(Link *link, bool force); static int dhcp6_address_callback(Address *address) { Address *a; - Iterator i; assert(address); assert(address->link); /* Make this called only once */ - SET_FOREACH(a, address->link->dhcp6_addresses, i) + SET_FOREACH(a, address->link->dhcp6_addresses) a->callback = NULL; return dhcp6_remove_old(address->link, true); @@ -674,7 +668,6 @@ static int dhcp6_address_callback(Address *address) { static int dhcp6_remove_old(Link *link, bool force) { Address *address; Route *route; - Iterator i; int k, r = 0; assert(link); @@ -688,14 +681,14 @@ static int dhcp6_remove_old(Link *link, bool force) { if (!force) { bool set_callback = !set_isempty(link->dhcp6_addresses); - SET_FOREACH(address, link->dhcp6_addresses, i) + SET_FOREACH(address, link->dhcp6_addresses) if (address_is_ready(address)) { set_callback = false; break; } if (set_callback) { - SET_FOREACH(address, link->dhcp6_addresses, i) + SET_FOREACH(address, link->dhcp6_addresses) address->callback = dhcp6_address_callback; return 0; } @@ -705,13 +698,13 @@ static int dhcp6_remove_old(Link *link, bool force) { link_dirty(link); - SET_FOREACH(route, link->dhcp6_routes_old, i) { + SET_FOREACH(route, link->dhcp6_routes_old) { k = route_remove(route, link, NULL); if (k < 0) r = k; } - SET_FOREACH(address, link->dhcp6_addresses_old, i) { + SET_FOREACH(address, link->dhcp6_addresses_old) { k = address_remove(address, link, NULL); if (k < 0) r = k; @@ -723,7 +716,6 @@ static int dhcp6_remove_old(Link *link, bool force) { static int dhcp6_remove(Link *link) { Address *address; Route *route; - Iterator i; int k, r = 0; assert(link); @@ -742,13 +734,13 @@ static int dhcp6_remove(Link *link) { link_dirty(link); - SET_FOREACH(route, link->dhcp6_routes, i) { + SET_FOREACH(route, link->dhcp6_routes) { k = route_remove(route, link, NULL); if (k < 0) r = k; } - SET_FOREACH(address, link->dhcp6_addresses, i) { + SET_FOREACH(address, link->dhcp6_addresses) { k = address_remove(address, link, NULL); if (k < 0) r = k; @@ -846,14 +838,13 @@ static int dhcp6_set_unreachable_route(Link *link, const union in_addr_union *ad } static int dhcp6_pd_prefix_acquired(Link *dhcp6_link) { - Iterator i; Link *link; int r; assert(dhcp6_link); assert(dhcp6_link->dhcp6_lease); - HASHMAP_FOREACH(link, dhcp6_link->manager->links, i) { + HASHMAP_FOREACH(link, dhcp6_link->manager->links) { if (link == dhcp6_link) continue; @@ -918,7 +909,7 @@ static int dhcp6_pd_prefix_acquired(Link *dhcp6_link) { false); } - HASHMAP_FOREACH(link, dhcp6_link->manager->links, i) { + HASHMAP_FOREACH(link, dhcp6_link->manager->links) { if (link == dhcp6_link) continue; @@ -1230,7 +1221,6 @@ int dhcp6_request_address(Link *link, int ir) { int dhcp6_request_prefix_delegation(Link *link) { Link *l; - Iterator i; assert(link); assert(link->manager); @@ -1240,7 +1230,7 @@ int dhcp6_request_prefix_delegation(Link *link) { log_link_debug(link, "Requesting DHCPv6 prefixes to be delegated for new link"); - HASHMAP_FOREACH(l, link->manager->links, i) { + HASHMAP_FOREACH(l, link->manager->links) { int r, enabled; if (l == link) @@ -1334,12 +1324,11 @@ static int dhcp6_set_hostname(sd_dhcp6_client *client, Link *link) { static bool dhcp6_enable_prefix_delegation(Link *dhcp6_link) { Link *link; - Iterator i; assert(dhcp6_link); assert(dhcp6_link->manager); - HASHMAP_FOREACH(link, dhcp6_link->manager->links, i) { + HASHMAP_FOREACH(link, dhcp6_link->manager->links) { if (link == dhcp6_link) continue; @@ -1358,7 +1347,6 @@ int dhcp6_configure(Link *link) { sd_dhcp6_option *send_option; void *request_options; const DUID *duid; - Iterator i; int r; assert(link); @@ -1400,7 +1388,7 @@ int dhcp6_configure(Link *link) { if (r < 0) return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set DUID: %m"); - ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp6_client_send_options, i) { + ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp6_client_send_options) { r = sd_dhcp6_client_add_option(client, send_option); if (r == -EEXIST) continue; @@ -1428,7 +1416,7 @@ int dhcp6_configure(Link *link) { return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set MUD URL: %m"); } - SET_FOREACH(request_options, link->network->dhcp6_request_options, i) { + SET_FOREACH(request_options, link->network->dhcp6_request_options) { uint32_t option = PTR_TO_UINT32(request_options); r = sd_dhcp6_client_set_request_option(client, option); @@ -1452,7 +1440,7 @@ int dhcp6_configure(Link *link) { return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set vendor class: %m"); } - ORDERED_HASHMAP_FOREACH(vendor_option, link->network->dhcp6_client_send_vendor_options, i) { + ORDERED_HASHMAP_FOREACH(vendor_option, link->network->dhcp6_client_send_vendor_options) { r = sd_dhcp6_client_add_vendor_option(client, vendor_option); if (r == -EEXIST) continue; diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index f623a9b4a1..072dfac93d 100644 --- a/src/network/networkd-link-bus.c +++ b/src/network/networkd-link-bus.c @@ -727,7 +727,6 @@ int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char *** Manager *m = userdata; unsigned c = 0; Link *link; - Iterator i; assert(bus); assert(path); @@ -738,7 +737,7 @@ int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char *** if (!l) return -ENOMEM; - HASHMAP_FOREACH(link, m->links, i) { + HASHMAP_FOREACH(link, m->links) { char *p; p = link_bus_path(link); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 84d6e6e7f4..a1c961442e 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -365,7 +365,6 @@ void link_update_operstate(Link *link, bool also_update_master) { uint8_t scope = RT_SCOPE_NOWHERE; bool changed = false; Address *address; - Iterator i; assert(link); @@ -384,7 +383,7 @@ void link_update_operstate(Link *link, bool also_update_master) { if (carrier_state >= LINK_CARRIER_STATE_CARRIER) { Link *slave; - SET_FOREACH(slave, link->slaves, i) { + SET_FOREACH(slave, link->slaves) { link_update_operstate(slave, false); if (slave->carrier_state < LINK_CARRIER_STATE_CARRIER) @@ -392,7 +391,7 @@ void link_update_operstate(Link *link, bool also_update_master) { } } - SET_FOREACH(address, link->addresses, i) { + SET_FOREACH(address, link->addresses) { if (!address_is_ready(address)) continue; @@ -401,7 +400,7 @@ void link_update_operstate(Link *link, bool also_update_master) { } /* for operstate we also take foreign addresses into account */ - SET_FOREACH(address, link->addresses_foreign, i) { + SET_FOREACH(address, link->addresses_foreign) { if (!address_is_ready(address)) continue; @@ -886,10 +885,9 @@ void link_enter_failed(Link *link) { static int link_join_netdevs_after_configured(Link *link) { NetDev *netdev; - Iterator i; int r; - HASHMAP_FOREACH(netdev, link->network->stacked_netdevs, i) { + HASHMAP_FOREACH(netdev, link->network->stacked_netdevs) { if (netdev->ifindex > 0) /* Assume already enslaved. */ continue; @@ -1101,7 +1099,6 @@ int link_request_set_routes(Link *link) { void link_check_ready(Link *link) { Address *a; - Iterator i; assert(link); @@ -1126,7 +1123,7 @@ void link_check_ready(Link *link) { return; } - SET_FOREACH(a, link->addresses, i) + SET_FOREACH(a, link->addresses) if (!address_is_ready(a)) { _cleanup_free_ char *str = NULL; @@ -1175,7 +1172,7 @@ void link_check_ready(Link *link) { return; } - SET_FOREACH(n, link->ndisc_addresses, i) + SET_FOREACH(n, link->ndisc_addresses) if (!n->marked) { has_ndisc_address = true; break; @@ -1259,7 +1256,6 @@ static int link_set_bridge_fdb(Link *link) { static int static_address_ready_callback(Address *address) { Address *a; - Iterator i; Link *link; assert(address); @@ -1270,7 +1266,7 @@ static int static_address_ready_callback(Address *address) { if (!link->addresses_configured) return 0; - SET_FOREACH(a, link->static_addresses, i) + SET_FOREACH(a, link->static_addresses) if (!address_is_ready(a)) { _cleanup_free_ char *str = NULL; @@ -1280,7 +1276,7 @@ static int static_address_ready_callback(Address *address) { } /* This should not be called again */ - SET_FOREACH(a, link->static_addresses, i) + SET_FOREACH(a, link->static_addresses) a->callback = NULL; link->addresses_ready = true; @@ -1567,9 +1563,8 @@ static bool link_reduces_vlan_mtu(Link *link) { static uint32_t link_get_requested_mtu_by_stacked_netdevs(Link *link) { uint32_t mtu = 0; NetDev *dev; - Iterator i; - HASHMAP_FOREACH(dev, link->network->stacked_netdevs, i) + HASHMAP_FOREACH(dev, link->network->stacked_netdevs) if (dev->kind == NETDEV_KIND_VLAN && dev->mtu > 0) /* See vlan_dev_change_mtu() in kernel. */ mtu = MAX(mtu, link_reduces_vlan_mtu(link) ? dev->mtu + 4 : dev->mtu); @@ -2031,7 +2026,6 @@ static int link_set_group(Link *link) { static int link_handle_bound_to_list(Link *link) { Link *l; - Iterator i; int r; bool required_up = false; bool link_is_up = false; @@ -2044,7 +2038,7 @@ static int link_handle_bound_to_list(Link *link) { if (link->flags & IFF_UP) link_is_up = true; - HASHMAP_FOREACH (l, link->bound_to_links, i) + HASHMAP_FOREACH (l, link->bound_to_links) if (link_has_carrier(l)) { required_up = true; break; @@ -2064,7 +2058,6 @@ static int link_handle_bound_to_list(Link *link) { } static int link_handle_bound_by_list(Link *link) { - Iterator i; Link *l; int r; @@ -2073,7 +2066,7 @@ static int link_handle_bound_by_list(Link *link) { if (hashmap_isempty(link->bound_by_links)) return 0; - HASHMAP_FOREACH (l, link->bound_by_links, i) { + HASHMAP_FOREACH (l, link->bound_by_links) { r = link_handle_bound_to_list(l); if (r < 0) return r; @@ -2108,7 +2101,6 @@ static int link_put_carrier(Link *link, Link *carrier, Hashmap **h) { static int link_new_bound_by_list(Link *link) { Manager *m; Link *carrier; - Iterator i; int r; bool list_updated = false; @@ -2117,7 +2109,7 @@ static int link_new_bound_by_list(Link *link) { m = link->manager; - HASHMAP_FOREACH(carrier, m->links, i) { + HASHMAP_FOREACH(carrier, m->links) { if (!carrier->network) continue; @@ -2136,7 +2128,7 @@ static int link_new_bound_by_list(Link *link) { if (list_updated) link_dirty(link); - HASHMAP_FOREACH(carrier, link->bound_by_links, i) { + HASHMAP_FOREACH(carrier, link->bound_by_links) { r = link_put_carrier(carrier, link, &carrier->bound_to_links); if (r < 0) return r; @@ -2150,7 +2142,6 @@ static int link_new_bound_by_list(Link *link) { static int link_new_bound_to_list(Link *link) { Manager *m; Link *carrier; - Iterator i; int r; bool list_updated = false; @@ -2165,7 +2156,7 @@ static int link_new_bound_to_list(Link *link) { m = link->manager; - HASHMAP_FOREACH (carrier, m->links, i) { + HASHMAP_FOREACH (carrier, m->links) { if (strv_fnmatch(link->network->bind_carrier, carrier->ifname)) { r = link_put_carrier(link, carrier, &link->bound_to_links); if (r < 0) @@ -2178,7 +2169,7 @@ static int link_new_bound_to_list(Link *link) { if (list_updated) link_dirty(link); - HASHMAP_FOREACH (carrier, link->bound_to_links, i) { + HASHMAP_FOREACH (carrier, link->bound_to_links) { r = link_put_carrier(carrier, link, &carrier->bound_by_links); if (r < 0) return r; @@ -2213,9 +2204,8 @@ static int link_new_carrier_maps(Link *link) { static void link_free_bound_to_list(Link *link) { Link *bound_to; - Iterator i; - HASHMAP_FOREACH (bound_to, link->bound_to_links, i) { + HASHMAP_FOREACH (bound_to, link->bound_to_links) { hashmap_remove(link->bound_to_links, INT_TO_PTR(bound_to->ifindex)); if (hashmap_remove(bound_to->bound_by_links, INT_TO_PTR(link->ifindex))) @@ -2227,9 +2217,8 @@ static void link_free_bound_to_list(Link *link) { static void link_free_bound_by_list(Link *link) { Link *bound_by; - Iterator i; - HASHMAP_FOREACH (bound_by, link->bound_by_links, i) { + HASHMAP_FOREACH (bound_by, link->bound_by_links) { hashmap_remove(link->bound_by_links, INT_TO_PTR(bound_by->ifindex)); if (hashmap_remove(bound_by->bound_to_links, INT_TO_PTR(link->ifindex))) { @@ -2413,7 +2402,6 @@ static int netdev_join_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li static int link_enter_join_netdev(Link *link) { NetDev *netdev; - Iterator i; int r; assert(link); @@ -2486,7 +2474,7 @@ static int link_enter_join_netdev(Link *link) { } } - HASHMAP_FOREACH(netdev, link->network->stacked_netdevs, i) { + HASHMAP_FOREACH(netdev, link->network->stacked_netdevs) { if (netdev->ifindex > 0) /* Assume already enslaved. */ @@ -2745,7 +2733,6 @@ static bool link_is_static_route_configured(Link *link, Route *route) { static bool link_address_is_dynamic(Link *link, Address *address) { Route *route; - Iterator i; assert(link); assert(address); @@ -2756,7 +2743,7 @@ static bool link_address_is_dynamic(Link *link, Address *address) { /* Even when the address is leased from a DHCP server, networkd assign the address * without lifetime when KeepConfiguration=dhcp. So, let's check that we have * corresponding routes with RTPROT_DHCP. */ - SET_FOREACH(route, link->routes_foreign, i) { + SET_FOREACH(route, link->routes_foreign) { if (route->protocol != RTPROT_DHCP) continue; @@ -2816,7 +2803,6 @@ static int link_drop_foreign_config(Link *link) { Address *address; Neighbor *neighbor; Route *route; - Iterator i; int r; /* The kernel doesn't notify us about tentative addresses; @@ -2827,7 +2813,7 @@ static int link_drop_foreign_config(Link *link) { return r; } - SET_FOREACH(address, link->addresses_foreign, i) { + SET_FOREACH(address, link->addresses_foreign) { /* we consider IPv6LL addresses to be managed by the kernel */ if (address->family == AF_INET6 && in_addr_is_link_local(AF_INET6, &address->in_addr) == 1 && link_ipv6ll_enabled(link)) continue; @@ -2849,7 +2835,7 @@ static int link_drop_foreign_config(Link *link) { } } - SET_FOREACH(neighbor, link->neighbors_foreign, i) { + SET_FOREACH(neighbor, link->neighbors_foreign) { if (link_is_neighbor_configured(link, neighbor)) { r = neighbor_add(link, neighbor->family, &neighbor->in_addr, &neighbor->lladdr, neighbor->lladdr_size, NULL); if (r < 0) @@ -2861,7 +2847,7 @@ static int link_drop_foreign_config(Link *link) { } } - SET_FOREACH(route, link->routes_foreign, i) { + SET_FOREACH(route, link->routes_foreign) { /* do not touch routes managed by the kernel */ if (route->protocol == RTPROT_KERNEL) continue; @@ -2930,10 +2916,9 @@ static int link_drop_config(Link *link) { Address *address, *pool_address; Neighbor *neighbor; Route *route; - Iterator i; int r; - SET_FOREACH(address, link->addresses, i) { + SET_FOREACH(address, link->addresses) { /* we consider IPv6LL addresses to be managed by the kernel */ if (address->family == AF_INET6 && in_addr_is_link_local(AF_INET6, &address->in_addr) == 1 && link_ipv6ll_enabled(link)) continue; @@ -2953,13 +2938,13 @@ static int link_drop_config(Link *link) { } } - SET_FOREACH(neighbor, link->neighbors, i) { + SET_FOREACH(neighbor, link->neighbors) { r = neighbor_remove(neighbor, link, NULL); if (r < 0) return r; } - SET_FOREACH(route, link->routes, i) { + SET_FOREACH(route, link->routes) { /* do not touch routes managed by the kernel */ if (route->protocol == RTPROT_KERNEL) continue; @@ -2994,13 +2979,12 @@ static int link_configure_ipv4_dad(Link *link) { static int link_configure_traffic_control(Link *link) { TrafficControl *tc; - Iterator i; int r; link->tc_configured = false; link->tc_messages = 0; - ORDERED_HASHMAP_FOREACH(tc, link->network->tc_by_section, i) { + ORDERED_HASHMAP_FOREACH(tc, link->network->tc_by_section) { r = traffic_control_configure(link, tc); if (r < 0) return r; @@ -3016,13 +3000,12 @@ static int link_configure_traffic_control(Link *link) { static int link_configure_sr_iov(Link *link) { SRIOV *sr_iov; - Iterator i; int r; link->sr_iov_configured = false; link->sr_iov_messages = 0; - ORDERED_HASHMAP_FOREACH(sr_iov, link->network->sr_iov_by_section, i) { + ORDERED_HASHMAP_FOREACH(sr_iov, link->network->sr_iov_by_section) { r = sr_iov_configure(link, sr_iov); if (r < 0) return r; @@ -4224,7 +4207,6 @@ int link_update(Link *link, sd_netlink_message *m) { static void print_link_hashmap(FILE *f, const char *prefix, Hashmap* h) { bool space = false; - Iterator i; Link *link; assert(f); @@ -4234,7 +4216,7 @@ static void print_link_hashmap(FILE *f, const char *prefix, Hashmap* h) { return; fputs(prefix, f); - HASHMAP_FOREACH(link, h, i) { + HASHMAP_FOREACH(link, h) { if (space) fputc(' ', f); @@ -4319,7 +4301,6 @@ int link_save(Link *link) { _cleanup_fclose_ FILE *f = NULL; Route *route; Address *a; - Iterator i; int r; assert(link); @@ -4401,7 +4382,7 @@ int link_save(Link *link) { if (link->network->ipv6_accept_ra_use_dns && link->ndisc_rdnss) { NDiscRDNSS *dd; - SET_FOREACH(dd, link->ndisc_rdnss, i) + SET_FOREACH(dd, link->ndisc_rdnss) serialize_in6_addrs(f, &dd->address, 1, &space); } @@ -4439,7 +4420,7 @@ int link_save(Link *link) { fputs("DOMAINS=", f); space = false; - ORDERED_SET_FOREACH(p, link->search_domains ?: link->network->search_domains, i) + ORDERED_SET_FOREACH(p, link->search_domains ?: link->network->search_domains) fputs_with_space(f, p, NULL, &space); if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_YES) { @@ -4454,7 +4435,7 @@ int link_save(Link *link) { if (link->network->ipv6_accept_ra_use_domains == DHCP_USE_DOMAINS_YES) { NDiscDNSSL *dd; - SET_FOREACH(dd, link->ndisc_dnssl, i) + SET_FOREACH(dd, link->ndisc_dnssl) fputs_with_space(f, NDISC_DNSSL_DOMAIN(dd), NULL, &space); } @@ -4464,7 +4445,7 @@ int link_save(Link *link) { fputs("ROUTE_DOMAINS=", f); space = false; - ORDERED_SET_FOREACH(p, link->route_domains ?: link->network->route_domains, i) + ORDERED_SET_FOREACH(p, link->route_domains ?: link->network->route_domains) fputs_with_space(f, p, NULL, &space); if (link->network->dhcp_use_domains == DHCP_USE_DOMAINS_ROUTE) { @@ -4479,7 +4460,7 @@ int link_save(Link *link) { if (link->network->ipv6_accept_ra_use_domains == DHCP_USE_DOMAINS_ROUTE) { NDiscDNSSL *dd; - SET_FOREACH(dd, link->ndisc_dnssl, i) + SET_FOREACH(dd, link->ndisc_dnssl) fputs_with_space(f, NDISC_DNSSL_DOMAIN(dd), NULL, &space); } @@ -4530,7 +4511,7 @@ int link_save(Link *link) { fputs("DNSSEC_NTA=", f); space = false; - SET_FOREACH(n, nta_anchors, i) + SET_FOREACH(n, nta_anchors) fputs_with_space(f, n, NULL, &space); fputc('\n', f); } @@ -4539,7 +4520,7 @@ int link_save(Link *link) { fputs("ADDRESSES=", f); space = false; - SET_FOREACH(a, link->addresses, i) { + SET_FOREACH(a, link->addresses) { _cleanup_free_ char *address_str = NULL; r = in_addr_to_string(a->family, &a->in_addr, &address_str); @@ -4555,7 +4536,7 @@ int link_save(Link *link) { fputs("ROUTES=", f); space = false; - SET_FOREACH(route, link->routes, i) { + SET_FOREACH(route, link->routes) { _cleanup_free_ char *route_str = NULL; r = in_addr_to_string(route->family, &route->dst, &route_str); diff --git a/src/network/networkd-manager-bus.c b/src/network/networkd-manager-bus.c index 9db59d93f8..8dbcdff826 100644 --- a/src/network/networkd-manager-bus.c +++ b/src/network/networkd-manager-bus.c @@ -20,7 +20,6 @@ static int method_list_links(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; Manager *manager = userdata; - Iterator i; Link *link; int r; @@ -32,7 +31,7 @@ static int method_list_links(sd_bus_message *message, void *userdata, sd_bus_err if (r < 0) return r; - HASHMAP_FOREACH(link, manager->links, i) { + HASHMAP_FOREACH(link, manager->links) { _cleanup_free_ char *path = NULL; path = link_bus_path(link); @@ -201,7 +200,6 @@ static int bus_method_reconfigure_link(sd_bus_message *message, void *userdata, static int bus_method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *manager = userdata; - Iterator i; Link *link; int r; @@ -222,7 +220,7 @@ static int bus_method_reload(sd_bus_message *message, void *userdata, sd_bus_err if (r < 0) return r; - HASHMAP_FOREACH(link, manager->links, i) { + HASHMAP_FOREACH(link, manager->links) { r = link_reconfigure(link, false); if (r < 0) return r; diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index a697e2133a..6187434466 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -81,12 +81,11 @@ static int setup_default_address_pool(Manager *m) { static int manager_reset_all(Manager *m) { Link *link; - Iterator i; int r; assert(m); - HASHMAP_FOREACH(link, m->links, i) { + HASHMAP_FOREACH(link, m->links) { r = link_carrier_reset(link); if (r < 0) log_link_warning_errno(link, r, "Could not reset carrier: %m"); @@ -1519,7 +1518,6 @@ static int manager_save(Manager *m) { _cleanup_strv_free_ char **p = NULL; _cleanup_fclose_ FILE *f = NULL; Link *link; - Iterator i; int r; assert(m); @@ -1546,7 +1544,7 @@ static int manager_save(Manager *m) { if (!route_domains) return -ENOMEM; - HASHMAP_FOREACH(link, m->links, i) { + HASHMAP_FOREACH(link, m->links) { const struct in_addr *addresses; if (link->flags & IFF_LOOPBACK) @@ -1723,14 +1721,13 @@ fail: static int manager_dirty_handler(sd_event_source *s, void *userdata) { Manager *m = userdata; Link *link; - Iterator i; assert(m); if (m->dirty) manager_save(m); - SET_FOREACH(link, m->dirty_links, i) + SET_FOREACH(link, m->dirty_links) (void) link_save_and_clean(link); return 1; @@ -1827,14 +1824,13 @@ int manager_new(Manager **ret) { void manager_free(Manager *m) { AddressPool *pool; Link *link; - Iterator i; if (!m) return; free(m->state_file); - HASHMAP_FOREACH(link, m->links, i) + HASHMAP_FOREACH(link, m->links) (void) link_stop_clients(link, true); m->dhcp6_prefixes = hashmap_free_with_destructor(m->dhcp6_prefixes, dhcp6_pd_free); @@ -1880,7 +1876,6 @@ void manager_free(Manager *m) { int manager_start(Manager *m) { Link *link; - Iterator i; int r; assert(m); @@ -1894,7 +1889,7 @@ int manager_start(Manager *m) { manager_save(m); - HASHMAP_FOREACH(link, m->links, i) + HASHMAP_FOREACH(link, m->links) (void) link_save(link); return 0; diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index bcea91c696..23b0ea069d 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -40,12 +40,11 @@ static int ndisc_remove_old_one(Link *link, const struct in6_addr *router, bool static int ndisc_address_callback(Address *address) { struct in6_addr router = {}; NDiscAddress *n; - Iterator i; assert(address); assert(address->link); - SET_FOREACH(n, address->link->ndisc_addresses, i) + SET_FOREACH(n, address->link->ndisc_addresses) if (n->address == address) { router = n->router; break; @@ -61,7 +60,7 @@ static int ndisc_address_callback(Address *address) { } /* Make this called only once */ - SET_FOREACH(n, address->link->ndisc_addresses, i) + SET_FOREACH(n, address->link->ndisc_addresses) if (IN6_ARE_ADDR_EQUAL(&n->router, &router)) n->address->callback = NULL; @@ -73,7 +72,6 @@ static int ndisc_remove_old_one(Link *link, const struct in6_addr *router, bool NDiscRoute *nr; NDiscDNSSL *dnssl; NDiscRDNSS *rdnss; - Iterator i; int k, r = 0; assert(link); @@ -85,21 +83,21 @@ static int ndisc_remove_old_one(Link *link, const struct in6_addr *router, bool if (!link->ndisc_addresses_configured || !link->ndisc_routes_configured) return 0; - SET_FOREACH(na, link->ndisc_addresses, i) + SET_FOREACH(na, link->ndisc_addresses) if (!na->marked && IN6_ARE_ADDR_EQUAL(&na->router, router)) { set_callback = true; break; } if (set_callback) - SET_FOREACH(na, link->ndisc_addresses, i) + SET_FOREACH(na, link->ndisc_addresses) if (!na->marked && address_is_ready(na->address)) { set_callback = false; break; } if (set_callback) { - SET_FOREACH(na, link->ndisc_addresses, i) + SET_FOREACH(na, link->ndisc_addresses) if (!na->marked && IN6_ARE_ADDR_EQUAL(&na->router, router)) na->address->callback = ndisc_address_callback; @@ -124,25 +122,25 @@ static int ndisc_remove_old_one(Link *link, const struct in6_addr *router, bool link_dirty(link); - SET_FOREACH(na, link->ndisc_addresses, i) + SET_FOREACH(na, link->ndisc_addresses) if (na->marked && IN6_ARE_ADDR_EQUAL(&na->router, router)) { k = address_remove(na->address, link, NULL); if (k < 0) r = k; } - SET_FOREACH(nr, link->ndisc_routes, i) + SET_FOREACH(nr, link->ndisc_routes) if (nr->marked && IN6_ARE_ADDR_EQUAL(&nr->router, router)) { k = route_remove(nr->route, link, NULL); if (k < 0) r = k; } - SET_FOREACH(rdnss, link->ndisc_rdnss, i) + SET_FOREACH(rdnss, link->ndisc_rdnss) if (rdnss->marked && IN6_ARE_ADDR_EQUAL(&rdnss->router, router)) free(set_remove(link->ndisc_rdnss, rdnss)); - SET_FOREACH(dnssl, link->ndisc_dnssl, i) + SET_FOREACH(dnssl, link->ndisc_dnssl) if (dnssl->marked && IN6_ARE_ADDR_EQUAL(&dnssl->router, router)) free(set_remove(link->ndisc_dnssl, dnssl)); @@ -157,7 +155,6 @@ static int ndisc_remove_old(Link *link) { NDiscRoute *nr; NDiscDNSSL *dnssl; NDiscRDNSS *rdnss; - Iterator i; int k, r; assert(link); @@ -166,7 +163,7 @@ static int ndisc_remove_old(Link *link) { if (!routers) return -ENOMEM; - SET_FOREACH(na, link->ndisc_addresses, i) + SET_FOREACH(na, link->ndisc_addresses) if (!set_contains(routers, &na->router)) { router = newdup(struct in6_addr, &na->router, 1); if (!router) @@ -180,7 +177,7 @@ static int ndisc_remove_old(Link *link) { TAKE_PTR(router); } - SET_FOREACH(nr, link->ndisc_routes, i) + SET_FOREACH(nr, link->ndisc_routes) if (!set_contains(routers, &nr->router)) { router = newdup(struct in6_addr, &nr->router, 1); if (!router) @@ -194,7 +191,7 @@ static int ndisc_remove_old(Link *link) { TAKE_PTR(router); } - SET_FOREACH(rdnss, link->ndisc_rdnss, i) + SET_FOREACH(rdnss, link->ndisc_rdnss) if (!set_contains(routers, &rdnss->router)) { router = newdup(struct in6_addr, &rdnss->router, 1); if (!router) @@ -208,7 +205,7 @@ static int ndisc_remove_old(Link *link) { TAKE_PTR(router); } - SET_FOREACH(dnssl, link->ndisc_dnssl, i) + SET_FOREACH(dnssl, link->ndisc_dnssl) if (!set_contains(routers, &dnssl->router)) { router = newdup(struct in6_addr, &dnssl->router, 1); if (!router) @@ -223,7 +220,7 @@ static int ndisc_remove_old(Link *link) { } r = 0; - SET_FOREACH(a, routers, i) { + SET_FOREACH(a, routers) { k = ndisc_remove_old_one(link, a, false); if (k < 0) r = k; @@ -571,7 +568,6 @@ static int make_stableprivate_address(Link *link, const struct in6_addr *prefix, static int ndisc_router_generate_addresses(Link *link, struct in6_addr *address, uint8_t prefixlen, Set **ret) { _cleanup_set_free_free_ Set *addresses = NULL; IPv6Token *j; - Iterator i; int r; assert(link); @@ -582,7 +578,7 @@ static int ndisc_router_generate_addresses(Link *link, struct in6_addr *address, if (!addresses) return log_oom(); - ORDERED_SET_FOREACH(j, link->network->ipv6_tokens, i) { + ORDERED_SET_FOREACH(j, link->network->ipv6_tokens) { _cleanup_free_ struct in6_addr *new_address = NULL; if (j->address_generation_type == IPV6_TOKEN_ADDRESS_GENERATION_PREFIXSTABLE @@ -650,7 +646,6 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r struct in6_addr addr, *a; unsigned prefixlen; usec_t time_now; - Iterator i; int r; assert(link); @@ -693,7 +688,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r address->flags = IFA_F_NOPREFIXROUTE|IFA_F_MANAGETEMPADDR; address->cinfo.ifa_prefered = lifetime_preferred; - SET_FOREACH(a, addresses, i) { + SET_FOREACH(a, addresses) { Address *existing_address; /* see RFC4862 section 5.5.3.e */ @@ -847,7 +842,6 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) { struct in6_addr router; NDiscRDNSS *rdnss; usec_t time_now; - Iterator i; int n, r; assert(link); @@ -869,7 +863,7 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) { if (n < 0) return log_link_error_errno(link, n, "Failed to get RDNSS addresses: %m"); - SET_FOREACH(rdnss, link->ndisc_rdnss, i) + SET_FOREACH(rdnss, link->ndisc_rdnss) if (IN6_ARE_ADDR_EQUAL(&rdnss->router, &router)) rdnss->marked = true; @@ -935,7 +929,6 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) { uint32_t lifetime; usec_t time_now; NDiscDNSSL *dnssl; - Iterator i; char **j; int r; @@ -958,7 +951,7 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) { if (r < 0) return log_link_error_errno(link, r, "Failed to get DNSSL addresses: %m"); - SET_FOREACH(dnssl, link->ndisc_dnssl, i) + SET_FOREACH(dnssl, link->ndisc_dnssl) if (IN6_ARE_ADDR_EQUAL(&dnssl->router, &router)) dnssl->marked = true; @@ -1087,7 +1080,6 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) { uint64_t flags; NDiscAddress *na; NDiscRoute *nr; - Iterator i; int r; assert(link); @@ -1104,11 +1096,11 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) { if (r < 0) return log_link_error_errno(link, r, "Failed to get router address from RA: %m"); - SET_FOREACH(na, link->ndisc_addresses, i) + SET_FOREACH(na, link->ndisc_addresses) if (IN6_ARE_ADDR_EQUAL(&na->router, &router)) na->marked = true; - SET_FOREACH(nr, link->ndisc_routes, i) + SET_FOREACH(nr, link->ndisc_routes) if (IN6_ARE_ADDR_EQUAL(&nr->router, &router)) nr->marked = true; @@ -1228,7 +1220,6 @@ int ndisc_configure(Link *link) { void ndisc_vacuum(Link *link) { NDiscRDNSS *r; NDiscDNSSL *d; - Iterator i; usec_t time_now; bool updated = false; @@ -1238,13 +1229,13 @@ void ndisc_vacuum(Link *link) { time_now = now(clock_boottime_or_monotonic()); - SET_FOREACH(r, link->ndisc_rdnss, i) + SET_FOREACH(r, link->ndisc_rdnss) if (r->valid_until < time_now) { free(set_remove(link->ndisc_rdnss, r)); updated = true; } - SET_FOREACH(d, link->ndisc_dnssl, i) + SET_FOREACH(d, link->ndisc_dnssl) if (d->valid_until < time_now) { free(set_remove(link->ndisc_dnssl, d)); updated = true; diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c index a895f72688..70fddd56a5 100644 --- a/src/network/networkd-network-bus.c +++ b/src/network/networkd-network-bus.c @@ -18,7 +18,6 @@ static int property_get_ether_addrs( char buf[ETHER_ADDR_TO_STRING_MAX]; const struct ether_addr *p; - Iterator i; Set *s; int r; @@ -32,7 +31,7 @@ static int property_get_ether_addrs( if (r < 0) return r; - SET_FOREACH(p, s, i) { + SET_FOREACH(p, s) { r = sd_bus_message_append(reply, "s", ether_addr_to_string(p, buf)); if (r < 0) return r; @@ -88,7 +87,6 @@ int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; Network *network; - Iterator i; int r; assert(bus); @@ -96,7 +94,7 @@ int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char assert(m); assert(nodes); - ORDERED_HASHMAP_FOREACH(network, m->networks, i) { + ORDERED_HASHMAP_FOREACH(network, m->networks) { char *p; p = network_bus_path(network); diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 97f5551ee5..a61e774e36 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -121,12 +121,11 @@ static int network_resolve_netdev_one(Network *network, const char *name, NetDev static int network_resolve_stacked_netdevs(Network *network) { void *name, *kind; - Iterator i; int r; assert(network); - HASHMAP_FOREACH_KEY(kind, name, network->stacked_netdev_names, i) { + HASHMAP_FOREACH_KEY(kind, name, network->stacked_netdev_names) { _cleanup_(netdev_unrefp) NetDev *netdev = NULL; r = network_resolve_netdev_one(network, name, PTR_TO_INT(kind), &netdev); @@ -160,7 +159,6 @@ int network_verify(Network *network) { FdbEntry *fdb, *fdb_next; TrafficControl *tc; SRIOV *sr_iov; - Iterator i; assert(network); assert(network->filename); @@ -328,11 +326,11 @@ int network_verify(Network *network) { routing_policy_rule_free(rule); bool has_root = false, has_clsact = false; - ORDERED_HASHMAP_FOREACH(tc, network->tc_by_section, i) + ORDERED_HASHMAP_FOREACH(tc, network->tc_by_section) if (traffic_control_section_verify(tc, &has_root, &has_clsact) < 0) traffic_control_free(tc); - ORDERED_HASHMAP_FOREACH(sr_iov, network->sr_iov_by_section, i) + ORDERED_HASHMAP_FOREACH(sr_iov, network->sr_iov_by_section) if (sr_iov_section_verify(sr_iov) < 0) sr_iov_free(sr_iov); @@ -600,7 +598,6 @@ int network_load(Manager *manager, OrderedHashmap **networks) { int network_reload(Manager *manager) { OrderedHashmap *new_networks = NULL; Network *n, *old; - Iterator i; int r; assert(manager); @@ -609,7 +606,7 @@ int network_reload(Manager *manager) { if (r < 0) goto failure; - ORDERED_HASHMAP_FOREACH(n, new_networks, i) { + ORDERED_HASHMAP_FOREACH(n, new_networks) { r = network_get_by_name(manager, n->name, &old); if (r < 0) continue; /* The .network file is new. */ @@ -798,12 +795,11 @@ int network_get(Manager *manager, unsigned short iftype, sd_device *device, enum nl80211_iftype wlan_iftype, const char *ssid, const struct ether_addr *bssid, Network **ret) { Network *network; - Iterator i; assert(manager); assert(ret); - ORDERED_HASHMAP_FOREACH(network, manager->networks, i) + ORDERED_HASHMAP_FOREACH(network, manager->networks) if (net_match_config(network->match_mac, network->match_permanent_mac, network->match_path, network->match_driver, network->match_type, network->match_name, network->match_property, diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 28c0f3b898..b82c4e7f79 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -144,7 +144,6 @@ void route_free(Route *route) { if (route->link) { NDiscRoute *n; - Iterator i; set_remove(route->link->routes, route); set_remove(route->link->routes_foreign, route); @@ -154,7 +153,7 @@ void route_free(Route *route) { set_remove(route->link->dhcp6_routes_old, route); set_remove(route->link->dhcp6_pd_routes, route); set_remove(route->link->dhcp6_pd_routes_old, route); - SET_FOREACH(n, route->link->ndisc_routes, i) + SET_FOREACH(n, route->link->ndisc_routes) if (n->route == route) free(set_remove(route->link->ndisc_routes, n)); } @@ -575,7 +574,6 @@ static int append_nexthops(Route *route, sd_netlink_message *req) { struct rtnexthop *rtnh; MultipathRoute *m; size_t offset; - Iterator i; int r; if (ordered_set_isempty(route->multipath_routes)) @@ -591,7 +589,7 @@ static int append_nexthops(Route *route, sd_netlink_message *req) { }; offset = (uint8_t *) RTA_DATA(rta) - (uint8_t *) rta; - ORDERED_SET_FOREACH(m, route->multipath_routes, i) { + ORDERED_SET_FOREACH(m, route->multipath_routes) { r = append_nexthop_one(route, m, &rta, offset); if (r < 0) return r; diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index d4950540be..0905056cf7 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -1168,12 +1168,11 @@ int config_parse_routing_policy_rule_suppress_prefixlen( int routing_policy_serialize_rules(Set *rules, FILE *f) { RoutingPolicyRule *rule = NULL; - Iterator i; int r; assert(f); - SET_FOREACH(rule, rules, i) { + SET_FOREACH(rule, rules) { _cleanup_free_ char *from_str = NULL, *to_str = NULL; const char *family_str; bool space = false; @@ -1489,13 +1488,12 @@ int routing_policy_load_rules(const char *state_file, Set **rules) { static bool manager_links_have_routing_policy_rule(Manager *m, RoutingPolicyRule *rule) { RoutingPolicyRule *link_rule; - Iterator i; Link *link; assert(m); assert(rule); - HASHMAP_FOREACH(link, m->links, i) { + HASHMAP_FOREACH(link, m->links) { if (!link->network) continue; @@ -1509,13 +1507,12 @@ static bool manager_links_have_routing_policy_rule(Manager *m, RoutingPolicyRule void routing_policy_rule_purge(Manager *m, Link *link) { RoutingPolicyRule *rule, *existing; - Iterator i; int r; assert(m); assert(link); - SET_FOREACH(rule, m->rules_saved, i) { + SET_FOREACH(rule, m->rules_saved) { existing = set_get(m->rules_foreign, rule); if (!existing) continue; /* Saved rule does not exist anymore. */ diff --git a/src/network/networkd-speed-meter.c b/src/network/networkd-speed-meter.c index c4fc56b019..ecf0346344 100644 --- a/src/network/networkd-speed-meter.c +++ b/src/network/networkd-speed-meter.c @@ -46,7 +46,6 @@ static int speed_meter_handler(sd_event_source *s, uint64_t usec, void *userdata Manager *manager = userdata; sd_netlink_message *i; usec_t usec_now; - Iterator j; Link *link; int r; @@ -64,7 +63,7 @@ static int speed_meter_handler(sd_event_source *s, uint64_t usec, void *userdata manager->speed_meter_usec_old = manager->speed_meter_usec_new; manager->speed_meter_usec_new = usec_now; - HASHMAP_FOREACH(link, manager->links, j) + HASHMAP_FOREACH(link, manager->links) link->stats_updated = false; r = sd_rtnl_message_new_link(manager->rtnl, &req, RTM_GETLINK, 0); diff --git a/src/network/wait-online/manager.c b/src/network/wait-online/manager.c index 6ab26d3ca9..e84eed46ac 100644 --- a/src/network/wait-online/manager.c +++ b/src/network/wait-online/manager.c @@ -66,7 +66,6 @@ static int manager_link_is_online(Manager *m, Link *l, LinkOperationalStateRange bool manager_configured(Manager *m) { bool one_ready = false; - Iterator i; const char *ifname; void *p; Link *l; @@ -74,7 +73,7 @@ bool manager_configured(Manager *m) { if (!hashmap_isempty(m->interfaces)) { /* wait for all the links given on the command line to appear */ - HASHMAP_FOREACH_KEY(p, ifname, m->interfaces, i) { + HASHMAP_FOREACH_KEY(p, ifname, m->interfaces) { LinkOperationalStateRange *range = p; l = hashmap_get(m->links_by_name, ifname); @@ -106,7 +105,7 @@ bool manager_configured(Manager *m) { /* wait for all links networkd manages to be in admin state 'configured' * and at least one link to gain a carrier */ - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { if (manager_ignore_link(m, l)) { log_link_debug(l, "link is ignored"); continue; @@ -255,7 +254,6 @@ static int manager_rtnl_listen(Manager *m) { static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) { Manager *m = userdata; - Iterator i; Link *l; int r; @@ -263,7 +261,7 @@ static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void * sd_network_monitor_flush(m->network_monitor); - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { r = link_update_monitor(l); if (r < 0 && r != -ENODATA) log_link_warning_errno(l, r, "Failed to update link state, ignoring: %m"); diff --git a/src/portable/portable.c b/src/portable/portable.c index bd7edce807..e55a8116c6 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -103,7 +103,6 @@ static int compare_metadata(PortableMetadata *const *x, PortableMetadata *const int portable_metadata_hashmap_to_sorted_array(Hashmap *unit_files, PortableMetadata ***ret) { _cleanup_free_ PortableMetadata **sorted = NULL; - Iterator iterator; PortableMetadata *item; size_t k = 0; @@ -111,7 +110,7 @@ int portable_metadata_hashmap_to_sorted_array(Hashmap *unit_files, PortableMetad if (!sorted) return -ENOMEM; - HASHMAP_FOREACH(item, unit_files, iterator) + HASHMAP_FOREACH(item, unit_files) sorted[k++] = item; assert(k == hashmap_size(unit_files)); @@ -987,7 +986,6 @@ int portable_attach( _cleanup_(lookup_paths_free) LookupPaths paths = {}; _cleanup_(image_unrefp) Image *image = NULL; PortableMetadata *item; - Iterator iterator; int r; assert(name_or_path); @@ -1004,7 +1002,7 @@ int portable_attach( if (r < 0) return r; - HASHMAP_FOREACH(item, unit_files, iterator) { + HASHMAP_FOREACH(item, unit_files) { r = unit_file_exists(UNIT_FILE_SYSTEM, &paths, item->name); if (r < 0) return sd_bus_error_set_errnof(error, r, "Failed to determine whether unit '%s' exists on the host: %m", item->name); @@ -1018,7 +1016,7 @@ int portable_attach( return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, "Unit file '%s' is active already, refusing.", item->name); } - HASHMAP_FOREACH(item, unit_files, iterator) { + HASHMAP_FOREACH(item, unit_files) { r = attach_unit_file(&paths, image->path, image->type, item, profile, flags, changes, n_changes); if (r < 0) return r; @@ -1140,7 +1138,6 @@ int portable_detach( _cleanup_set_free_ Set *unit_files = NULL, *markers = NULL; _cleanup_closedir_ DIR *d = NULL; const char *where, *item; - Iterator iterator; struct dirent *de; int ret = 0; int r; @@ -1210,7 +1207,7 @@ int portable_detach( if (set_isempty(unit_files)) goto not_found; - SET_FOREACH(item, unit_files, iterator) { + SET_FOREACH(item, unit_files) { _cleanup_free_ char *md = NULL; const char *suffix; @@ -1252,7 +1249,7 @@ int portable_detach( } /* Now, also drop any image symlink, for images outside of the sarch path */ - SET_FOREACH(item, markers, iterator) { + SET_FOREACH(item, markers) { _cleanup_free_ char *sl = NULL; struct stat st; diff --git a/src/portable/portabled-bus.c b/src/portable/portabled-bus.c index 0fa05434ef..0169dcb463 100644 --- a/src/portable/portabled-bus.c +++ b/src/portable/portabled-bus.c @@ -135,7 +135,6 @@ static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_er _cleanup_hashmap_free_ Hashmap *images = NULL; Manager *m = userdata; Image *image; - Iterator i; int r; assert(message); @@ -157,7 +156,7 @@ static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_er if (r < 0) return r; - HASHMAP_FOREACH(image, images, i) { + HASHMAP_FOREACH(image, images) { _cleanup_(sd_bus_error_free) sd_bus_error error_state = SD_BUS_ERROR_NULL; PortableState state = _PORTABLE_STATE_INVALID; _cleanup_free_ char *p = NULL; diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c index 9646601491..b9914f5940 100644 --- a/src/portable/portabled-image-bus.c +++ b/src/portable/portabled-image-bus.c @@ -704,7 +704,6 @@ int bus_image_node_enumerator(sd_bus *bus, const char *path, void *userdata, cha size_t n_allocated = 0, n = 0; Manager *m = userdata; Image *image; - Iterator i; int r; assert(bus); @@ -719,7 +718,7 @@ int bus_image_node_enumerator(sd_bus *bus, const char *path, void *userdata, cha if (r < 0) return r; - HASHMAP_FOREACH(image, images, i) { + HASHMAP_FOREACH(image, images) { char *p; r = bus_image_path(image, &p); diff --git a/src/portable/portabled-image.c b/src/portable/portabled-image.c index d95845b32a..e498ba318e 100644 --- a/src/portable/portabled-image.c +++ b/src/portable/portabled-image.c @@ -85,7 +85,6 @@ int manager_image_cache_add(Manager *m, Image *image) { int manager_image_cache_discover(Manager *m, Hashmap *images, sd_bus_error *error) { Image *image; - Iterator i; int r; assert(m); @@ -97,7 +96,7 @@ int manager_image_cache_discover(Manager *m, Hashmap *images, sd_bus_error *erro if (r < 0) return r; - HASHMAP_FOREACH(image, images, i) + HASHMAP_FOREACH(image, images) (void) manager_image_cache_add(m, image); return 0; diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c index 97cc125232..ca01e5f50b 100644 --- a/src/resolve/resolved-bus.c +++ b/src/resolve/resolved-bus.c @@ -1324,7 +1324,6 @@ static int bus_property_get_dns_servers_internal( Manager *m = userdata; DnsServer *s; - Iterator i; Link *l; int r; @@ -1341,7 +1340,7 @@ static int bus_property_get_dns_servers_internal( return r; } - HASHMAP_FOREACH(l, m->links, i) + HASHMAP_FOREACH(l, m->links) LIST_FOREACH(servers, s, l->dns_servers) { r = bus_dns_server_append(reply, s, true, extended); if (r < 0) @@ -1477,7 +1476,6 @@ static int bus_property_get_domains( Manager *m = userdata; DnsSearchDomain *d; - Iterator i; Link *l; int r; @@ -1494,7 +1492,7 @@ static int bus_property_get_domains( return r; } - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { LIST_FOREACH(domains, d, l->search_domains) { r = sd_bus_message_append(reply, "(isb)", l->ifindex, d->name, d->route_only); if (r < 0) @@ -1581,7 +1579,6 @@ static int bus_property_get_ntas( Manager *m = userdata; const char *domain; - Iterator i; int r; assert(reply); @@ -1591,7 +1588,7 @@ static int bus_property_get_ntas( if (r < 0) return r; - SET_FOREACH(domain, m->trust_anchor.negative_by_name, i) { + SET_FOREACH(domain, m->trust_anchor.negative_by_name) { r = sd_bus_message_append(reply, "s", domain); if (r < 0) return r; diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c index 946889a834..683f113751 100644 --- a/src/resolve/resolved-dns-cache.c +++ b/src/resolve/resolved-dns-cache.c @@ -1015,14 +1015,13 @@ int dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_ int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p) { unsigned ancount = 0; - Iterator iterator; DnsCacheItem *i; int r; assert(cache); assert(p); - HASHMAP_FOREACH(i, cache->by_key, iterator) { + HASHMAP_FOREACH(i, cache->by_key) { DnsCacheItem *j; LIST_FOREACH(by_key, j, i) { @@ -1063,7 +1062,6 @@ int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p) { } void dns_cache_dump(DnsCache *cache, FILE *f) { - Iterator iterator; DnsCacheItem *i; if (!cache) @@ -1072,7 +1070,7 @@ void dns_cache_dump(DnsCache *cache, FILE *f) { if (!f) f = stdout; - HASHMAP_FOREACH(i, cache->by_key, iterator) { + HASHMAP_FOREACH(i, cache->by_key) { DnsCacheItem *j; LIST_FOREACH(by_key, j, i) { diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c index 63ede72473..75c8bf315e 100644 --- a/src/resolve/resolved-dns-packet.c +++ b/src/resolve/resolved-dns-packet.c @@ -354,7 +354,6 @@ static int dns_packet_extend(DnsPacket *p, size_t add, void **ret, size_t *start } void dns_packet_truncate(DnsPacket *p, size_t sz) { - Iterator i; char *s; void *n; @@ -363,7 +362,7 @@ void dns_packet_truncate(DnsPacket *p, size_t sz) { if (p->size <= sz) return; - HASHMAP_FOREACH_KEY(n, s, p->names, i) { + HASHMAP_FOREACH_KEY(n, s, p->names) { if (PTR_TO_SIZE(n) < sz) continue; @@ -646,7 +645,6 @@ fail: } static int dns_packet_append_types(DnsPacket *p, Bitmap *types, size_t *start) { - Iterator i; uint8_t window = 0; uint8_t entry = 0; uint8_t bitmaps[32] = {}; @@ -658,7 +656,7 @@ static int dns_packet_append_types(DnsPacket *p, Bitmap *types, size_t *start) { saved_size = p->size; - BITMAP_FOREACH(n, types, i) { + BITMAP_FOREACH(n, types) { assert(n <= 0xffff); if ((n >> 8) != window && bitmaps[entry / 8] != 0) { diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c index 894b98834d..3afe4cf73b 100644 --- a/src/resolve/resolved-dns-query.c +++ b/src/resolve/resolved-dns-query.c @@ -129,14 +129,13 @@ static int dns_query_candidate_add_transaction(DnsQueryCandidate *c, DnsResource static int dns_query_candidate_go(DnsQueryCandidate *c) { DnsTransaction *t; - Iterator i; int r; unsigned n = 0; assert(c); /* Start the transactions that are not started yet */ - SET_FOREACH(t, c->transactions, i) { + SET_FOREACH(t, c->transactions) { if (t->state != DNS_TRANSACTION_NULL) continue; @@ -157,14 +156,13 @@ static int dns_query_candidate_go(DnsQueryCandidate *c) { static DnsTransactionState dns_query_candidate_state(DnsQueryCandidate *c) { DnsTransactionState state = DNS_TRANSACTION_NO_SERVERS; DnsTransaction *t; - Iterator i; assert(c); if (c->error_code != 0) return DNS_TRANSACTION_ERRNO; - SET_FOREACH(t, c->transactions, i) { + SET_FOREACH(t, c->transactions) { switch (t->state) { @@ -729,7 +727,6 @@ static void dns_query_accept(DnsQuery *q, DnsQueryCandidate *c) { bool has_authenticated = false, has_non_authenticated = false; DnssecResult dnssec_result_authenticated = _DNSSEC_RESULT_INVALID, dnssec_result_non_authenticated = _DNSSEC_RESULT_INVALID; DnsTransaction *t; - Iterator i; int r; assert(q); @@ -753,7 +750,7 @@ static void dns_query_accept(DnsQuery *q, DnsQueryCandidate *c) { q->answer_errno = c->error_code; } - SET_FOREACH(t, c->transactions, i) { + SET_FOREACH(t, c->transactions) { switch (t->state) { diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index fa43dd089d..63ed9ebf10 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -750,11 +750,10 @@ static int format_timestamp_dns(char *buf, size_t l, time_t sec) { static char *format_types(Bitmap *types) { _cleanup_strv_free_ char **strv = NULL; _cleanup_free_ char *str = NULL; - Iterator i; unsigned type; int r; - BITMAP_FOREACH(type, types, i) { + BITMAP_FOREACH(type, types) { if (dns_type_to_string(type)) { r = strv_extend(&strv, dns_type_to_string(type)); if (r < 0) diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index abf7b9122d..e69ba3c758 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -1218,7 +1218,6 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) { DnsTransaction *t; DnsZoneItem *z, *i; unsigned size = 0; - Iterator iterator; char *service_type; int r; @@ -1238,7 +1237,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) { return 0; /* we reach this point only if changing hostname didn't help */ /* Calculate answer's size. */ - HASHMAP_FOREACH(z, scope->zone.by_key, iterator) { + HASHMAP_FOREACH(z, scope->zone.by_key) { if (z->state != DNS_ZONE_ITEM_ESTABLISHED) continue; @@ -1270,7 +1269,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) { return log_oom(); /* Second iteration, actually add RRs to the answer. */ - HASHMAP_FOREACH(z, scope->zone.by_key, iterator) + HASHMAP_FOREACH(z, scope->zone.by_key) LIST_FOREACH (by_key, i, z) { DnsAnswerFlags flags; @@ -1288,7 +1287,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) { } /* Since all the active services are in the zone make them discoverable now. */ - SET_FOREACH(service_type, types, iterator) { + SET_FOREACH(service_type, types) { _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr; rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_PTR, @@ -1338,7 +1337,6 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) { } int dns_scope_add_dnssd_services(DnsScope *scope) { - Iterator i; DnssdService *service; DnssdTxtData *txt_data; int r; @@ -1350,7 +1348,7 @@ int dns_scope_add_dnssd_services(DnsScope *scope) { scope->announced = false; - HASHMAP_FOREACH(service, scope->manager->dnssd_services, i) { + HASHMAP_FOREACH(service, scope->manager->dnssd_services) { service->withdrawn = false; r = dns_zone_put(&scope->zone, scope, service->ptr_rr, false); @@ -1373,7 +1371,6 @@ int dns_scope_add_dnssd_services(DnsScope *scope) { int dns_scope_remove_dnssd_services(DnsScope *scope) { _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL; - Iterator i; DnssdService *service; DnssdTxtData *txt_data; int r; @@ -1389,7 +1386,7 @@ int dns_scope_remove_dnssd_services(DnsScope *scope) { if (r < 0) return r; - HASHMAP_FOREACH(service, scope->manager->dnssd_services, i) { + HASHMAP_FOREACH(service, scope->manager->dnssd_services) { dns_zone_remove_rr(&scope->zone, service->ptr_rr); dns_zone_remove_rr(&scope->zone, service->srv_rr); LIST_FOREACH(items, txt_data, service->txt_data_items) diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c index 9c221e1989..a5b89128c7 100644 --- a/src/resolve/resolved-dns-server.c +++ b/src/resolve/resolved-dns-server.c @@ -753,13 +753,12 @@ DnsServer *manager_get_dns_server(Manager *m) { if (!m->current_dns_server) { bool found = false; - Iterator i; /* No DNS servers configured, let's see if there are * any on any links. If not, we use the fallback * servers */ - HASHMAP_FOREACH(l, m->links, i) + HASHMAP_FOREACH(l, m->links) if (l->dns_servers) { found = true; break; diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c index 12f69aef38..a814de6a1f 100644 --- a/src/resolve/resolved-dns-stream.c +++ b/src/resolve/resolved-dns-stream.c @@ -455,7 +455,6 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use static DnsStream *dns_stream_free(DnsStream *s) { DnsPacket *p; - Iterator i; assert(s); @@ -471,7 +470,7 @@ static DnsStream *dns_stream_free(DnsStream *s) { dnstls_stream_free(s); #endif - ORDERED_SET_FOREACH(p, s->write_queue, i) + ORDERED_SET_FOREACH(p, s->write_queue) dns_packet_unref(ordered_set_remove(s->write_queue, p)); dns_packet_unref(s->write_packet); diff --git a/src/resolve/resolved-dns-stub.c b/src/resolve/resolved-dns-stub.c index 132bac8153..b09cbcff64 100644 --- a/src/resolve/resolved-dns-stub.c +++ b/src/resolve/resolved-dns-stub.c @@ -774,11 +774,10 @@ int manager_dns_stub_start(Manager *m) { if (!ordered_set_isempty(m->dns_extra_stub_listeners)) { DNSStubListenerExtra *l; - Iterator i; log_debug("Creating extra stub listeners."); - ORDERED_SET_FOREACH(l, m->dns_extra_stub_listeners, i) { + ORDERED_SET_FOREACH(l, m->dns_extra_stub_listeners) { if (FLAGS_SET(l->mode, DNS_STUB_LISTENER_UDP)) (void) manager_dns_stub_udp_fd_extra(m, l); if (FLAGS_SET(l->mode, DNS_STUB_LISTENER_TCP)) diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index cc833f72b9..36f57eae62 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -702,11 +702,10 @@ static void dns_transaction_cache_answer(DnsTransaction *t) { static bool dns_transaction_dnssec_is_live(DnsTransaction *t) { DnsTransaction *dt; - Iterator i; assert(t); - SET_FOREACH(dt, t->dnssec_transactions, i) + SET_FOREACH(dt, t->dnssec_transactions) if (DNS_TRANSACTION_IS_LIVE(dt->state)) return true; @@ -715,14 +714,13 @@ static bool dns_transaction_dnssec_is_live(DnsTransaction *t) { static int dns_transaction_dnssec_ready(DnsTransaction *t) { DnsTransaction *dt; - Iterator i; assert(t); /* Checks whether the auxiliary DNSSEC transactions of our transaction have completed, or are still * ongoing. Returns 0, if we aren't ready for the DNSSEC validation, positive if we are. */ - SET_FOREACH(dt, t->dnssec_transactions, i) { + SET_FOREACH(dt, t->dnssec_transactions) { switch (dt->state) { @@ -1476,7 +1474,6 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) { _cleanup_(dns_packet_unrefp) DnsPacket *p = NULL; bool add_known_answers = false; DnsTransaction *other; - Iterator i; DnsResourceKey *tkey; _cleanup_set_free_ Set *keys = NULL; unsigned qdcount; @@ -1585,7 +1582,7 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) { return r; } - SET_FOREACH(tkey, keys, i) { + SET_FOREACH(tkey, keys) { _cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL; bool tentative; @@ -1774,7 +1771,6 @@ int dns_transaction_go(DnsTransaction *t) { static int dns_transaction_find_cyclic(DnsTransaction *t, DnsTransaction *aux) { DnsTransaction *n; - Iterator i; int r; assert(t); @@ -1785,7 +1781,7 @@ static int dns_transaction_find_cyclic(DnsTransaction *t, DnsTransaction *aux) { if (t == aux) return 1; - SET_FOREACH(n, aux->dnssec_transactions, i) { + SET_FOREACH(n, aux->dnssec_transactions) { r = dns_transaction_find_cyclic(t, n); if (r != 0) return r; @@ -1977,7 +1973,6 @@ static bool dns_transaction_dnssec_supported(DnsTransaction *t) { static bool dns_transaction_dnssec_supported_full(DnsTransaction *t) { DnsTransaction *dt; - Iterator i; assert(t); @@ -1986,7 +1981,7 @@ static bool dns_transaction_dnssec_supported_full(DnsTransaction *t) { if (!dns_transaction_dnssec_supported(t)) return false; - SET_FOREACH(dt, t->dnssec_transactions, i) + SET_FOREACH(dt, t->dnssec_transactions) if (!dns_transaction_dnssec_supported(dt)) return false; @@ -2380,11 +2375,10 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * case DNS_TYPE_SOA: case DNS_TYPE_NS: { DnsTransaction *dt; - Iterator i; /* For SOA or NS RRs we look for a matching DS transaction */ - SET_FOREACH(dt, t->dnssec_transactions, i) { + SET_FOREACH(dt, t->dnssec_transactions) { if (dt->key->class != rr->key->class) continue; @@ -2418,7 +2412,6 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * case DNS_TYPE_DNAME: { const char *parent = NULL; DnsTransaction *dt; - Iterator i; /* * CNAME/DNAME RRs cannot be located at a zone apex, hence look directly for the parent SOA. @@ -2426,7 +2419,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * * DS RRs are signed if the parent is signed, hence also look at the parent SOA */ - SET_FOREACH(dt, t->dnssec_transactions, i) { + SET_FOREACH(dt, t->dnssec_transactions) { if (dt->key->class != rr->key->class) continue; @@ -2462,11 +2455,10 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * default: { DnsTransaction *dt; - Iterator i; /* Any other kind of RR (including DNSKEY/NSEC/NSEC3). Let's see if our SOA lookup was authenticated */ - SET_FOREACH(dt, t->dnssec_transactions, i) { + SET_FOREACH(dt, t->dnssec_transactions) { if (dt->key->class != rr->key->class) continue; @@ -2494,7 +2486,6 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * static int dns_transaction_in_private_tld(DnsTransaction *t, const DnsResourceKey *key) { DnsTransaction *dt; const char *tld; - Iterator i; int r; /* If DNSSEC downgrade mode is on, checks whether the @@ -2530,7 +2521,7 @@ static int dns_transaction_in_private_tld(DnsTransaction *t, const DnsResourceKe if (!dns_name_is_single_label(tld)) return false; - SET_FOREACH(dt, t->dnssec_transactions, i) { + SET_FOREACH(dt, t->dnssec_transactions) { if (dt->key->class != key->class) continue; @@ -2556,7 +2547,6 @@ static int dns_transaction_requires_nsec(DnsTransaction *t) { DnsTransaction *dt; const char *name; uint16_t type = 0; - Iterator i; int r; assert(t); @@ -2614,7 +2604,7 @@ static int dns_transaction_requires_nsec(DnsTransaction *t) { /* For all other RRs we check the SOA on the same level to see * if it's signed. */ - SET_FOREACH(dt, t->dnssec_transactions, i) { + SET_FOREACH(dt, t->dnssec_transactions) { if (dt->key->class != t->key->class) continue; @@ -2651,7 +2641,6 @@ static int dns_transaction_dnskey_authenticated(DnsTransaction *t, DnsResourceRe DNS_ANSWER_FOREACH(rrsig, t->answer) { DnsTransaction *dt; - Iterator i; r = dnssec_key_match_rrsig(rr->key, rrsig); if (r < 0) @@ -2659,7 +2648,7 @@ static int dns_transaction_dnskey_authenticated(DnsTransaction *t, DnsResourceRe if (r == 0) continue; - SET_FOREACH(dt, t->dnssec_transactions, i) { + SET_FOREACH(dt, t->dnssec_transactions) { if (dt->key->class != rr->key->class) continue; @@ -2771,14 +2760,13 @@ static int dns_transaction_invalidate_revoked_keys(DnsTransaction *t) { static int dns_transaction_copy_validated(DnsTransaction *t) { DnsTransaction *dt; - Iterator i; int r; assert(t); /* Copy all validated RRs from the auxiliary DNSSEC transactions into our set of validated RRs */ - SET_FOREACH(dt, t->dnssec_transactions, i) { + SET_FOREACH(dt, t->dnssec_transactions) { if (DNS_TRANSACTION_IS_LIVE(dt->state)) continue; diff --git a/src/resolve/resolved-dns-trust-anchor.c b/src/resolve/resolved-dns-trust-anchor.c index d68d0c3ba1..ad5061c2bd 100644 --- a/src/resolve/resolved-dns-trust-anchor.c +++ b/src/resolve/resolved-dns-trust-anchor.c @@ -464,7 +464,6 @@ static int domain_name_cmp(char * const *a, char * const *b) { static int dns_trust_anchor_dump(DnsTrustAnchor *d) { DnsAnswer *a; - Iterator i; assert(d); @@ -472,7 +471,7 @@ static int dns_trust_anchor_dump(DnsTrustAnchor *d) { log_info("No positive trust anchors defined."); else { log_info("Positive Trust Anchors:"); - HASHMAP_FOREACH(a, d->positive_by_key, i) { + HASHMAP_FOREACH(a, d->positive_by_key) { DnsResourceRecord *rr; DNS_ANSWER_FOREACH(rr, a) diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c index 33879d6142..f8e1491f8b 100644 --- a/src/resolve/resolved-dns-zone.c +++ b/src/resolve/resolved-dns-zone.c @@ -630,11 +630,10 @@ int dns_zone_verify_conflicts(DnsZone *zone, DnsResourceKey *key) { void dns_zone_verify_all(DnsZone *zone) { DnsZoneItem *i; - Iterator iterator; assert(zone); - HASHMAP_FOREACH(i, zone->by_key, iterator) { + HASHMAP_FOREACH(i, zone->by_key) { DnsZoneItem *j; LIST_FOREACH(by_key, j, i) @@ -643,7 +642,6 @@ void dns_zone_verify_all(DnsZone *zone) { } void dns_zone_dump(DnsZone *zone, FILE *f) { - Iterator iterator; DnsZoneItem *i; if (!zone) @@ -652,7 +650,7 @@ void dns_zone_dump(DnsZone *zone, FILE *f) { if (!f) f = stdout; - HASHMAP_FOREACH(i, zone->by_key, iterator) { + HASHMAP_FOREACH(i, zone->by_key) { DnsZoneItem *j; LIST_FOREACH(by_key, j, i) { diff --git a/src/resolve/resolved-dnssd-bus.c b/src/resolve/resolved-dnssd-bus.c index 33efb8ef06..7798746e67 100644 --- a/src/resolve/resolved-dnssd-bus.c +++ b/src/resolve/resolved-dnssd-bus.c @@ -14,7 +14,6 @@ int bus_dnssd_method_unregister(sd_bus_message *message, void *userdata, sd_bus_ DnssdService *s = userdata; DnssdTxtData *txt_data; Manager *m; - Iterator i; Link *l; int r; @@ -32,7 +31,7 @@ int bus_dnssd_method_unregister(sd_bus_message *message, void *userdata, sd_bus_ if (r == 0) return 1; /* Polkit will call us back */ - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { if (l->mdns_ipv4_scope) { r = dns_scope_announce(l->mdns_ipv4_scope, true); if (r < 0) @@ -91,7 +90,6 @@ static int dnssd_node_enumerator(sd_bus *bus, const char *path, void *userdata, _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; DnssdService *service; - Iterator i; unsigned c = 0; int r; @@ -104,7 +102,7 @@ static int dnssd_node_enumerator(sd_bus *bus, const char *path, void *userdata, if (!l) return -ENOMEM; - HASHMAP_FOREACH(service, m->dnssd_services, i) { + HASHMAP_FOREACH(service, m->dnssd_services) { char *p; r = sd_bus_path_encode("/org/freedesktop/resolve1/dnssd", service->name, &p); diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c index 4458ad1d2d..7d482ac5da 100644 --- a/src/resolve/resolved-dnssd.c +++ b/src/resolve/resolved-dnssd.c @@ -333,11 +333,10 @@ int dnssd_txt_item_new_from_data(const char *key, const void *data, const size_t } void dnssd_signal_conflict(Manager *manager, const char *name) { - Iterator i; DnssdService *s; int r; - HASHMAP_FOREACH(s, manager->dnssd_services, i) { + HASHMAP_FOREACH(s, manager->dnssd_services) { if (s->withdrawn) continue; diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c index 42d4ae7aaf..3665d69f3c 100644 --- a/src/resolve/resolved-link-bus.c +++ b/src/resolve/resolved-link-bus.c @@ -222,7 +222,6 @@ static int property_get_ntas( Link *l = userdata; const char *name; - Iterator i; int r; assert(reply); @@ -232,7 +231,7 @@ static int property_get_ntas( if (r < 0) return r; - SET_FOREACH(name, l->dnssec_negative_trust_anchors, i) { + SET_FOREACH(name, l->dnssec_negative_trust_anchors) { r = sd_bus_message_append(reply, "s", name); if (r < 0) return r; @@ -746,7 +745,6 @@ static int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, c _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; Link *link; - Iterator i; unsigned c = 0; assert(bus); @@ -758,7 +756,7 @@ static int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, c if (!l) return -ENOMEM; - HASHMAP_FOREACH(link, m->links, i) { + HASHMAP_FOREACH(link, m->links) { char *p; p = link_bus_path(link); diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c index f52c556bd1..79d84dde1f 100644 --- a/src/resolve/resolved-link.c +++ b/src/resolve/resolved-link.c @@ -1250,11 +1250,10 @@ int link_save_user(Link *l) { if (!set_isempty(l->dnssec_negative_trust_anchors)) { bool space = false; - Iterator i; char *nta; fputs("NTAS=", f); - SET_FOREACH(nta, l->dnssec_negative_trust_anchors, i) { + SET_FOREACH(nta, l->dnssec_negative_trust_anchors) { if (space) fputc(' ', f); diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index ddd336b489..3e63f90dda 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -268,7 +268,6 @@ static int manager_rtnl_listen(Manager *m) { static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) { Manager *m = userdata; - Iterator i; Link *l; int r; @@ -276,7 +275,7 @@ static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void * sd_network_monitor_flush(m->network_monitor); - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { r = link_update(l); if (r < 0) log_warning_errno(r, "Failed to update monitor information for %i: %m", l->ifindex); @@ -509,7 +508,6 @@ static int manager_sigusr1(sd_event_source *s, const struct signalfd_siginfo *si DnsServer *server; size_t size = 0; DnsScope *scope; - Iterator i; Link *l; assert(s); @@ -527,7 +525,7 @@ static int manager_sigusr1(sd_event_source *s, const struct signalfd_siginfo *si dns_server_dump(server, f); LIST_FOREACH(servers, server, m->fallback_dns_servers) dns_server_dump(server, f); - HASHMAP_FOREACH(l, m->links, i) + HASHMAP_FOREACH(l, m->links) LIST_FOREACH(servers, server, l->dns_servers) dns_server_dump(server, f); @@ -1066,13 +1064,12 @@ int manager_send( uint32_t manager_find_mtu(Manager *m) { uint32_t mtu = 0; Link *l; - Iterator i; /* If we don't know on which link a DNS packet would be * delivered, let's find the largest MTU that works on all * interfaces we know of */ - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { if (l->mtu <= 0) continue; @@ -1096,7 +1093,6 @@ int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_a } void manager_refresh_rrs(Manager *m) { - Iterator i; Link *l; DnssdService *s; @@ -1108,11 +1104,11 @@ void manager_refresh_rrs(Manager *m) { m->mdns_host_ipv6_key = dns_resource_key_unref(m->mdns_host_ipv6_key); if (m->mdns_support == RESOLVE_SUPPORT_YES) - HASHMAP_FOREACH(s, m->dnssd_services, i) + HASHMAP_FOREACH(s, m->dnssd_services) if (dnssd_update_rrs(s) < 0) log_warning("Failed to refresh DNS-SD service '%s'", s->name); - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { link_add_rrs(l, true); link_add_rrs(l, false); } @@ -1180,12 +1176,11 @@ int manager_next_hostname(Manager *m) { } LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr) { - Iterator i; Link *l; assert(m); - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { LinkAddress *a; a = link_find_address(l, family, in_addr); @@ -1272,7 +1267,6 @@ int manager_is_own_hostname(Manager *m, const char *name) { int manager_compile_dns_servers(Manager *m, OrderedSet **dns) { DnsServer *s; - Iterator i; Link *l; int r; @@ -1293,7 +1287,7 @@ int manager_compile_dns_servers(Manager *m, OrderedSet **dns) { } /* Then, add the per-link servers */ - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { LIST_FOREACH(servers, s, l->dns_servers) { r = ordered_set_put(*dns, s); if (r == -EEXIST) @@ -1324,7 +1318,6 @@ int manager_compile_dns_servers(Manager *m, OrderedSet **dns) { */ int manager_compile_search_domains(Manager *m, OrderedSet **domains, int filter_route) { DnsSearchDomain *d; - Iterator i; Link *l; int r; @@ -1348,7 +1341,7 @@ int manager_compile_search_domains(Manager *m, OrderedSet **domains, int filter_ return r; } - HASHMAP_FOREACH(l, m->links, i) { + HASHMAP_FOREACH(l, m->links) { LIST_FOREACH(domains, d, l->search_domains) { @@ -1378,7 +1371,6 @@ DnssecMode manager_get_dnssec_mode(Manager *m) { bool manager_dnssec_supported(Manager *m) { DnsServer *server; - Iterator i; Link *l; assert(m); @@ -1390,7 +1382,7 @@ bool manager_dnssec_supported(Manager *m) { if (server && !dns_server_dnssec_supported(server)) return false; - HASHMAP_FOREACH(l, m->links, i) + HASHMAP_FOREACH(l, m->links) if (!link_dnssec_supported(l)) return false; @@ -1423,14 +1415,13 @@ void manager_dnssec_verdict(Manager *m, DnssecVerdict verdict, const DnsResource } bool manager_routable(Manager *m, int family) { - Iterator i; Link *l; assert(m); /* Returns true if the host has at least one interface with a routable address of the specified type */ - HASHMAP_FOREACH(l, m->links, i) + HASHMAP_FOREACH(l, m->links) if (link_relevant(l, family, false)) return true; @@ -1449,13 +1440,12 @@ void manager_flush_caches(Manager *m) { } void manager_reset_server_features(Manager *m) { - Iterator i; Link *l; dns_server_reset_features_all(m->dns_servers); dns_server_reset_features_all(m->fallback_dns_servers); - HASHMAP_FOREACH(l, m->links, i) + HASHMAP_FOREACH(l, m->links) dns_server_reset_features_all(l->dns_servers); log_info("Resetting learnt feature levels on all servers."); @@ -1516,14 +1506,13 @@ void manager_cleanup_saved_user(Manager *m) { } bool manager_next_dnssd_names(Manager *m) { - Iterator i; DnssdService *s; bool tried = false; int r; assert(m); - HASHMAP_FOREACH(s, m->dnssd_services, i) { + HASHMAP_FOREACH(s, m->dnssd_services) { _cleanup_free_ char * new_name = NULL; if (!s->withdrawn) diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c index befd8d7949..0de5046367 100644 --- a/src/resolve/resolved-resolv-conf.c +++ b/src/resolve/resolved-resolv-conf.c @@ -231,7 +231,6 @@ static void write_resolv_conf_server(DnsServer *s, FILE *f, unsigned *count) { static void write_resolv_conf_search( OrderedSet *domains, FILE *f) { - Iterator i; char *domain; assert(domains); @@ -239,7 +238,7 @@ static void write_resolv_conf_search( fputs("search", f); - ORDERED_SET_FOREACH(domain, domains, i) { + ORDERED_SET_FOREACH(domain, domains) { fputc(' ', f); fputs(domain, f); } @@ -248,7 +247,6 @@ static void write_resolv_conf_search( } static int write_uplink_resolv_conf_contents(FILE *f, OrderedSet *dns, OrderedSet *domains) { - Iterator i; fputs("# This file is managed by man:systemd-resolved(8). Do not edit.\n" "#\n" @@ -269,7 +267,7 @@ static int write_uplink_resolv_conf_contents(FILE *f, OrderedSet *dns, OrderedSe unsigned count = 0; DnsServer *s; - ORDERED_SET_FOREACH(s, dns, i) + ORDERED_SET_FOREACH(s, dns) write_resolv_conf_server(s, f, &count); } diff --git a/src/shared/bitmap.h b/src/shared/bitmap.h index f65a050584..312cee9ce7 100644 --- a/src/shared/bitmap.h +++ b/src/shared/bitmap.h @@ -27,8 +27,10 @@ bool bitmap_iterate(const Bitmap *b, Iterator *i, unsigned *n); bool bitmap_equal(const Bitmap *a, const Bitmap *b); -#define BITMAP_FOREACH(n, b, i) \ - for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); ) +#define _BITMAP_FOREACH(n, b, i) \ + for (Iterator i = {}; bitmap_iterate((b), &i, (unsigned*)&(n)); ) +#define BITMAP_FOREACH(n, b) \ + _BITMAP_FOREACH(n, b, UNIQ_T(i, UNIQ)) DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free); diff --git a/src/shared/bus-unit-procs.c b/src/shared/bus-unit-procs.c index b21fe39326..5ae54efb19 100644 --- a/src/shared/bus-unit-procs.c +++ b/src/shared/bus-unit-procs.c @@ -158,13 +158,12 @@ static int dump_processes( size_t n = 0, i; pid_t *pids; void *pidp; - Iterator j; int width; /* Order processes by their PID */ pids = newa(pid_t, hashmap_size(cg->pids)); - HASHMAP_FOREACH_KEY(name, pidp, cg->pids, j) + HASHMAP_FOREACH_KEY(name, pidp, cg->pids) pids[n++] = PTR_TO_PID(pidp); assert(n == hashmap_size(cg->pids)); @@ -261,16 +260,14 @@ static int dump_extra_processes( _cleanup_hashmap_free_ Hashmap *names = NULL; struct CGroupInfo *cg; size_t n_allocated = 0, n = 0, k; - Iterator i; int width, r; /* Prints the extra processes, i.e. those that are in cgroups we haven't displayed yet. We show them as * combined, sorted, linear list. */ - HASHMAP_FOREACH(cg, cgroups, i) { + HASHMAP_FOREACH(cg, cgroups) { const char *name; void *pidp; - Iterator j; if (cg->done) continue; @@ -285,7 +282,7 @@ static int dump_extra_processes( if (!GREEDY_REALLOC(pids, n_allocated, n + hashmap_size(cg->pids))) return -ENOMEM; - HASHMAP_FOREACH_KEY(name, pidp, cg->pids, j) { + HASHMAP_FOREACH_KEY(name, pidp, cg->pids) { pids[n++] = PTR_TO_PID(pidp); r = hashmap_put(names, pidp, (void*) name); diff --git a/src/shared/dropin.c b/src/shared/dropin.c index 932da0c853..6c614b5c0a 100644 --- a/src/shared/dropin.c +++ b/src/shared/dropin.c @@ -233,7 +233,6 @@ int unit_file_find_dropin_paths( _cleanup_strv_free_ char **dirs = NULL; const char *n; char **p; - Iterator i; int r; assert(ret); @@ -242,7 +241,7 @@ int unit_file_find_dropin_paths( STRV_FOREACH(p, lookup_path) (void) unit_file_find_dirs(original_root, unit_path_cache, *p, name, dir_suffix, &dirs); - SET_FOREACH(n, aliases, i) + SET_FOREACH(n, aliases) STRV_FOREACH(p, lookup_path) (void) unit_file_find_dirs(original_root, unit_path_cache, *p, n, dir_suffix, &dirs); diff --git a/src/shared/fdset.c b/src/shared/fdset.c index 89d118a3aa..dfe8242fc4 100644 --- a/src/shared/fdset.c +++ b/src/shared/fdset.c @@ -161,13 +161,12 @@ finish: } int fdset_cloexec(FDSet *fds, bool b) { - Iterator i; void *p; int r; assert(fds); - SET_FOREACH(p, MAKE_SET(fds), i) { + SET_FOREACH(p, MAKE_SET(fds)) { r = fd_cloexec(PTR_TO_FD(p), b); if (r < 0) return r; @@ -209,7 +208,6 @@ fail: int fdset_close_others(FDSet *fds) { void *e; - Iterator i; int *a = NULL; size_t j = 0, m; @@ -217,7 +215,7 @@ int fdset_close_others(FDSet *fds) { if (m > 0) { a = newa(int, m); - SET_FOREACH(e, MAKE_SET(fds), i) + SET_FOREACH(e, MAKE_SET(fds)) a[j++] = PTR_TO_FD(e); } diff --git a/src/shared/fdset.h b/src/shared/fdset.h index bdf1377038..ceabb82311 100644 --- a/src/shared/fdset.h +++ b/src/shared/fdset.h @@ -35,8 +35,10 @@ int fdset_steal_first(FDSet *fds); void fdset_close(FDSet *fds); -#define FDSET_FOREACH(fd, fds, i) \ - for ((i) = ITERATOR_FIRST, (fd) = fdset_iterate((fds), &(i)); (fd) >= 0; (fd) = fdset_iterate((fds), &(i))) +#define _FDSET_FOREACH(fd, fds, i) \ + for (Iterator i = ITERATOR_FIRST; ((fd) = fdset_iterate((fds), &i)) >= 0; ) +#define FDSET_FOREACH(fd, fds) \ + _FDSET_FOREACH(fd, fds, UNIQ_T(i, UNIQ)) DEFINE_TRIVIAL_CLEANUP_FUNC(FDSet*, fdset_free); #define _cleanup_fdset_free_ _cleanup_(fdset_freep) diff --git a/src/shared/journal-util.c b/src/shared/journal-util.c index cb3762df43..4d0edbb7d0 100644 --- a/src/shared/journal-util.c +++ b/src/shared/journal-util.c @@ -85,7 +85,6 @@ int journal_access_blocked(sd_journal *j) { } int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_users) { - Iterator it; void *code; char *path; int r = 0; @@ -107,7 +106,7 @@ int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_use r = log_error_errno(EACCES, "No journal files were opened due to insufficient permissions."); } - HASHMAP_FOREACH_KEY(path, code, j->errors, it) { + HASHMAP_FOREACH_KEY(path, code, j->errors) { int err; err = abs(PTR_TO_INT(code)); diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 979c9b3f29..4f25c643d2 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -1000,7 +1000,6 @@ static int output_json( sd_id128_t boot_id; Hashmap *h = NULL; size_t n = 0; - Iterator i; int r; assert(j); @@ -1070,7 +1069,7 @@ static int output_json( goto finish; } - HASHMAP_FOREACH(d, h, i) { + HASHMAP_FOREACH(d, h) { assert(d->n_values > 0); array[n++] = json_variant_ref(d->name); @@ -1190,7 +1189,6 @@ static int output_cat( int r, prio = LOG_INFO; const char *field; - Iterator iterator; assert(j); assert(f); @@ -1224,7 +1222,7 @@ static int output_cat( if (set_isempty(output_fields)) return output_cat_field(f, j, flags, prio, "MESSAGE", highlight); - SET_FOREACH(field, output_fields, iterator) { + SET_FOREACH(field, output_fields) { r = output_cat_field(f, j, flags, prio, field, streq(field, "MESSAGE") ? highlight : NULL); if (r < 0) return r; diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c index 581ca86423..10f78d6c2c 100644 --- a/src/shared/seccomp-util.c +++ b/src/shared/seccomp-util.c @@ -1058,7 +1058,6 @@ int seccomp_load_syscall_filter_set_raw(uint32_t default_action, Hashmap* set, u SECCOMP_FOREACH_LOCAL_ARCH(arch) { _cleanup_(seccomp_releasep) scmp_filter_ctx seccomp = NULL; - Iterator i; void *syscall_id, *val; log_debug("Operating on architecture: %s", seccomp_arch_to_string(arch)); @@ -1067,7 +1066,7 @@ int seccomp_load_syscall_filter_set_raw(uint32_t default_action, Hashmap* set, u if (r < 0) return r; - HASHMAP_FOREACH_KEY(val, syscall_id, set, i) { + HASHMAP_FOREACH_KEY(val, syscall_id, set) { uint32_t a = action; int id = PTR_TO_INT(syscall_id) - 1; int error = PTR_TO_INT(val); @@ -1368,7 +1367,6 @@ int seccomp_restrict_address_families(Set *address_families, bool allow_list) { SECCOMP_FOREACH_LOCAL_ARCH(arch) { _cleanup_(seccomp_releasep) scmp_filter_ctx seccomp = NULL; bool supported; - Iterator i; log_debug("Operating on architecture: %s", seccomp_arch_to_string(arch)); @@ -1419,7 +1417,7 @@ int seccomp_restrict_address_families(Set *address_families, bool allow_list) { * range and then everything that is not in the set. First, we find the lowest and * highest address family in the set. */ - SET_FOREACH(afp, address_families, i) { + SET_FOREACH(afp, address_families) { int af = PTR_TO_INT(afp); if (af <= 0 || af >= af_max()) @@ -1500,7 +1498,7 @@ int seccomp_restrict_address_families(Set *address_families, bool allow_list) { /* If this is a deny list, then generate one rule for each address family that are * then combined in OR checks. */ - SET_FOREACH(af, address_families, i) { + SET_FOREACH(af, address_families) { r = seccomp_rule_add_exact( seccomp, SCMP_ACT_ERRNO(EAFNOSUPPORT), @@ -1742,7 +1740,6 @@ int seccomp_memory_deny_write_execute(void) { int seccomp_restrict_archs(Set *archs) { _cleanup_(seccomp_releasep) scmp_filter_ctx seccomp = NULL; - Iterator i; void *id; int r; @@ -1760,7 +1757,7 @@ int seccomp_restrict_archs(Set *archs) { if (!seccomp) return -ENOMEM; - SET_FOREACH(id, archs, i) { + SET_FOREACH(id, archs) { r = seccomp_arch_add(seccomp, PTR_TO_UINT32(id) - 1); if (r < 0 && r != -EEXIST) return r; diff --git a/src/shared/unit-file.c b/src/shared/unit-file.c index 0f030ae431..3b51c7c998 100644 --- a/src/shared/unit-file.c +++ b/src/shared/unit-file.c @@ -399,9 +399,8 @@ int unit_file_build_name_map( } /* Let's also put the names in the reverse db. */ - Iterator it; const char *dummy, *src; - HASHMAP_FOREACH_KEY(dummy, src, ids, it) { + HASHMAP_FOREACH_KEY(dummy, src, ids) { const char *dst; r = unit_ids_map_get(ids, src, &dst); diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 5274cd24b3..e44a0433b1 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -119,10 +119,9 @@ static int sysctl_write_or_warn(const char *key, const char *value, bool ignore_ static int apply_all(OrderedHashmap *sysctl_options) { Option *option; - Iterator i; int r = 0; - ORDERED_HASHMAP_FOREACH(option, sysctl_options, i) { + ORDERED_HASHMAP_FOREACH(option, sysctl_options) { int k; /* Ignore "negative match" options, they are there only to exclude stuff from globs. */ diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index e22efb92ac..71fd3af1a3 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -1546,7 +1546,6 @@ static int list_unit_files(int argc, char *argv[], void *userdata) { if (install_client_side()) { Hashmap *h; UnitFileList *u; - Iterator i; unsigned n_units; h = hashmap_new(&string_hash_ops); @@ -1567,7 +1566,7 @@ static int list_unit_files(int argc, char *argv[], void *userdata) { return log_oom(); } - HASHMAP_FOREACH(u, h, i) { + HASHMAP_FOREACH(u, h) { if (!output_show_unit_file(u, NULL, NULL)) continue; diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 383a62c598..cdfceb2533 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -357,7 +357,6 @@ static int write_temporary_passwd(const char *passwd_path, FILE **tmpfile, char _cleanup_fclose_ FILE *original = NULL, *passwd = NULL; _cleanup_(unlink_and_freep) char *passwd_tmp = NULL; struct passwd *pw = NULL; - Iterator iterator; Item *i; int r; @@ -406,7 +405,7 @@ static int write_temporary_passwd(const char *passwd_path, FILE **tmpfile, char return -errno; } - ORDERED_HASHMAP_FOREACH(i, todo_uids, iterator) { + ORDERED_HASHMAP_FOREACH(i, todo_uids) { struct passwd n = { .pw_name = i->name, .pw_uid = i->uid, @@ -456,7 +455,6 @@ static int write_temporary_shadow(const char *shadow_path, FILE **tmpfile, char _cleanup_fclose_ FILE *original = NULL, *shadow = NULL; _cleanup_(unlink_and_freep) char *shadow_tmp = NULL; struct spwd *sp = NULL; - Iterator iterator; long lstchg; Item *i; int r; @@ -508,7 +506,7 @@ static int write_temporary_shadow(const char *shadow_path, FILE **tmpfile, char return -errno; } - ORDERED_HASHMAP_FOREACH(i, todo_uids, iterator) { + ORDERED_HASHMAP_FOREACH(i, todo_uids) { struct spwd n = { .sp_namp = i->name, .sp_pwdp = (char*) "!*", /* lock this password, and make it invalid */ @@ -556,7 +554,6 @@ static int write_temporary_group(const char *group_path, FILE **tmpfile, char ** _cleanup_(unlink_and_freep) char *group_tmp = NULL; bool group_changed = false; struct group *gr = NULL; - Iterator iterator; Item *i; int r; @@ -611,7 +608,7 @@ static int write_temporary_group(const char *group_path, FILE **tmpfile, char ** return -errno; } - ORDERED_HASHMAP_FOREACH(i, todo_gids, iterator) { + ORDERED_HASHMAP_FOREACH(i, todo_gids) { struct group n = { .gr_name = i->name, .gr_gid = i->gid, @@ -654,7 +651,6 @@ static int write_temporary_gshadow(const char * gshadow_path, FILE **tmpfile, ch _cleanup_fclose_ FILE *original = NULL, *gshadow = NULL; _cleanup_(unlink_and_freep) char *gshadow_tmp = NULL; bool group_changed = false; - Iterator iterator; Item *i; int r; @@ -697,7 +693,7 @@ static int write_temporary_gshadow(const char * gshadow_path, FILE **tmpfile, ch return -errno; } - ORDERED_HASHMAP_FOREACH(i, todo_gids, iterator) { + ORDERED_HASHMAP_FOREACH(i, todo_gids) { struct sgrp n = { .sg_namp = i->name, .sg_passwd = (char*) "!!", @@ -1267,11 +1263,10 @@ DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(item_hash_ops, char, string_hash_f static int add_implicit(void) { char *g, **l; - Iterator iterator; int r; /* Implicitly create additional users and groups, if they were listed in "m" lines */ - ORDERED_HASHMAP_FOREACH_KEY(l, g, members, iterator) { + ORDERED_HASHMAP_FOREACH_KEY(l, g, members) { char **m; STRV_FOREACH(m, l) @@ -1900,7 +1895,6 @@ static int run(int argc, char *argv[]) { _cleanup_(decrypted_image_unrefp) DecryptedImage *decrypted_image = NULL; _cleanup_(umount_and_rmdir_and_freep) char *unlink_dir = NULL; _cleanup_close_ int lock = -1; - Iterator iterator; Item *i; int r; @@ -1980,10 +1974,10 @@ static int run(int argc, char *argv[]) { if (r < 0) return log_error_errno(r, "Failed to read group database: %m"); - ORDERED_HASHMAP_FOREACH(i, groups, iterator) + ORDERED_HASHMAP_FOREACH(i, groups) (void) process_item(i); - ORDERED_HASHMAP_FOREACH(i, users, iterator) + ORDERED_HASHMAP_FOREACH(i, users) (void) process_item(i); r = write_files(); diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index a2c72d1009..7d6be31742 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -655,7 +655,6 @@ static int load_sysv(SysvStub *s) { static int fix_order(SysvStub *s, Hashmap *all_services) { SysvStub *other; - Iterator j; int r; assert(s); @@ -666,7 +665,7 @@ static int fix_order(SysvStub *s, Hashmap *all_services) { if (s->sysv_start_priority < 0) return 0; - HASHMAP_FOREACH(other, all_services, j) { + HASHMAP_FOREACH(other, all_services) { if (s == other) continue; @@ -817,7 +816,6 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic Set *runlevel_services[ELEMENTSOF(rcnd_table)] = {}; _cleanup_strv_free_ char **sysvrcnd_path = NULL; SysvStub *service; - Iterator j; char **p; int r; @@ -892,7 +890,7 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic } for (unsigned i = 0; i < ELEMENTSOF(rcnd_table); i++) - SET_FOREACH(service, runlevel_services[i], j) { + SET_FOREACH(service, runlevel_services[i]) { r = strv_extend(&service->before, rcnd_table[i].target); if (r < 0) { log_oom(); @@ -918,7 +916,6 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) _cleanup_(free_sysvstub_hashmapp) Hashmap *all_services = NULL; _cleanup_(lookup_paths_free) LookupPaths lp = {}; SysvStub *service; - Iterator j; int r; assert_se(arg_dest = dest_late); @@ -939,10 +936,10 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) if (r < 0) return r; - HASHMAP_FOREACH(service, all_services, j) + HASHMAP_FOREACH(service, all_services) (void) load_sysv(service); - HASHMAP_FOREACH(service, all_services, j) { + HASHMAP_FOREACH(service, all_services) { (void) fix_order(service, all_services); (void) generate_unit_file(service); } diff --git a/src/test/test-bitmap.c b/src/test/test-bitmap.c index f73d36e255..b281c1ae74 100644 --- a/src/test/test-bitmap.c +++ b/src/test/test-bitmap.c @@ -4,7 +4,6 @@ int main(int argc, const char *argv[]) { _cleanup_bitmap_free_ Bitmap *b = NULL, *b2 = NULL; - Iterator it; unsigned n = (unsigned) -1, i = 0; b = bitmap_new(); @@ -46,14 +45,14 @@ int main(int argc, const char *argv[]) { assert_se(bitmap_isset(b, 32) == true); bitmap_unset(b, 32); - BITMAP_FOREACH(n, NULL, it) + BITMAP_FOREACH(n, NULL) assert_not_reached("NULL bitmap"); assert_se(bitmap_set(b, 0) == 0); assert_se(bitmap_set(b, 1) == 0); assert_se(bitmap_set(b, 256) == 0); - BITMAP_FOREACH(n, b, it) { + BITMAP_FOREACH(n, b) { assert_se(n == i); if (i == 0) i = 1; @@ -67,7 +66,7 @@ int main(int argc, const char *argv[]) { i = 0; - BITMAP_FOREACH(n, b, it) { + BITMAP_FOREACH(n, b) { assert_se(n == i); if (i == 0) i = 1; diff --git a/src/test/test-fdset.c b/src/test/test-fdset.c index fb9d397569..212fe0dbd4 100644 --- a/src/test/test-fdset.c +++ b/src/test/test-fdset.c @@ -115,7 +115,6 @@ static void test_fdset_iterate(void) { int fd = -1; FDSet *fdset = NULL; char name[] = "/tmp/test-fdset_iterate.XXXXXX"; - Iterator i; int c = 0; int a; @@ -128,7 +127,7 @@ static void test_fdset_iterate(void) { assert_se(fdset_put(fdset, fd) >= 0); assert_se(fdset_put(fdset, fd) >= 0); - FDSET_FOREACH(a, fdset, i) { + FDSET_FOREACH(a, fdset) { c++; assert_se(a == fd); } diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c index 09fe71f205..5ff5d096a6 100644 --- a/src/test/test-hashmap-plain.c +++ b/src/test/test-hashmap-plain.c @@ -469,7 +469,6 @@ static void test_hashmap_ensure_allocated(void) { static void test_hashmap_foreach_key(void) { Hashmap *m; - Iterator i; bool key_found[] = { false, false, false, false }; const char *s; const char *key; @@ -486,7 +485,7 @@ static void test_hashmap_foreach_key(void) { NULSTR_FOREACH(key, key_table) hashmap_put(m, key, (void*) (const char*) "my dummy val"); - HASHMAP_FOREACH_KEY(s, key, m, i) { + HASHMAP_FOREACH_KEY(s, key, m) { assert(s); if (!key_found[0] && streq(key, "key 1")) key_found[0] = true; @@ -506,7 +505,6 @@ static void test_hashmap_foreach_key(void) { static void test_hashmap_foreach(void) { Hashmap *m; - Iterator i; bool value_found[] = { false, false, false, false }; char *val1, *val2, *val3, *val4, *s; unsigned count; @@ -525,14 +523,14 @@ static void test_hashmap_foreach(void) { m = NULL; count = 0; - HASHMAP_FOREACH(s, m, i) + HASHMAP_FOREACH(s, m) count++; assert_se(count == 0); m = hashmap_new(&string_hash_ops); count = 0; - HASHMAP_FOREACH(s, m, i) + HASHMAP_FOREACH(s, m) count++; assert_se(count == 0); @@ -541,7 +539,7 @@ static void test_hashmap_foreach(void) { hashmap_put(m, "Key 3", val3); hashmap_put(m, "Key 4", val4); - HASHMAP_FOREACH(s, m, i) { + HASHMAP_FOREACH(s, m) { if (!value_found[0] && streq(s, val1)) value_found[0] = true; else if (!value_found[1] && streq(s, val2)) diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c index 94dbbf1576..852712844f 100644 --- a/src/test/test-hashmap.c +++ b/src/test/test-hashmap.c @@ -54,7 +54,6 @@ static void test_string_compare_func(void) { static void compare_cache(Hashmap *map, IteratedCache *cache) { const void **keys = NULL, **values = NULL; unsigned num, idx; - Iterator iter; void *k, *v; assert_se(iterated_cache_get(cache, &keys, &values, &num) == 0); @@ -62,7 +61,7 @@ static void compare_cache(Hashmap *map, IteratedCache *cache) { assert_se(num == 0 || values); idx = 0; - HASHMAP_FOREACH_KEY(v, k, map, iter) { + HASHMAP_FOREACH_KEY(v, k, map) { assert_se(v == values[idx]); assert_se(k == keys[idx]); diff --git a/src/test/test-install-root.c b/src/test/test-install-root.c index f309160889..6fb2fd4298 100644 --- a/src/test/test-install-root.c +++ b/src/test/test-install-root.c @@ -548,7 +548,6 @@ static void test_preset_and_list(const char *root) { const char *p, *q; UnitFileState state; bool got_yes = false, got_no = false; - Iterator j; UnitFileList *fl; Hashmap *h; @@ -631,7 +630,7 @@ static void test_preset_and_list(const char *root) { p = strjoina(root, "/usr/lib/systemd/system/preset-yes.service"); q = strjoina(root, "/usr/lib/systemd/system/preset-no.service"); - HASHMAP_FOREACH(fl, h, j) { + HASHMAP_FOREACH(fl, h) { assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, basename(fl->path), &state) >= 0); assert_se(fl->state == state); diff --git a/src/test/test-install.c b/src/test/test-install.c index 62daaccd62..f1423fb635 100644 --- a/src/test/test-install.c +++ b/src/test/test-install.c @@ -22,7 +22,6 @@ static void dump_changes(UnitFileChange *c, unsigned n) { int main(int argc, char* argv[]) { Hashmap *h; UnitFileList *p; - Iterator i; int r; const char *const files[] = { "avahi-daemon.service", NULL }; const char *const files2[] = { "/home/lennart/test.service", NULL }; @@ -36,7 +35,7 @@ int main(int argc, char* argv[]) { r = unit_file_get_list(UNIT_FILE_SYSTEM, NULL, h, NULL, NULL); assert_se(r == 0); - HASHMAP_FOREACH(p, h, i) { + HASHMAP_FOREACH(p, h) { UnitFileState s = _UNIT_FILE_STATE_INVALID; r = unit_file_get_state(UNIT_FILE_SYSTEM, NULL, basename(p->path), &s); diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c index 0293d1cd0f..66925c2b6d 100644 --- a/src/test/test-load-fragment.c +++ b/src/test/test-load-fragment.c @@ -33,7 +33,6 @@ static int test_unit_file_get_set(void) { int r; Hashmap *h; - Iterator i; UnitFileList *p; h = hashmap_new(&string_hash_ops); @@ -48,7 +47,7 @@ static int test_unit_file_get_set(void) { if (r < 0) return EXIT_FAILURE; - HASHMAP_FOREACH(p, h, i) + HASHMAP_FOREACH(p, h) printf("%s = %s\n", p->path, unit_file_state_to_string(p->state)); unit_file_list_free(h); diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index 499873f0ce..30b00ae4d8 100644 --- a/src/test/test-mountpoint-util.c +++ b/src/test/test-mountpoint-util.c @@ -38,7 +38,6 @@ static void test_mount_propagation_flags(const char *name, int ret, unsigned lon static void test_mnt_id(void) { _cleanup_fclose_ FILE *f = NULL; _cleanup_hashmap_free_free_ Hashmap *h = NULL; - Iterator i; char *p; void *k; int r; @@ -72,7 +71,7 @@ static void test_mnt_id(void) { path = NULL; } - HASHMAP_FOREACH_KEY(p, k, h, i) { + HASHMAP_FOREACH_KEY(p, k, h) { int mnt_id = PTR_TO_INT(k), mnt_id2; r = path_get_mnt_id(p, &mnt_id2); diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c index 6021164739..d1f85a7f26 100644 --- a/src/test/test-unit-file.c +++ b/src/test/test-unit-file.c @@ -30,7 +30,6 @@ static void test_unit_file_build_name_map(char **ids) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; _cleanup_hashmap_free_ Hashmap *unit_ids = NULL; _cleanup_hashmap_free_ Hashmap *unit_names = NULL; - Iterator i; const char *k, *dst; char **v; usec_t mtime = 0; @@ -40,10 +39,10 @@ static void test_unit_file_build_name_map(char **ids) { assert_se(unit_file_build_name_map(&lp, &mtime, &unit_ids, &unit_names, NULL) == 1); - HASHMAP_FOREACH_KEY(dst, k, unit_ids, i) + HASHMAP_FOREACH_KEY(dst, k, unit_ids) log_info("ids: %s → %s", k, dst); - HASHMAP_FOREACH_KEY(v, k, unit_names, i) { + HASHMAP_FOREACH_KEY(v, k, unit_names) { _cleanup_free_ char *j = strv_join(v, ", "); log_info("aliases: %s ← %s", k, j); } @@ -59,7 +58,6 @@ static void test_unit_file_build_name_map(char **ids) { char **id; STRV_FOREACH(id, ids) { const char *fragment, *name; - Iterator it; _cleanup_set_free_free_ Set *names = NULL; log_info("*** %s ***", *id); r = unit_file_find_fragment(unit_ids, @@ -70,7 +68,7 @@ static void test_unit_file_build_name_map(char **ids) { assert(r == 0); log_info("fragment: %s", fragment); log_info("names:"); - SET_FOREACH(name, names, it) + SET_FOREACH(name, names) log_info(" %s", name); } } diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index aec8ddc904..5a0a5a5867 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -375,9 +375,8 @@ static bool takes_ownership(ItemType t) { static struct Item* find_glob(OrderedHashmap *h, const char *match) { ItemArray *j; - Iterator i; - ORDERED_HASHMAP_FOREACH(j, h, i) { + ORDERED_HASHMAP_FOREACH(j, h) { size_t n; for (n = 0; n < j->n_items; n++) { @@ -2372,10 +2371,9 @@ static int process_item_array(ItemArray *array, OperationMask operation) { /* Clean up all children first */ if ((operation & (OPERATION_REMOVE|OPERATION_CLEAN)) && !set_isempty(array->children)) { - Iterator i; ItemArray *c; - SET_FOREACH(c, array->children, i) { + SET_FOREACH(c, array->children) { int k; k = process_item_array(c, operation & (OPERATION_REMOVE|OPERATION_CLEAN)); @@ -3163,7 +3161,6 @@ static int parse_argv(int argc, char *argv[]) { static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoent, bool *invalid_config) { _cleanup_(hashmap_freep) Hashmap *uid_cache = NULL, *gid_cache = NULL; _cleanup_fclose_ FILE *_f = NULL; - Iterator iterator; unsigned v = 0; FILE *f; Item *i; @@ -3219,14 +3216,13 @@ static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoe } /* we have to determine age parameter for each entry of type X */ - ORDERED_HASHMAP_FOREACH(i, globs, iterator) { - Iterator iter; + ORDERED_HASHMAP_FOREACH(i, globs) { Item *j, *candidate_item = NULL; if (i->type != IGNORE_DIRECTORY_PATH) continue; - ORDERED_HASHMAP_FOREACH(j, items, iter) { + ORDERED_HASHMAP_FOREACH(j, items) { if (!IN_SET(j->type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA)) continue; @@ -3337,7 +3333,6 @@ static int run(int argc, char *argv[]) { _cleanup_(umount_and_rmdir_and_freep) char *unlink_dir = NULL; _cleanup_strv_free_ char **config_dirs = NULL; bool invalid_config = false; - Iterator iterator; ItemArray *a; enum { PHASE_REMOVE_AND_CLEAN, @@ -3431,12 +3426,12 @@ static int run(int argc, char *argv[]) { return r; /* Let's now link up all child/parent relationships */ - ORDERED_HASHMAP_FOREACH(a, items, iterator) { + ORDERED_HASHMAP_FOREACH(a, items) { r = link_parent(a); if (r < 0) return r; } - ORDERED_HASHMAP_FOREACH(a, globs, iterator) { + ORDERED_HASHMAP_FOREACH(a, globs) { r = link_parent(a); if (r < 0) return r; @@ -3458,14 +3453,14 @@ static int run(int argc, char *argv[]) { continue; /* The non-globbing ones usually create things, hence we apply them first */ - ORDERED_HASHMAP_FOREACH(a, items, iterator) { + ORDERED_HASHMAP_FOREACH(a, items) { k = process_item_array(a, op); if (k < 0 && r >= 0) r = k; } /* The globbing ones usually alter things, hence we apply them second. */ - ORDERED_HASHMAP_FOREACH(a, globs, iterator) { + ORDERED_HASHMAP_FOREACH(a, globs) { k = process_item_array(a, op); if (k < 0 && r >= 0) r = k; diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index 87779a4dd6..932f6e18b2 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -583,7 +583,6 @@ static void terminate_agents(Set *pids) { struct timespec ts; siginfo_t status = {}; sigset_t set; - Iterator i; void *p; int r, signum; @@ -591,7 +590,7 @@ static void terminate_agents(Set *pids) { * Request termination of the remaining processes as those * are not required anymore. */ - SET_FOREACH(p, pids, i) + SET_FOREACH(p, pids) (void) kill(PTR_TO_PID(p), SIGTERM); /* @@ -625,7 +624,7 @@ static void terminate_agents(Set *pids) { /* * Kill hanging processes. */ - SET_FOREACH(p, pids, i) { + SET_FOREACH(p, pids) { log_warning("Failed to terminate child %d, killing it", PTR_TO_PID(p)); (void) kill(PTR_TO_PID(p), SIGKILL); } diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index e1daac21ed..3fe4ac7e6a 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -1056,10 +1056,9 @@ int udev_event_execute_rules(UdevEvent *event, void udev_event_execute_run(UdevEvent *event, usec_t timeout_usec, int timeout_signal) { const char *command; void *val; - Iterator i; int r; - ORDERED_HASHMAP_FOREACH_KEY(val, command, event->run_list, i) { + ORDERED_HASHMAP_FOREACH_KEY(val, command, event->run_list) { UdevBuiltinCommand builtin_cmd = PTR_TO_UDEV_BUILTIN_CMD(val); if (builtin_cmd != _UDEV_BUILTIN_INVALID) { diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 31a3403093..541d48189f 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -314,7 +314,6 @@ static int node_permissions_apply(sd_device *dev, bool apply_mac, if (apply_mode || apply_uid || apply_gid || apply_mac) { bool selinux = false, smack = false; const char *name, *label; - Iterator i; if (apply_mode || apply_uid || apply_gid) { log_device_debug(dev, "Setting permissions %s, uid=" UID_FMT ", gid=" GID_FMT ", mode=%#o", @@ -340,7 +339,7 @@ static int node_permissions_apply(sd_device *dev, bool apply_mac, mode != MODE_INVALID ? mode & 0777 : stats.st_mode & 0777); /* apply SECLABEL{$module}=$label */ - ORDERED_HASHMAP_FOREACH_KEY(label, name, seclabel_list, i) { + ORDERED_HASHMAP_FOREACH_KEY(label, name, seclabel_list) { int q; if (streq(name, "selinux")) { diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index 8cd8ed1a1e..52f27ed941 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -62,7 +62,6 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device, static int setup_monitor(MonitorNetlinkGroup sender, sd_event *event, sd_device_monitor **ret) { _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor = NULL; const char *subsystem, *devtype, *tag; - Iterator i; int r; r = device_monitor_new_full(&monitor, sender, -1); @@ -75,14 +74,14 @@ static int setup_monitor(MonitorNetlinkGroup sender, sd_event *event, sd_device_ if (r < 0) return log_error_errno(r, "Failed to attach event: %m"); - HASHMAP_FOREACH_KEY(devtype, subsystem, arg_subsystem_filter, i) { + HASHMAP_FOREACH_KEY(devtype, subsystem, arg_subsystem_filter) { r = sd_device_monitor_filter_add_match_subsystem_devtype(monitor, subsystem, devtype); if (r < 0) return log_error_errno(r, "Failed to apply subsystem filter '%s%s%s': %m", subsystem, devtype ? "/" : "", strempty(devtype)); } - SET_FOREACH(tag, arg_tag_filter, i) { + SET_FOREACH(tag, arg_tag_filter) { r = sd_device_monitor_filter_add_match_tag(monitor, tag); if (r < 0) return log_error_errno(r, "Failed to apply tag filter '%s': %m", tag); diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index 53d4905992..0d84b31ff0 100644 --- a/src/udev/udevadm-test.c +++ b/src/udev/udevadm-test.c @@ -105,7 +105,6 @@ int test_main(int argc, char *argv[], void *userdata) { _cleanup_(sd_device_unrefp) sd_device *dev = NULL; const char *cmd, *key, *value; sigset_t mask, sigmask_orig; - Iterator i; void *val; int r; @@ -149,7 +148,7 @@ int test_main(int argc, char *argv[], void *userdata) { FOREACH_DEVICE_PROPERTY(dev, key, value) printf("%s=%s\n", key, value); - ORDERED_HASHMAP_FOREACH_KEY(val, cmd, event->run_list, i) { + ORDERED_HASHMAP_FOREACH_KEY(val, cmd, event->run_list) { char program[UTIL_PATH_SIZE]; (void) udev_event_apply_format(event, cmd, program, sizeof(program), false); diff --git a/src/udev/udevd.c b/src/udev/udevd.c index b2052578eb..48a7774fc9 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -612,7 +612,6 @@ static int worker_spawn(Manager *manager, struct event *event) { static void event_run(Manager *manager, struct event *event) { static bool log_children_max_reached = true; struct worker *worker; - Iterator i; int r; assert(manager); @@ -626,7 +625,7 @@ static void event_run(Manager *manager, struct event *event) { event->seqnum, r >= 0 ? device_action_to_string(action) : "<unknown>"); } - HASHMAP_FOREACH(worker, manager->workers, i) { + HASHMAP_FOREACH(worker, manager->workers) { if (worker->state != WORKER_IDLE) continue; @@ -724,11 +723,10 @@ static int event_queue_insert(Manager *manager, sd_device *dev) { static void manager_kill_workers(Manager *manager) { struct worker *worker; - Iterator i; assert(manager); - HASHMAP_FOREACH(worker, manager->workers, i) { + HASHMAP_FOREACH(worker, manager->workers) { if (worker->state == WORKER_KILLED) continue; diff --git a/src/xdg-autostart-generator/xdg-autostart-generator.c b/src/xdg-autostart-generator/xdg-autostart-generator.c index 53366a31ec..6cec28e622 100644 --- a/src/xdg-autostart-generator/xdg-autostart-generator.c +++ b/src/xdg-autostart-generator/xdg-autostart-generator.c @@ -94,7 +94,6 @@ static int enumerate_xdg_autostart(Hashmap *all_services) { static int run(const char *dest, const char *dest_early, const char *dest_late) { _cleanup_(hashmap_freep) Hashmap *all_services = NULL; XdgAutostartService *service; - Iterator j; int r; assert_se(dest_late); @@ -107,7 +106,7 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) if (r < 0) return r; - HASHMAP_FOREACH(service, all_services, j) + HASHMAP_FOREACH(service, all_services) (void) xdg_autostart_service_generate_unit(service, dest_late); return 0; |