From: Timo Sirainen Date: Wed, 10 Feb 2021 18:25:30 +0000 (+0200) Subject: auth: Use array_foreach_elem() where possible X-Git-Tag: 2.3.16~202 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cab67ca2cda06d0bb3b5c55fd0c8889b2d79c10d;p=thirdparty%2Fdovecot%2Fcore.git auth: Use array_foreach_elem() where possible --- diff --git a/src/auth/auth-worker-server.c b/src/auth/auth-worker-server.c index 156b2f1b6f..53833c9a7c 100644 --- a/src/auth/auth-worker-server.c +++ b/src/auth/auth-worker-server.c @@ -268,14 +268,12 @@ static void auth_worker_destroy(struct auth_worker_connection **_conn, static struct auth_worker_connection *auth_worker_find_free(void) { - struct auth_worker_connection **conns; + struct auth_worker_connection *conn; if (idle_count == 0) return NULL; - array_foreach_modifiable(&connections, conns) { - struct auth_worker_connection *conn = *conns; - + array_foreach_elem(&connections, conn) { if (conn->request == NULL) return conn; } diff --git a/src/auth/auth.c b/src/auth/auth.c index 2b8d32a129..845c43cadf 100644 --- a/src/auth/auth.c +++ b/src/auth/auth.c @@ -373,7 +373,7 @@ void auths_preinit(const struct auth_settings *set, pool_t pool, { struct master_service_settings_output set_output; const struct auth_settings *service_set; - struct auth *auth, *const *authp; + struct auth *auth; unsigned int i; const char *not_service = NULL; bool check_default = TRUE; @@ -404,15 +404,15 @@ void auths_preinit(const struct auth_settings *set, pool_t pool, if (not_service != NULL && str_array_find(services, not_service+1)) check_default = FALSE; - array_foreach(&auths, authp) { - if ((*authp)->service != NULL || check_default) - auth_mech_list_verify_passdb(*authp); + array_foreach_elem(&auths, auth) { + if (auth->service != NULL || check_default) + auth_mech_list_verify_passdb(auth); } } void auths_init(void) { - struct auth *const *auth; + struct auth *auth; /* sanity checks */ i_assert(auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_USER_IDX].key == 'u'); @@ -423,16 +423,16 @@ void auths_init(void) i_assert(auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT-1].key != '\0' || auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT-1].long_key != NULL); - array_foreach(&auths, auth) - auth_init(*auth); + array_foreach_elem(&auths, auth) + auth_init(auth); } void auths_deinit(void) { - struct auth *const *auth; + struct auth *auth; - array_foreach(&auths, auth) - auth_deinit(*auth); + array_foreach_elem(&auths, auth) + auth_deinit(auth); event_unref(&auth_event); } diff --git a/src/auth/db-dict-cache-key.c b/src/auth/db-dict-cache-key.c index 1af6b0804f..a220d8d9c5 100644 --- a/src/auth/db-dict-cache-key.c +++ b/src/auth/db-dict-cache-key.c @@ -26,7 +26,6 @@ db_dict_parse_cache_key(const ARRAY_TYPE(db_dict_key) *keys, { const struct db_dict_field *field; const struct db_dict_key *key; - const struct db_dict_key *const *keyp; const char *p, *name; unsigned int idx, size; string_t *str = t_str_new(128); @@ -59,7 +58,7 @@ db_dict_parse_cache_key(const ARRAY_TYPE(db_dict_key) *keys, p += size; } } - array_foreach(objects, keyp) - str_printfa(str, "\t%s", (*keyp)->key); + array_foreach_elem(objects, key) + str_printfa(str, "\t%s", key->key); return str_c(str); } diff --git a/src/auth/db-dict.c b/src/auth/db-dict.c index 779ac4360a..50be2c6f4a 100644 --- a/src/auth/db-dict.c +++ b/src/auth/db-dict.c @@ -377,11 +377,11 @@ static void db_dict_iter_find_used_keys(struct db_dict_value_iter *iter) static void db_dict_iter_find_used_objects(struct db_dict_value_iter *iter) { - const struct db_dict_key *const *keyp; + const struct db_dict_key *dict_key; struct db_dict_iter_key *key; - array_foreach(iter->objects, keyp) { - key = db_dict_iter_find_key(iter, (*keyp)->name); + array_foreach_elem(iter->objects, dict_key) { + key = db_dict_iter_find_key(iter, dict_key->name); i_assert(key != NULL); /* checked at init */ i_assert(key->key->parsed_format != DB_DICT_VALUE_FORMAT_VALUE); key->used = TRUE; diff --git a/src/auth/passdb.c b/src/auth/passdb.c index 21fd385529..9bc2b875c3 100644 --- a/src/auth/passdb.c +++ b/src/auth/passdb.c @@ -15,11 +15,9 @@ static const struct passdb_module_interface passdb_iface_deinit = { static struct passdb_module_interface *passdb_interface_find(const char *name) { - struct passdb_module_interface *const *ifaces; - - array_foreach(&passdb_interfaces, ifaces) { - struct passdb_module_interface *iface = *ifaces; + struct passdb_module_interface *iface; + array_foreach_elem(&passdb_interfaces, iface) { if (strcmp(iface->name, name) == 0) return iface; } diff --git a/src/auth/userdb.c b/src/auth/userdb.c index 2f1fdf95c4..21751f9297 100644 --- a/src/auth/userdb.c +++ b/src/auth/userdb.c @@ -15,11 +15,9 @@ static const struct userdb_module_interface userdb_iface_deinit = { static struct userdb_module_interface *userdb_interface_find(const char *name) { - struct userdb_module_interface *const *ifaces; - - array_foreach(&userdb_interfaces, ifaces) { - struct userdb_module_interface *iface = *ifaces; + struct userdb_module_interface *iface; + array_foreach_elem(&userdb_interfaces, iface) { if (strcmp(iface->name, name) == 0) return iface; }