]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Use array_foreach_elem() where possible
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 10 Feb 2021 18:25:30 +0000 (20:25 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 7 May 2021 10:09:35 +0000 (10:09 +0000)
src/auth/auth-worker-server.c
src/auth/auth.c
src/auth/db-dict-cache-key.c
src/auth/db-dict.c
src/auth/passdb.c
src/auth/userdb.c

index 156b2f1b6f999951c345607bdd3c9cbd4dc22a6d..53833c9a7cc2bb6ba587ab868756a82844461522 100644 (file)
@@ -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;
        }
index 2b8d32a129d97547d941ded6456f763ab18ae124..845c43cadfd7770f90369290eabfcf2dbf1dfac1 100644 (file)
@@ -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);
 }
 
index 1af6b0804fce136414614bfebefee473e560509b..a220d8d9c508834450a8642b972bab55c1fd92a9 100644 (file)
@@ -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);
 }
index 779ac4360a77ac35b353b47071d3121e6833ce3a..50be2c6f4a6feef7436756d2d028e16ce0d1889a 100644 (file)
@@ -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;
index 21fd38552931c88f524d07083b223687fab1fbb7..9bc2b875c37c5f206eeeee3814fe360082186802 100644 (file)
@@ -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;
        }
index 2f1fdf95c480f1138b93c2ee0d4e70f950c6b66f..21751f92970b006da00dfd07c7ea8a0639b2374f 100644 (file)
@@ -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;
        }