]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Use array_foreach_elem() where possible
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 10 Feb 2021 18:34:25 +0000 (20:34 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 7 May 2021 10:09:35 +0000 (10:09 +0000)
src/director/director-connection.c
src/director/director-host.c
src/director/director.c
src/director/doveadm-connection.c
src/director/mail-host.c
src/director/main.c
src/director/notify-connection.c
src/director/user-directory.c

index 82088983a85bf04e3ea9853e8e879bf337501d5b..72211bdb8b268851eed16d017dc3883acf426d2f 100644 (file)
@@ -367,11 +367,9 @@ static bool director_connection_assign_left(struct director_connection *conn)
 
 static void director_assign_left(struct director *dir)
 {
-       struct director_connection *conn, *const *connp;
-
-       array_foreach(&dir->connections, connp) {
-               conn = *connp;
+       struct director_connection *conn;
 
+       array_foreach_elem(&dir->connections, conn) {
                if (conn->in && conn->handshake_received &&
                    conn->to_disconnect == NULL && conn != dir->left) {
                        /* either use this or disconnect it */
@@ -388,10 +386,10 @@ static void director_assign_left(struct director *dir)
 
 static bool director_has_outgoing_connections(struct director *dir)
 {
-       struct director_connection *const *connp;
+       struct director_connection *conn;
 
-       array_foreach(&dir->connections, connp) {
-               if (!(*connp)->in && (*connp)->to_disconnect == NULL)
+       array_foreach_elem(&dir->connections, conn) {
+               if (!conn->in && conn->to_disconnect == NULL)
                        return TRUE;
        }
        return FALSE;
@@ -399,20 +397,20 @@ static bool director_has_outgoing_connections(struct director *dir)
 
 static void director_send_delayed_syncs(struct director *dir)
 {
-       struct director_host *const *hostp;
+       struct director_host *host;
 
        i_assert(dir->right != NULL);
 
        e_debug(dir->right->event, "Sending delayed SYNCs");
-       array_foreach(&dir->dir_hosts, hostp) {
-               if ((*hostp)->delayed_sync_seq == 0)
+       array_foreach_elem(&dir->dir_hosts, host) {
+               if (host->delayed_sync_seq == 0)
                        continue;
 
-               director_sync_send(dir, *hostp, (*hostp)->delayed_sync_seq,
-                                  (*hostp)->delayed_sync_minor_version,
-                                  (*hostp)->delayed_sync_timestamp,
-                                  (*hostp)->delayed_sync_hosts_hash);
-               (*hostp)->delayed_sync_seq = 0;
+               director_sync_send(dir, host, host->delayed_sync_seq,
+                                  host->delayed_sync_minor_version,
+                                  host->delayed_sync_timestamp,
+                                  host->delayed_sync_hosts_hash);
+               host->delayed_sync_seq = 0;
        }
 }
 
@@ -1840,11 +1838,9 @@ static bool director_cmd_connect(struct director_connection *conn,
 
 static void director_disconnect_wrong_lefts(struct director *dir)
 {
-       struct director_connection *const *connp, *conn;
-
-       array_foreach(&dir->connections, connp) {
-               conn = *connp;
+       struct director_connection *conn;
 
+       array_foreach_elem(&dir->connections, conn) {
                if (conn->in && conn != dir->left && conn->me_received &&
                    conn->to_disconnect == NULL &&
                    director_host_cmp_to_self(dir->left->host, conn->host,
@@ -2136,16 +2132,16 @@ static void director_connection_input(struct director_connection *conn)
 
 static void director_connection_send_directors(struct director_connection *conn)
 {
-       struct director_host *const *hostp;
+       struct director_host *host;
        string_t *str = t_str_new(64);
 
-       array_foreach(&conn->dir->dir_hosts, hostp) {
-               if ((*hostp)->removed)
+       array_foreach_elem(&conn->dir->dir_hosts, host) {
+               if (host->removed)
                        continue;
 
                str_truncate(str, 0);
                str_printfa(str, "DIRECTOR\t%s\t%u\n",
-                           (*hostp)->ip_str, (*hostp)->port);
+                           host->ip_str, host->port);
                director_connection_send(conn, str_c(str));
        }
 }
@@ -2153,7 +2149,7 @@ static void director_connection_send_directors(struct director_connection *conn)
 static void
 director_connection_send_hosts(struct director_connection *conn)
 {
-       struct mail_host *const *hostp;
+       struct mail_host *host;
        bool send_updowns;
        string_t *str = t_str_new(128);
 
@@ -2163,8 +2159,7 @@ director_connection_send_hosts(struct director_connection *conn)
 
        str_printfa(str, "HOST-HAND-START\t%u\n",
                    conn->dir->ring_handshaked ? 1 : 0);
-       array_foreach(mail_hosts_get(conn->dir->mail_hosts), hostp) {
-               struct mail_host *host = *hostp;
+       array_foreach_elem(mail_hosts_get(conn->dir->mail_hosts), host) {
                const char *host_tag = mail_host_get_tag(host);
 
                str_printfa(str, "HOST\t%s\t%u",
index 87d22719c4e64225f04b28c93b59332860a29f6b..215ad0d154c551f531dddc64e9b84e983349e18a 100644 (file)
@@ -108,12 +108,11 @@ struct director_host *
 director_host_lookup(struct director *dir, const struct ip_addr *ip,
                     in_port_t port)
 {
-       struct director_host *const *hostp;
+       struct director_host *host;
 
-       array_foreach(&dir->dir_hosts, hostp) {
-               if (net_ip_compare(&(*hostp)->ip, ip) &&
-                   (*hostp)->port == port)
-                       return *hostp;
+       array_foreach_elem(&dir->dir_hosts, host) {
+               if (net_ip_compare(&host->ip, ip) && host->port == port)
+                       return host;
        }
        return NULL;
 }
@@ -121,11 +120,11 @@ director_host_lookup(struct director *dir, const struct ip_addr *ip,
 struct director_host *
 director_host_lookup_ip(struct director *dir, const struct ip_addr *ip)
 {
-       struct director_host *const *hostp;
+       struct director_host *host;
 
-       array_foreach(&dir->dir_hosts, hostp) {
-               if (net_ip_compare(&(*hostp)->ip, ip))
-                       return *hostp;
+       array_foreach_elem(&dir->dir_hosts, host) {
+               if (net_ip_compare(&host->ip, ip))
+                       return host;
        }
        return NULL;
 }
index d211e8a8423694132d472be4a7a0935ce257aab7..43f7f0c99e10d0dfc3876b6c57f763897f824aa9 100644 (file)
@@ -119,11 +119,11 @@ static bool
 director_has_outgoing_connection(struct director *dir,
                                 struct director_host *host)
 {
-       struct director_connection *const *connp;
+       struct director_connection *conn;
 
-       array_foreach(&dir->connections, connp) {
-               if (director_connection_get_host(*connp) == host &&
-                   !director_connection_is_incoming(*connp))
+       array_foreach_elem(&dir->connections, conn) {
+               if (director_connection_get_host(conn) == host &&
+                   !director_connection_is_incoming(conn))
                        return TRUE;
        }
        return FALSE;
@@ -202,7 +202,7 @@ static void director_quick_reconnect_retry(struct director *dir)
 
 static bool director_wait_for_others(struct director *dir)
 {
-       struct director_host *const *hostp;
+       struct director_host *host;
 
        /* don't assume we're alone until we've attempted to connect
           to others for a while */
@@ -213,9 +213,9 @@ static bool director_wait_for_others(struct director *dir)
        if (dir->ring_first_alone == 0)
                dir->ring_first_alone = ioloop_time;
        /* reset all failures and try again */
-       array_foreach(&dir->dir_hosts, hostp) {
-               (*hostp)->last_network_failure = 0;
-               (*hostp)->last_protocol_failure = 0;
+       array_foreach_elem(&dir->dir_hosts, host) {
+               host->last_network_failure = 0;
+               host->last_protocol_failure = 0;
        }
        timeout_remove(&dir->to_reconnect);
        dir->to_reconnect = timeout_add(DIRECTOR_QUICK_RECONNECT_TIMEOUT_MSECS,
@@ -395,10 +395,10 @@ void director_sync_send(struct director *dir, struct director_host *host,
 static bool
 director_has_any_outgoing_connections(struct director *dir)
 {
-       struct director_connection *const *connp;
+       struct director_connection *conn;
 
-       array_foreach(&dir->connections, connp) {
-               if (!director_connection_is_incoming(*connp))
+       array_foreach_elem(&dir->connections, conn) {
+               if (!director_connection_is_incoming(conn))
                        return TRUE;
        }
        return FALSE;
@@ -496,19 +496,19 @@ static void director_sync(struct director *dir)
 
 void director_sync_freeze(struct director *dir)
 {
-       struct director_connection *const *connp;
+       struct director_connection *conn;
 
        i_assert(!dir->sync_frozen);
        i_assert(!dir->sync_pending);
 
-       array_foreach(&dir->connections, connp)
-               director_connection_cork(*connp);
+       array_foreach_elem(&dir->connections, conn)
+               director_connection_cork(conn);
        dir->sync_frozen = TRUE;
 }
 
 void director_sync_thaw(struct director *dir)
 {
-       struct director_connection *const *connp;
+       struct director_connection *conn;
 
        i_assert(dir->sync_frozen);
 
@@ -517,8 +517,8 @@ void director_sync_thaw(struct director *dir)
                dir->sync_pending = FALSE;
                director_sync(dir);
        }
-       array_foreach(&dir->connections, connp)
-               director_connection_uncork(*connp);
+       array_foreach_elem(&dir->connections, conn)
+               director_connection_uncork(conn);
 }
 
 void director_notify_ring_added(struct director_host *added_host,
@@ -656,10 +656,10 @@ director_send_host(struct director *dir, struct director_host *src,
 
 void director_resend_hosts(struct director *dir)
 {
-       struct mail_host *const *hostp;
+       struct mail_host *host;
 
-       array_foreach(mail_hosts_get(dir->mail_hosts), hostp)
-               director_send_host(dir, dir->self_host, NULL, *hostp);
+       array_foreach_elem(mail_hosts_get(dir->mail_hosts), host)
+               director_send_host(dir, dir->self_host, NULL, host);
 }
 
 void director_update_host(struct director *dir, struct director_host *src,
@@ -729,21 +729,21 @@ void director_flush_host(struct director *dir, struct director_host *src,
 void director_update_user(struct director *dir, struct director_host *src,
                          struct user *user)
 {
-       struct director_connection *const *connp;
+       struct director_connection *conn;
 
        i_assert(src != NULL);
        i_assert(!user->weak);
 
-       array_foreach(&dir->connections, connp) {
-               if (director_connection_get_host(*connp) == src)
+       array_foreach_elem(&dir->connections, conn) {
+               if (director_connection_get_host(conn) == src)
                        continue;
 
-               if (director_connection_get_minor_version(*connp) >= DIRECTOR_VERSION_USER_TIMESTAMP) {
-                       director_connection_send(*connp, t_strdup_printf(
+               if (director_connection_get_minor_version(conn) >= DIRECTOR_VERSION_USER_TIMESTAMP) {
+                       director_connection_send(conn, t_strdup_printf(
                                "USER\t%u\t%s\t%u\n", user->username_hash, user->host->ip_str,
                                user->timestamp));
                } else {
-                       director_connection_send(*connp, t_strdup_printf(
+                       director_connection_send(conn, t_strdup_printf(
                                "USER\t%u\t%s\n", user->username_hash, user->host->ip_str));
                }
        }
@@ -1341,10 +1341,10 @@ director_user_tag_killed(struct director *dir, struct mail_tag *tag,
 
 void director_user_killed(struct director *dir, unsigned int username_hash)
 {
-       struct mail_tag *const *tagp;
+       struct mail_tag *tag;
 
-       array_foreach(mail_hosts_get_tags(dir->mail_hosts), tagp)
-               director_user_tag_killed(dir, *tagp, username_hash);
+       array_foreach_elem(mail_hosts_get_tags(dir->mail_hosts), tag)
+               director_user_tag_killed(dir, tag, username_hash);
 }
 
 static void
@@ -1382,10 +1382,10 @@ void director_user_killed_everywhere(struct director *dir,
                                     struct director_host *orig_src,
                                     unsigned int username_hash)
 {
-       struct mail_tag *const *tagp;
+       struct mail_tag *tag;
 
-       array_foreach(mail_hosts_get_tags(dir->mail_hosts), tagp) {
-               director_user_tag_killed_everywhere(dir, *tagp, src, orig_src,
+       array_foreach_elem(mail_hosts_get_tags(dir->mail_hosts), tag) {
+               director_user_tag_killed_everywhere(dir, tag, src, orig_src,
                                                    username_hash);
        }
 }
@@ -1416,14 +1416,14 @@ void director_update_send_version(struct director *dir,
                                  struct director_host *src,
                                  unsigned int min_version, const char *cmd)
 {
-       struct director_connection *const *connp;
+       struct director_connection *conn;
 
        i_assert(src != NULL);
 
-       array_foreach(&dir->connections, connp) {
-               if (director_connection_get_host(*connp) != src &&
-                   director_connection_get_minor_version(*connp) >= min_version)
-                       director_connection_send(*connp, cmd);
+       array_foreach_elem(&dir->connections, conn) {
+               if (director_connection_get_host(conn) != src &&
+                   director_connection_get_minor_version(conn) >= min_version)
+                       director_connection_send(conn, cmd);
        }
 }
 
index ea36b5fb9d6d442d44fc6b3fd4b5c004d0116b27..c840536bede78174e6e856ac1e51d5db2ce02041 100644 (file)
@@ -100,16 +100,16 @@ static enum doveadm_director_cmd_ret
 doveadm_cmd_host_list(struct doveadm_connection *conn,
                      const char *const *args ATTR_UNUSED)
 {
-       struct mail_host *const *hostp;
+       struct mail_host *host;
        string_t *str = t_str_new(1024);
 
-       array_foreach(mail_hosts_get(conn->dir->mail_hosts), hostp) {
+       array_foreach_elem(mail_hosts_get(conn->dir->mail_hosts), host) {
                str_printfa(str, "%s\t%u\t%u\t",
-                           (*hostp)->ip_str, (*hostp)->vhost_count,
-                           (*hostp)->user_count);
-               str_append_tabescaped(str, mail_host_get_tag(*hostp));
-               str_printfa(str, "\t%c\t%ld", (*hostp)->down ? 'D' : 'U',
-                           (long)(*hostp)->last_updown_change);
+                           host->ip_str, host->vhost_count,
+                           host->user_count);
+               str_append_tabescaped(str, mail_host_get_tag(host));
+               str_printfa(str, "\t%c\t%ld", host->down ? 'D' : 'U',
+                           (long)host->last_updown_change);
                str_append_c(str, '\n');
        }
        str_append_c(str, '\n');
@@ -255,9 +255,9 @@ doveadm_cmd_director_list(struct doveadm_connection *conn,
                          const char *const *args ATTR_UNUSED)
 {
        struct director *dir = conn->dir;
-       struct director_host *const *hostp;
+       struct director_host *host;
        string_t *str = t_str_new(1024);
-       struct director_connection *const *connp;
+       struct director_connection *dir_conn;
        ARRAY(struct director_host *) hosts;
 
        t_array_init(&hosts, array_count(&dir->dir_hosts));
@@ -265,23 +265,22 @@ doveadm_cmd_director_list(struct doveadm_connection *conn,
        array_sort(&hosts, director_host_cmp_p);
 
        /* first show incoming connections that have no known host yet */
-       array_foreach(&dir->connections, connp) {
-               if (director_connection_get_host(*connp) == NULL)
-                       doveadm_director_connection_append(dir, *connp, NULL, str);
+       array_foreach_elem(&dir->connections, dir_conn) {
+               if (director_connection_get_host(dir_conn) == NULL)
+                       doveadm_director_connection_append(dir, dir_conn, NULL, str);
        }
 
        /* show other connections and host without connections sorted by host */
-       array_foreach(&hosts, hostp) {
-               const struct director_host *host = *hostp;
+       array_foreach_elem(&hosts, host) {
                bool have_connections = FALSE;
 
-               array_foreach(&dir->connections, connp) {
+               array_foreach_elem(&dir->connections, dir_conn) {
                        const struct director_host *conn_host =
-                               director_connection_get_host(*connp);
+                               director_connection_get_host(dir_conn);
                        if (conn_host != host)
                                continue;
                        have_connections = TRUE;
-                       doveadm_director_connection_append(dir, *connp, host, str);
+                       doveadm_director_connection_append(dir, dir_conn, host, str);
                }
                if (!have_connections)
                        doveadm_director_host_append(dir, host, str);
@@ -480,13 +479,13 @@ doveadm_cmd_host_remove(struct doveadm_connection *conn,
 static void
 doveadm_cmd_host_flush_all(struct doveadm_connection *conn)
 {
-       struct mail_host *const *hostp;
+       struct mail_host *host;
        unsigned int total_user_count = 0;
 
-       array_foreach(mail_hosts_get(conn->dir->mail_hosts), hostp) {
-               total_user_count += (*hostp)->user_count;
+       array_foreach_elem(mail_hosts_get(conn->dir->mail_hosts), host) {
+               total_user_count += host->user_count;
                director_flush_host(conn->dir, conn->dir->self_host,
-                                   NULL, *hostp);
+                                   NULL, host);
        }
        e_warning(conn->dir->event,
                  "Flushed all backend hosts with %u users. This is an unsafe "
index b26e40c0b40ef8676ec5eea55302d6fdfc69dfe8..c70c7a0ce959daf989cc73286ec2c500c64f1c2f 100644 (file)
@@ -81,54 +81,54 @@ static void mail_vhost_add(struct mail_tag *tag, struct mail_host *host)
 static void
 mail_tag_vhosts_sort_ring(struct mail_host_list *list, struct mail_tag *tag)
 {
-       struct mail_host *const *hostp;
+       struct mail_host *host;
 
        /* rebuild vhosts */
        array_clear(&tag->vhosts);
-       array_foreach(&list->hosts, hostp)
-               mail_vhost_add(tag, *hostp);
+       array_foreach_elem(&list->hosts, host)
+               mail_vhost_add(tag, host);
        array_sort(&tag->vhosts, mail_vhost_cmp);
 }
 
 static void
 mail_hosts_sort(struct mail_host_list *list)
 {
-       struct mail_host *const *hostp;
-       struct mail_tag *const *tagp;
+       struct mail_host *host;
+       struct mail_tag *tag;
        uint32_t num;
 
        array_sort(&list->hosts, mail_host_cmp);
 
        list->have_vhosts = FALSE;
-       array_foreach(&list->tags, tagp) {
-               mail_tag_vhosts_sort_ring(list, *tagp);
-               if (array_count(&(*tagp)->vhosts) > 0)
+       array_foreach_elem(&list->tags, tag) {
+               mail_tag_vhosts_sort_ring(list, tag);
+               if (array_count(&tag->vhosts) > 0)
                        list->have_vhosts = TRUE;
        }
        list->vhosts_unsorted = FALSE;
 
        /* recalculate the hosts_hash */
        list->hosts_hash = 0;
-       array_foreach(&list->hosts, hostp) {
-               num = ((*hostp)->down ? 1 : 0) ^ (*hostp)->vhost_count;
+       array_foreach_elem(&list->hosts, host) {
+               num = (host->down ? 1 : 0) ^ host->vhost_count;
                list->hosts_hash = crc32_data_more(list->hosts_hash,
                                                   &num, sizeof(num));
-               num = net_ip_hash(&(*hostp)->ip);
+               num = net_ip_hash(&host->ip);
                list->hosts_hash = crc32_data_more(list->hosts_hash,
                                                   &num, sizeof(num));
                list->hosts_hash = crc32_str_more(list->hosts_hash,
-                                                 (*hostp)->tag->name);
+                                                 host->tag->name);
        }
 }
 
 struct mail_tag *
 mail_tag_find(struct mail_host_list *list, const char *tag_name)
 {
-       struct mail_tag *const *tagp;
+       struct mail_tag *tag;
 
-       array_foreach(&list->tags, tagp) {
-               if (strcmp((*tagp)->name, tag_name) == 0)
-                       return *tagp;
+       array_foreach_elem(&list->tags, tag) {
+               if (strcmp(tag->name, tag_name) == 0)
+                       return tag;
        }
        return NULL;
 }
@@ -389,14 +389,14 @@ void mail_host_remove(struct mail_host *host)
 struct mail_host *
 mail_host_lookup(struct mail_host_list *list, const struct ip_addr *ip)
 {
-       struct mail_host *const *hostp;
+       struct mail_host *host;
 
        if (list->vhosts_unsorted)
                mail_hosts_sort(list);
 
-       array_foreach(&list->hosts, hostp) {
-               if (net_ip_compare(&(*hostp)->ip, ip))
-                       return *hostp;
+       array_foreach_elem(&list->hosts, host) {
+               if (net_ip_compare(&host->ip, ip))
+                       return host;
        }
        return NULL;
 }
@@ -437,10 +437,10 @@ mail_host_get_by_hash(struct mail_host_list *list, unsigned int hash,
 
 void mail_hosts_set_synced(struct mail_host_list *list)
 {
-       struct mail_host *const *hostp;
+       struct mail_host *host;
 
-       array_foreach(&list->hosts, hostp)
-               (*hostp)->desynced = FALSE;
+       array_foreach_elem(&list->hosts, host)
+               host->desynced = FALSE;
 }
 
 unsigned int mail_hosts_hash(struct mail_host_list *list)
@@ -468,13 +468,13 @@ const ARRAY_TYPE(mail_host) *mail_hosts_get(struct mail_host_list *list)
 
 bool mail_hosts_have_tags(struct mail_host_list *list)
 {
-       struct mail_tag *const *tagp;
+       struct mail_tag *tag;
 
        if (list->vhosts_unsorted)
                mail_hosts_sort(list);
 
-       array_foreach(&list->tags, tagp) {
-               if ((*tagp)->name[0] != '\0' && array_count(&(*tagp)->vhosts) > 0)
+       array_foreach_elem(&list->tags, tag) {
+               if (tag->name[0] != '\0' && array_count(&tag->vhosts) > 0)
                        return TRUE;
        }
        return FALSE;
@@ -505,15 +505,15 @@ mail_hosts_init(struct director *dir,
 void mail_hosts_deinit(struct mail_host_list **_list)
 {
        struct mail_host_list *list = *_list;
-       struct mail_host *const *hostp;
-       struct mail_tag *const *tagp;
+       struct mail_host *host;
+       struct mail_tag *tag;
 
        *_list = NULL;
 
-       array_foreach(&list->tags, tagp)
-               mail_tag_free(*tagp);
-       array_foreach(&list->hosts, hostp)
-               mail_host_free(*hostp);
+       array_foreach_elem(&list->tags, tag)
+               mail_tag_free(tag);
+       array_foreach_elem(&list->hosts, host)
+               mail_host_free(host);
        array_free(&list->hosts);
        array_free(&list->tags);
        i_free(list);
@@ -535,11 +535,11 @@ mail_host_dup(struct mail_host_list *dest_list, const struct mail_host *src)
 struct mail_host_list *mail_hosts_dup(const struct mail_host_list *src)
 {
        struct mail_host_list *dest;
-       struct mail_host *const *hostp, *dest_host;
+       struct mail_host *host, *dest_host;
 
        dest = mail_hosts_init(src->dir, src->user_expire_secs, src->user_free_hook);
-       array_foreach(&src->hosts, hostp) {
-               dest_host = mail_host_dup(dest, *hostp);
+       array_foreach_elem(&src->hosts, host) {
+               dest_host = mail_host_dup(dest, host);
                array_push_back(&dest->hosts, &dest_host);
        }
        mail_hosts_sort(dest);
@@ -548,8 +548,8 @@ struct mail_host_list *mail_hosts_dup(const struct mail_host_list *src)
 
 void mail_hosts_sort_users(struct mail_host_list *list)
 {
-       struct mail_tag *const *tagp;
+       struct mail_tag *tag;
 
-       array_foreach(&list->tags, tagp)
-               user_directory_sort((*tagp)->users);
+       array_foreach_elem(&list->tags, tag)
+               user_directory_sort(tag->users);
 }
index 36fce048daab6682ca312dc2976096b9400b096a..d55a38afc3b6b70e80ac01fd8c7a7a53de4d86c6 100644 (file)
@@ -42,11 +42,11 @@ static ARRAY(enum director_socket_type) listener_socket_types;
 
 static unsigned int director_total_users_count(void)
 {
-       struct mail_tag *const *tagp;
+       struct mail_tag *tag;
        unsigned int count = 0;
 
-       array_foreach(mail_hosts_get_tags(director->mail_hosts), tagp)
-               count += user_directory_count((*tagp)->users);
+       array_foreach_elem(mail_hosts_get_tags(director->mail_hosts), tag)
+               count += user_directory_count(tag->users);
        return count;
 }
 
@@ -232,7 +232,7 @@ static void client_connected(struct master_service_connection *conn)
 
 static void director_state_changed(struct director *dir)
 {
-       struct director_request *const *requestp;
+       struct director_request *request;
        ARRAY(struct director_request *) new_requests;
        bool ret;
 
@@ -241,12 +241,12 @@ static void director_state_changed(struct director *dir)
 
        /* if there are any pending client requests, finish them now */
        t_array_init(&new_requests, 8);
-       array_foreach(&dir->pending_requests, requestp) {
-               ret = director_request_continue(*requestp);
+       array_foreach_elem(&dir->pending_requests, request) {
+               ret = director_request_continue(request);
                if (!ret) {
                        /* a) request for a user being killed
                           b) user is weak */
-                       array_push_back(&new_requests, requestp);
+                       array_push_back(&new_requests, &request);
                }
        }
        array_clear(&dir->pending_requests);
index 628f844da69ccee651c35a1e9e4abe3538f09492..d750c831eab8bb3bfb199e032f3289625b9241ea 100644 (file)
@@ -49,15 +49,15 @@ static void notify_update_user(struct director *dir, struct mail_tag *tag,
 
 static void notify_connection_input(struct notify_connection *conn)
 {
-       struct mail_tag *const *tagp;
+       struct mail_tag *tag;
        const char *line;
        unsigned int hash;
 
        while ((line = i_stream_read_next_line(conn->input)) != NULL) {
                if (!director_get_username_hash(conn->dir, line, &hash))
                        continue;
-               array_foreach(mail_hosts_get_tags(conn->dir->mail_hosts), tagp)
-                       notify_update_user(conn->dir, *tagp, line, hash);
+               array_foreach_elem(mail_hosts_get_tags(conn->dir->mail_hosts), tag)
+                       notify_update_user(conn->dir, tag, line, hash);
        }
        if (conn->input->eof) {
                if (conn->fifo)
index 9a4244664be11f697c6ea0fe7a0cd2ef343fd3e9..ea7f6e0b9c8211edcefb49aa014d7d09dcf49334 100644 (file)
@@ -44,13 +44,13 @@ struct user_directory {
 
 static void user_move_iters(struct user_directory *dir, struct user *user)
 {
-       struct user_directory_iter *const *iterp;
+       struct user_directory_iter *iter;
 
-       array_foreach(&dir->iters, iterp) {
-               if ((*iterp)->pos == user)
-                       (*iterp)->pos = user->next;
-               if ((*iterp)->stop_after_tail == user) {
-                       (*iterp)->stop_after_tail =
+       array_foreach_elem(&dir->iters, iter) {
+               if (iter->pos == user)
+                       iter->pos = user->next;
+               if (iter->stop_after_tail == user) {
+                       iter->stop_after_tail =
                                user->prev != NULL ? user->prev : user->next;
                }
        }
@@ -205,7 +205,7 @@ static int user_timestamp_cmp(struct user *const *user1,
 void user_directory_sort(struct user_directory *dir)
 {
        ARRAY(struct user *) users;
-       struct user *user, *const *userp;
+       struct user *user;
        unsigned int i, users_count = hash_table_count(dir->hash);
 
        dir->sort_pending = FALSE;
@@ -233,8 +233,8 @@ void user_directory_sort(struct user_directory *dir)
 
        /* recreate the linked list */
        dir->head = dir->tail = NULL;
-       array_foreach(&users, userp)
-               DLLIST2_APPEND(&dir->head, &dir->tail, *userp);
+       array_foreach_elem(&users, user)
+               DLLIST2_APPEND(&dir->head, &dir->tail, user);
        i_assert(dir->head != NULL &&
                 dir->head->timestamp <= dir->tail->timestamp);
        array_free(&users);