]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Use array_first instead of array_idx
authorAki Tuomi <aki.tuomi@dovecot.fi>
Fri, 4 Jan 2019 11:56:10 +0000 (13:56 +0200)
committerVille Savolainen <ville.savolainen@open-xchange.com>
Mon, 1 Apr 2019 10:48:51 +0000 (10:48 +0000)
@@
expression A;
@@

-array_idx(A, 0)
+array_first(A)

@@
expression A;
@@

-array_idx_modifiable(A, 0)
+array_first_modifiable(A)

60 files changed:
src/auth/auth-request-handler.c
src/auth/auth-worker-server.c
src/auth/db-ldap.c
src/config/config-parser.c
src/dict/dict-commands.c
src/director/director.c
src/doveadm/doveadm-dsync.c
src/doveadm/doveadm-dump-index.c
src/doveadm/doveadm-kick.c
src/doveadm/doveadm-mail-server.c
src/doveadm/doveadm-mailbox-list-iter.c
src/doveadm/doveadm-print-formatted.c
src/doveadm/doveadm-who.c
src/doveadm/dsync/dsync-ibc-pipe.c
src/doveadm/dsync/dsync-mailbox-export.c
src/imap/cmd-thread.c
src/imap/imap-commands-util.c
src/imap/imap-fetch.c
src/ipc/ipc-connection.c
src/ipc/ipc-group.c
src/lib-dict/dict-redis.c
src/lib-fts/fts-filter-normalizer-icu.c
src/lib-fts/fts-language.c
src/lib-http/http-client-connection.c
src/lib-http/http-message-parser.c
src/lib-imap-client/imapc-client.c
src/lib-imap-client/imapc-connection.c
src/lib-imap-client/imapc-msgmap.c
src/lib-imap/imap-parser.c
src/lib-index/mail-index-sync-ext.c
src/lib-index/mail-index-transaction-update.c
src/lib-index/mail-index-view-sync.c
src/lib-index/mail-transaction-log-view.c
src/lib-lda/mail-deliver.c
src/lib-ldap/ldap-entry.c
src/lib-mail/istream-attachment-connector.c
src/lib-master/anvil-client.c
src/lib-smtp/smtp-reply-parser.c
src/lib-smtp/smtp-server-cmd-mail.c
src/lib-smtp/smtp-server-cmd-rcpt.c
src/lib-smtp/smtp-server-command.c
src/lib-smtp/smtp-server-transaction.c
src/lib-sql/driver-cassandra.c
src/lib-sql/driver-test.c
src/lib-storage/index/dbox-multi/mdbox-purge.c
src/lib-storage/index/dbox-multi/mdbox-save.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-search.c
src/lib-storage/index/index-sync-changes.c
src/lib-storage/index/index-thread-finish.c
src/lib-storage/index/pop3c/pop3c-client.c
src/lib/priorityq.c
src/master/service-process-notify.c
src/plugins/acl/acl-cache.c
src/plugins/fts-solr/solr-connection.c
src/plugins/fts/fts-expunge-log.c
src/plugins/mail-crypt/test-mail-global-key.c
src/plugins/quota/quota-imapc.c
src/plugins/virtual/virtual-sync.c
src/util/script.c

index 318f150316c0f0f8349ee6127a8a4e8297cafbff..dbc41d6f5a94588c95504523de1a8598d7f44a10 100644 (file)
@@ -867,7 +867,7 @@ void auth_request_handler_flush_failures(bool flush_all)
                return;
        }
 
-       auth_requests = array_idx_modifiable(&auth_failures_arr, 0);
+       auth_requests = array_first_modifiable(&auth_failures_arr);
        /* count the number of requests that we need to flush */
        for (i = 0; i < count; i++) {
                auth_request = auth_requests[aqueue_idx(auth_failures, i)];
index a0b16d76578ce4f7a2a1e4d5541ea9be1c9a9422..b8ed2916bd33881483ccc93a9c5df40aeb6820f1 100644 (file)
@@ -500,7 +500,7 @@ void auth_worker_server_deinit(void)
        struct auth_worker_connection **connp, *conn;
 
        while (array_count(&connections) > 0) {
-               connp = array_idx_modifiable(&connections, 0);
+               connp = array_first_modifiable(&connections);
                conn = *connp;
                auth_worker_destroy(&conn, "Shutting down", FALSE);
        }
index 7a41b6758fcaf24444c88a15ffbe5cdff7c0a297..460822a9fa0e95196101beedab902ade9813d491 100644 (file)
@@ -544,7 +544,7 @@ db_ldap_find_request(struct ldap_connection *conn, int msgid,
        if (count == 0)
                return NULL;
 
-       requests = array_idx(&conn->request_array, 0);
+       requests = array_first(&conn->request_array);
        for (i = 0; i < count; i++) {
                request = requests[aqueue_idx(conn->request_queue, i)];
                if (request->msgid == msgid) {
@@ -1326,7 +1326,7 @@ static void db_ldap_conn_close(struct ldap_connection *conn)
        timeout_remove(&conn->to);
 
        if (conn->pending_count != 0) {
-               requests = array_idx(&conn->request_array, 0);
+               requests = array_first(&conn->request_array);
                for (i = 0; i < conn->pending_count; i++) {
                        request = requests[aqueue_idx(conn->request_queue, i)];
 
index 0519644d9133547c0d5c86a8805ec855c5cf87e4..c3bc7649a53b26e64f1725d929c17fa6a2476cda 100644 (file)
@@ -738,7 +738,7 @@ static int config_parse_finish(struct config_parser_context *ctx, const char **e
 
        new_filter = config_filter_init(ctx->pool);
        array_append_zero(&ctx->all_parsers);
-       config_filter_add_all(new_filter, array_idx(&ctx->all_parsers, 0));
+       config_filter_add_all(new_filter, array_first(&ctx->all_parsers));
 
        if (ret < 0)
                ;
index c1b393ebf15e187f1b174b8da5e97c6eb1846f6c..9302c2a8d05b2b1cda5ad8b13f433379c3646213 100644 (file)
@@ -80,7 +80,7 @@ static void dict_connection_cmds_flush(struct dict_connection *conn)
 
        dict_connection_ref(conn);
        while (array_count(&conn->cmds) > 0) {
-               first_cmdp = array_idx(&conn->cmds, 0);
+               first_cmdp = array_first(&conn->cmds);
                cmd = *first_cmdp;
 
                i_assert(cmd->async_reply_id == 0);
@@ -659,7 +659,7 @@ static void dict_connection_cmd_output_more(struct dict_connection_cmd *cmd)
        struct dict_connection_cmd *const *first_cmdp;
 
        if (cmd->conn->minor_version < DICT_CLIENT_PROTOCOL_TIMINGS_MIN_VERSION) {
-               first_cmdp = array_idx(&cmd->conn->cmds, 0);
+               first_cmdp = array_first(&cmd->conn->cmds);
                if (*first_cmdp != cmd)
                        return;
        }
index 843f8553195da03c9bbec65423b8e80372f72c1d..c5661ab765222a19b0573e9fe6a3cb3eaadac70a 100644 (file)
@@ -1465,7 +1465,7 @@ void director_deinit(struct director **_dir)
        *_dir = NULL;
 
        while (array_count(&dir->connections) > 0) {
-               connp = array_idx(&dir->connections, 0);
+               connp = array_first(&dir->connections);
                conn = *connp;
                director_connection_deinit(&conn, "Shutting down");
        }
@@ -1481,7 +1481,7 @@ void director_deinit(struct director **_dir)
        timeout_remove(&dir->to_remove_dirs);
        timeout_remove(&dir->to_callback);
        while (array_count(&dir->dir_hosts) > 0) {
-               hostp = array_idx(&dir->dir_hosts, 0);
+               hostp = array_first(&dir->dir_hosts);
                host = *hostp;
                director_host_free(&host);
        }
index 808c126493d6922de95fb87afbafeed489b6b0ca..d2b3f1c651d1eadf6dc9877b04f51cb20117748e 100644 (file)
@@ -614,7 +614,7 @@ cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
                t_strsplit_spaces(doveadm_settings->dsync_hashed_headers, " ,");
        if (array_count(&ctx->exclude_mailboxes) > 0) {
                /* array is NULL-terminated in init() */
-               set.exclude_mailboxes = array_idx(&ctx->exclude_mailboxes, 0);
+               set.exclude_mailboxes = array_first(&ctx->exclude_mailboxes);
        }
        doveadm_user_init_dsync(user);
 
index 1b38de2a4f44d2ddf04b7df2f796aae12b53e312..250b63a19033a6793695d79e2b8ee49af127d398 100644 (file)
@@ -376,7 +376,7 @@ static void dump_keywords(struct mail_index *index)
        if (count == 0)
                return;
 
-       keywords = array_idx(&index->keywords, 0);
+       keywords = array_first(&index->keywords);
        for (i = 0; i < count; i++)
                printf("%3u = %s\n", i, keywords[kw_indexes[i]]);
 }
index 425a1e114bd194a0a1dfffda23f6a9eac746b252..41acba84b081377c8bfb08ff51a0b2f7b7d4e142 100644 (file)
@@ -71,7 +71,7 @@ kick_pid_want_kicked(struct kick_context *ctx, const struct kick_pid *k_pid,
        const struct kick_user *user;
 
        if (array_count(&k_pid->users) == 1) {
-               user = array_idx(&k_pid->users, 0);
+               user = array_first(&k_pid->users);
                if (!user->kick_me)
                        return FALSE;
        } else {
index d0215844583c74032c9d1111154e5397077dd448..4e0466ba5662a7f52fa019d2d96581bd40edd8f7 100644 (file)
@@ -119,7 +119,7 @@ static void doveadm_cmd_callback(int exit_code, const char *error,
 
        if (array_count(&server->queue) > 0) {
                struct server_connection *conn;
-               char *const *usernamep = array_idx(&server->queue, 0);
+               char *const *usernamep = array_first(&server->queue);
                char *username = *usernamep;
 
                conn = doveadm_server_find_unused_conn(server);
@@ -337,7 +337,7 @@ static void doveadm_servers_destroy_all_connections(void)
                while (array_count(&server->connections) > 0) {
                        struct server_connection *const *connp, *conn;
 
-                       connp = array_idx(&server->connections, 0);
+                       connp = array_first(&server->connections);
                        conn = *connp;
                        server_connection_destroy(&conn);
                }
index 71179998cb475449c2fbf1940afec14643ee3656..d76c0cca6dca2e7865a373c640ba15e860581ef5 100644 (file)
@@ -108,7 +108,7 @@ doveadm_mailbox_list_iter_init_nsmask(struct doveadm_mail_cmd_context *ctx,
        iter->only_selectable = TRUE;
        iter->iter_flags = iter_flags;
        iter->iter = mailbox_list_iter_init_namespaces(user->namespaces,
-                                                      array_idx(&iter->patterns, 0),
+                                                      array_first(&iter->patterns),
                                                       ns_mask, iter_flags);
        return iter;
 }
index 50851cfe04d3da7861c4f2641f54904300bfe173..bd3916cca1d4cce3d9dc9800ef43f133965d32f1 100644 (file)
@@ -64,7 +64,7 @@ static void doveadm_print_formatted_print(const char *value)
        entry->value = value;
 
        if (ctx.idx >= array_count(&ctx.headers)) {
-               if (var_expand(ctx.buf, ctx.format, array_idx(&ctx.headers,0), &error) <= 0) {
+               if (var_expand(ctx.buf, ctx.format, array_first(&ctx.headers), &error) <= 0) {
                        i_error("Failed to expand print format '%s': %s",
                                ctx.format, error);
                }
index a0544affa2cf6b1a68f3ecb3434323c81ba88df2..8bdcccaf9844e181daac959fd844d6683a217def 100644 (file)
@@ -28,7 +28,7 @@ static void who_user_ip(const struct who_user *user, struct ip_addr *ip_r)
        if (array_count(&user->ips) == 0)
                i_zero(ip_r);
        else {
-               const struct ip_addr *ip = array_idx(&user->ips, 0);
+               const struct ip_addr *ip = array_first(&user->ips);
                *ip_r = *ip;
        }
 }
index e9f8ca3719192c55a8fa7c79e8eb25acc5b75904..3d6d2b72e0f92b6c962f5f418e10b2f51cefd2e5 100644 (file)
@@ -111,7 +111,7 @@ dsync_ibc_pipe_pop_item(struct dsync_ibc_pipe *pipe, enum item_type type)
        if (array_count(&pipe->item_queue) == 0)
                return NULL;
 
-       item = array_idx_modifiable(&pipe->item_queue, 0);
+       item = array_first_modifiable(&pipe->item_queue);
        i_assert(item->type == type);
        pipe->pop_item = *item;
        array_delete(&pipe->item_queue, 0, 1);
@@ -129,7 +129,7 @@ static bool dsync_ibc_pipe_try_pop_eol(struct dsync_ibc_pipe *pipe)
        if (array_count(&pipe->item_queue) == 0)
                return FALSE;
 
-       item = array_idx(&pipe->item_queue, 0);
+       item = array_first(&pipe->item_queue);
        if (item->type != ITEM_END_OF_LIST)
                return FALSE;
 
@@ -526,7 +526,7 @@ static void pipe_close_mail_streams(struct dsync_ibc_pipe *pipe)
        struct item *item;
 
        if (array_count(&pipe->item_queue) > 0) {
-               item = array_idx_modifiable(&pipe->item_queue, 0);
+               item = array_first_modifiable(&pipe->item_queue);
                if (item->type == ITEM_MAIL &&
                    item->u.mail.input != NULL)
                        i_stream_unref(&item->u.mail.input);
index 9cf5e36a4e30f486be56ca4cb863c54f70e84d35..8d36300fe07c0b1a550043956d42f7752650506a 100644 (file)
@@ -745,7 +745,7 @@ dsync_mailbox_export_body_search_init(struct dsync_mailbox_exporter *exporter)
                    array_count(&instances->seqs) == 0)
                        continue;
 
-               uids = array_idx(&instances->seqs, 0);
+               uids = array_first(&instances->seqs);
                seq = uids[0].seq1;
                if (!instances->searched) {
                        instances->searched = TRUE;
@@ -762,7 +762,7 @@ dsync_mailbox_export_body_search_init(struct dsync_mailbox_exporter *exporter)
                                             &const_guid, 1);
                                continue;
                        }
-                       uids = array_idx(&instances->seqs, 0);
+                       uids = array_first(&instances->seqs);
                        seq = uids[0].seq1;
                        seq_range_array_add(&sarg->value.seqset, seq);
                }
index 9e109f3a56cb480c2336e4e096f29ab852691ef3..04b4a058b079d56d02fbce94fbbd96e05044c7d2 100644 (file)
@@ -116,8 +116,8 @@ static int orderedsubject_thread_cmp(const struct orderedsubject_thread *t1,
        if (t1->timestamp > t2->timestamp)
                return 1;
 
-       m1 = array_idx(&t1->msgs, 0);
-       m2 = array_idx(&t2->msgs, 0);
+       m1 = array_first(&t1->msgs);
+       m2 = array_first(&t2->msgs);
        if (*m1 < *m2)
                return -1;
        if (*m1 > *m2)
index 5c48b87abe50e923e910d3cbee5e72833d3dcd05..eb72bb0714a1091969af9bb759d1995da61c5083 100644 (file)
@@ -305,7 +305,7 @@ void client_send_mailbox_flags(struct client *client, bool selecting)
                                &status);
 
        keywords = count == 0 ? NULL :
-               array_idx(client->keywords.names, 0);
+               array_first(client->keywords.names);
        str = t_str_new(128);
        str_append(str, "* FLAGS (");
        imap_write_flags(str, status.flags, keywords);
index e8bfc011488a74519a1d8d51d59c3fee6bd35e63..d5d245915150ae70290cae70d748417c72faff12 100644 (file)
@@ -41,7 +41,7 @@ void imap_fetch_handler_unregister(const char *name)
 {
        const struct imap_fetch_handler *handler, *first_handler;
 
-       first_handler = array_idx(&fetch_handlers, 0);
+       first_handler = array_first(&fetch_handlers);
        handler = imap_fetch_handler_lookup(name);
        i_assert(handler != NULL);
        array_delete(&fetch_handlers, handler - first_handler, 1);
@@ -380,7 +380,7 @@ void imap_fetch_begin(struct imap_fetch_context *ctx, struct mailbox *box,
                                 MAIL_FETCH_STREAM_BODY)) == 0)) {
                array_append_zero(&ctx->all_headers);
 
-               headers = array_idx(&ctx->all_headers, 0);
+               headers = array_first(&ctx->all_headers);
                wanted_headers = mailbox_header_lookup_init(box, headers);
                array_delete(&ctx->all_headers,
                             array_count(&ctx->all_headers)-1, 1);
index dc8942a1f19faef006b47ce788576d913b48fee7..d1c39b1d44d76885a9d6d4ef1f412a9b28ef281a 100644 (file)
@@ -205,7 +205,7 @@ void ipc_connection_destroy(struct ipc_connection **_conn,
        DLLIST_REMOVE(&conn->group->connections, conn);
 
        while (array_count(&conn->cmds) > 0) {
-               cmdp = array_idx(&conn->cmds, 0);
+               cmdp = array_first(&conn->cmds);
                cmd = *cmdp;
 
                ipc_connection_cmd_free(&cmd, error);
index c36285d97d68f4dfd06b00a0bc4f13e376050089..7f94a74630a5afcdc86d306b20f89c780f5594e9 100644 (file)
@@ -148,7 +148,7 @@ void ipc_groups_deinit(void)
        struct ipc_group *const *groupp, *group;
 
        while (array_count(&ipc_groups) > 0) {
-               groupp = array_idx(&ipc_groups, 0);
+               groupp = array_first(&ipc_groups);
                group = *groupp;
 
                while ((*groupp)->connections != NULL) {
index d1600dc5d34ac70c373fc5f83051711e3b6e5321..6f5709ca4a1f1904a36ab49a831dffc592a44f34 100644 (file)
@@ -246,7 +246,7 @@ redis_conn_input_more(struct redis_connection *conn, const char **error_r)
                if (line[0] != '*' || str_to_uint(line+1, &num_replies) < 0)
                        break;
 
-               reply = array_idx_modifiable(&dict->replies, 0);
+               reply = array_first_modifiable(&dict->replies);
                i_assert(reply->reply_count > 0);
                if (reply->reply_count != num_replies) {
                        *error_r = t_strdup_printf(
@@ -259,7 +259,7 @@ redis_conn_input_more(struct redis_connection *conn, const char **error_r)
                if (*line != '+' && *line != ':')
                        break;
                /* success, just ignore the actual reply */
-               reply = array_idx_modifiable(&dict->replies, 0);
+               reply = array_first_modifiable(&dict->replies);
                i_assert(reply->reply_count > 0);
                if (--reply->reply_count == 0) {
                        const struct dict_commit_result result = {
index b50a70f72335f45dd62d29e275f1c34f220eaf20..733101d4d4309dab7c2edb69bf0074a499bfbda2 100644 (file)
@@ -90,7 +90,7 @@ fts_filter_normalizer_icu_filter(struct fts_filter *filter, const char **token,
        array_append_zero(&np->utf16_token);
        array_delete(&np->utf16_token, array_count(&np->utf16_token)-1, 1);
        array_clear(&np->trans_token);
-       if (fts_icu_translate(&np->trans_token, array_idx(&np->utf16_token, 0),
+       if (fts_icu_translate(&np->trans_token, array_first(&np->utf16_token),
                              array_count(&np->utf16_token),
                              np->transliterator, error_r) < 0)
                return -1;
@@ -98,7 +98,7 @@ fts_filter_normalizer_icu_filter(struct fts_filter *filter, const char **token,
        if (array_count(&np->trans_token) == 0)
                return 0;
 
-       fts_icu_utf16_to_utf8(np->utf8_token, array_idx(&np->trans_token, 0),
+       fts_icu_utf16_to_utf8(np->utf8_token, array_first(&np->trans_token),
                              array_count(&np->trans_token));
        fts_filter_truncate_token(np->utf8_token, np->filter.max_length);
        *token = str_c(np->utf8_token);
index b6b4c684232eb3af51293589558fc7ea950e09bb..679ac238b509650fd555b803b71617c158d8d662 100644 (file)
@@ -196,7 +196,7 @@ fts_language_list_get_first(struct fts_language_list *list)
 {
        const struct fts_language *const *langp;
 
-       langp = array_idx(&list->languages, 0);
+       langp = array_first(&list->languages);
        return *langp;
 }
 
@@ -307,7 +307,7 @@ fts_language_detect(struct fts_language_list *list,
        /* if there's only a single wanted language, return it always. */
        if (array_count(&list->languages) == 1) {
                const struct fts_language *const *langp =
-                       array_idx(&list->languages, 0);
+                       array_first(&list->languages);
                *lang_r = *langp;
                return FTS_LANGUAGE_RESULT_OK;
        }
index f1b680ae2cb6df625a56fe1a531553d46b14891b..cfc12b91ce7c94cb83a6ed2414eb908a0141eb13 100644 (file)
@@ -244,7 +244,7 @@ http_client_connection_get_timing_info(struct http_client_connection *conn)
        string_t *str = t_str_new(64);
 
        if (array_count(&conn->request_wait_list) > 0) {
-               requestp = array_idx(&conn->request_wait_list, 0);
+               requestp = array_first(&conn->request_wait_list);
 
                str_append(str, "Request ");
                http_client_request_append_stats_text(*requestp, str);
@@ -589,7 +589,7 @@ void http_client_connection_start_request_timeout(
 
        i_assert(array_is_created(&conn->request_wait_list));
        i_assert(array_count(&conn->request_wait_list) > 0);
-       requestp = array_idx(&conn->request_wait_list, 0);
+       requestp = array_first(&conn->request_wait_list);
        timeout_msecs = (*requestp)->attempt_timeout_msecs;
 
        if (timeout_msecs == 0)
index 94b1393083d2a5b7042f40fa85458f100203da5f..22ea1cd28d97490f86aa29b30cf86f9e172cc286 100644 (file)
@@ -451,7 +451,7 @@ int http_message_parse_body(struct http_message_parser *parser, bool request)
                                        && array_is_created(&coding->parameters)
                                        && array_count(&coding->parameters) > 0) {
                                        const struct http_transfer_param *param =
-                                               array_idx(&coding->parameters, 0);
+                                               array_first(&coding->parameters);
 
                                        parser->error_code = HTTP_MESSAGE_PARSE_ERROR_BAD_MESSAGE;
                                        parser->error = t_strdup_printf(
index 0088083ab5df4a54d3d90b37005371f3633ea08a..a76e6068c95164e8de3ee54fd5488677b6013cf7 100644 (file)
@@ -275,7 +275,7 @@ imapc_client_find_connection(struct imapc_client *client)
        /* FIXME: stupid algorithm */
        if (array_count(&client->conns) == 0)
                return imapc_client_add_connection(client)->conn;
-       connp = array_idx(&client->conns, 0);
+       connp = array_first(&client->conns);
        return (*connp)->conn;
 }
 
index c0dd46647198b067e26aa93b7003a92c7e0e7c4d..4eb46f8f35b30336599c15bdc04f7980cc112e39 100644 (file)
@@ -2031,7 +2031,7 @@ static void imapc_command_send_finished(struct imapc_connection *conn,
        cmd->sent = TRUE;
 
        /* everything sent. move command to wait list. */
-       cmdp = array_idx(&conn->cmd_send_queue, 0);
+       cmdp = array_first(&conn->cmd_send_queue);
        i_assert(*cmdp == cmd);
        array_delete(&conn->cmd_send_queue, 0, 1);
        array_append(&conn->cmd_wait_list, &cmd, 1);
@@ -2048,7 +2048,7 @@ imapc_command_get_sending_stream(struct imapc_command *cmd)
        if (!array_is_created(&cmd->streams) || array_count(&cmd->streams) == 0)
                return NULL;
 
-       stream = array_idx_modifiable(&cmd->streams, 0);
+       stream = array_first_modifiable(&cmd->streams);
        if (stream->pos != cmd->send_pos)
                return NULL;
        return stream;
index 172f2c22991cfa73c603a8e71a9236a8cd98c237..3f21343b9b21ca6a550924bacfb92a5624485f49 100644 (file)
@@ -59,7 +59,7 @@ bool imapc_msgmap_uid_to_rseq(struct imapc_msgmap *msgmap,
                return FALSE;
        }
 
-       first = array_idx(&msgmap->uids, 0);
+       first = array_first(&msgmap->uids);
        *rseq_r = (p - first) + 1;
        return TRUE;
 }
index 872c320d9590f35240ac68421d20835590e83203..8e9b36e075ef414087f7573caf5f001b3b489a0e 100644 (file)
@@ -536,7 +536,7 @@ static bool imap_parser_is_next_resp_text(struct imap_parser *parser)
            array_count(parser->cur_list) != 1)
                return FALSE;
 
-       arg = array_idx(&parser->root_list, 0);
+       arg = array_first(&parser->root_list);
        if (arg->type != IMAP_ARG_ATOM)
                return FALSE;
 
index 1cd7050bf7f095a2be0fa3bbdc7a91c0d03084b9..d91ee76141874db54b88480b55957f8281d7279e 100644 (file)
@@ -323,7 +323,7 @@ sync_ext_resize(const struct mail_transaction_ext_intro *u,
                ssize_t diff = (ssize_t)new_padded_hdr_size -
                        (ssize_t)old_padded_hdr_size;
 
-               ext = array_idx_modifiable(&map->extensions, 0);
+               ext = array_first_modifiable(&map->extensions);
                for (i = ext_map_idx + 1; i < count; i++) {
                        ext[i].ext_offset += diff;
                        ext[i].hdr_offset += diff;
index 7354aa19d7d9c884fb183e1c8fe09729e908ec55..894aac6b79edddf573aefa9d6d4e600f600c1339 100644 (file)
@@ -124,7 +124,7 @@ void mail_index_update_day_headers(struct mail_index_transaction *t,
        int i, days;
 
        hdr = *mail_index_get_header(t->view);
-       rec = array_idx(&t->appends, 0);
+       rec = array_first(&t->appends);
 
        stamp = time_to_local_day_start(day_stamp);
        if ((time_t)hdr.day_stamp >= stamp)
index 40e2508ac98ecc2d2d29626b3156d3871ef0d7db..5dc0ed5cf1e34484ee50aba7878433f9918e8232 100644 (file)
@@ -295,7 +295,7 @@ static int view_sync_update_keywords(struct mail_index_view_sync_ctx *ctx,
        kw_idx = array_get(&ctx->lost_new_kw, &count);
        if (count == 0)
                return 0;
-       kw_names = array_idx(&ctx->view->index->keywords, 0);
+       kw_names = array_first(&ctx->view->index->keywords);
 
        i_zero(&thdr);
        thdr.type = MAIL_TRANSACTION_KEYWORD_UPDATE | MAIL_TRANSACTION_EXTERNAL;
index 258e443e1d368d5388aecdb95e3eeeabac5ad17a..6cef4e3aa530c17cb407068866285bffad38a0d9 100644 (file)
@@ -275,7 +275,7 @@ int mail_transaction_log_view_set(struct mail_transaction_log_view *view,
           We're mapping the files in reverse order so that _log_file_map()
           can verify that prev_file_offset matches how far it actually managed
           to sync the file. */
-       files = array_idx(&view->file_refs, 0);
+       files = array_first(&view->file_refs);
        for (i = array_count(&view->file_refs); i > 0; i--) {
                file = files[i-1];
                start_offset = file->hdr.file_seq == min_file_seq ?
index 84c109da8bd2620e98cec12001ddc8a05256ff84..095f59bfd599c6f92005fb62bf88420efaabaca6 100644 (file)
@@ -396,7 +396,7 @@ int mail_deliver_save(struct mail_deliver_context *ctx, const char *mailbox,
                           later on. */
                        i_assert(array_count(&changes.saved_uids) == 1);
                        const struct seq_range *range =
-                               array_idx(&changes.saved_uids, 0);
+                               array_first(&changes.saved_uids);
                        i_assert(range->seq1 == range->seq2);
                        ctx->dest_mail = mail_deliver_open_mail(box, range->seq1,
                                MAIL_FETCH_STREAM_BODY | MAIL_FETCH_GUID, &t);
@@ -653,7 +653,7 @@ mail_deliver_transaction_commit(struct mailbox_transaction_context *ctx,
 
        if (array_count(&changes_r->saved_uids) > 0) {
                const struct seq_range *range =
-                       array_idx(&changes_r->saved_uids, 0);
+                       array_first(&changes_r->saved_uids);
 
                mail_deliver_cache_update_post_commit(box, range->seq1);
        }
index a5a64e29100dd3e1e7e39b39e6c4f2b6e43e5e42..7d288d6500d8f44c09b1ff60fe2d32a2d8d7ef3e 100644 (file)
@@ -65,7 +65,7 @@ const char *const *ldap_entry_get_attribute(const struct ldap_entry *entry, cons
        const struct ldap_attribute *attr;
        array_foreach(&entry->attributes, attr) {
                if (strcasecmp(attr->name, attribute) == 0) {
-                       return array_idx(&attr->values, 0);
+                       return array_first(&attr->values);
                }
        }
        return NULL;
index e6b7c9b5b10a1fefc24fa40a6bb4cf5ac1f87af3..16f2976bd9cb925bd861ba4f36cae4d312d7889e 100644 (file)
@@ -134,7 +134,7 @@ istream_attachment_connector_finish(struct istream_attachment_connector **_conn)
        }
        array_append_zero(&conn->streams);
 
-       inputs = array_idx_modifiable(&conn->streams, 0);
+       inputs = array_first_modifiable(&conn->streams);
        input = i_stream_create_concat(inputs);
 
        istream_attachment_connector_free(conn);
index 822a9c733674b39ca41ab35125ce0f7e63a18929..d5ae772b47e0570c59a67f3e2567339ea623bbae 100644 (file)
@@ -254,7 +254,7 @@ void anvil_client_query_abort(struct anvil_client *client,
        *_query = NULL;
 
        count = aqueue_count(client->queries);
-       queries = array_idx(&client->queries_arr, 0);
+       queries = array_first(&client->queries_arr);
        for (i = 0; i < count; i++) {
                if (queries[aqueue_idx(client->queries, i)] == query) {
                        query->callback = NULL;
index cd35ffb731c62ccef6d9d6e84354f22b4cbea717..221892b5eff6f369bbe8d94cafcd2bead7ebed7c 100644 (file)
@@ -607,7 +607,7 @@ int smtp_reply_parse_next(struct smtp_reply_parser *parser,
 
        parser->state.state = SMTP_REPLY_PARSE_STATE_INIT;
        parser->state.reply->text_lines =
-               array_idx(&parser->state.reply_lines, 0);
+               array_first(&parser->state.reply_lines);
        *reply_r = parser->state.reply;
        return 1;
 }
@@ -651,7 +651,7 @@ int smtp_reply_parse_ehlo(struct smtp_reply_parser *parser,
 
        parser->state.state = SMTP_REPLY_PARSE_STATE_INIT;
        parser->state.reply->text_lines =
-               array_idx(&parser->state.reply_lines, 0);
+               array_first(&parser->state.reply_lines);
        *reply_r = parser->state.reply;
        return 1;
 }
index 998b9ba4860e8a005524d265151ee23596571b4b..1d7c9c8d58c8a7b77258a8374136dd552a77576e 100644 (file)
@@ -135,7 +135,7 @@ void smtp_server_cmd_mail(struct smtp_server_cmd_ctx *cmd,
 
        /* [SP Mail-parameters] */
        if (array_is_created(&conn->mail_param_extensions))
-               param_extensions = array_idx(&conn->mail_param_extensions, 0);
+               param_extensions = array_first(&conn->mail_param_extensions);
        if (smtp_params_mail_parse(cmd->pool, params, caps, param_extensions,
                                   NULL, &mail_data->params, &pperror,
                                   &error) < 0) {
index f9a9a8586f4f0837425ec82b817be1fb7a428279..016825e4a0212765d2811acd0765a573e05bafa3 100644 (file)
@@ -164,7 +164,7 @@ void smtp_server_cmd_rcpt(struct smtp_server_cmd_ctx *cmd,
 
        /* [SP Rcpt-parameters] */
        if (array_is_created(&conn->rcpt_param_extensions))
-               param_extensions = array_idx(&conn->rcpt_param_extensions, 0);
+               param_extensions = array_first(&conn->rcpt_param_extensions);
        if (smtp_params_rcpt_parse(rcpt->pool, params, caps, param_extensions,
                                   &rcpt->params, &pperror, &error) < 0) {
                switch (pperror) {
index 6b554685835a0394f86d8252c5127f4376bccaf2..a744fa0c4fd9e7a2a66807dfe1def6e130f665ff 100644 (file)
@@ -633,7 +633,7 @@ void smtp_server_command_finished(struct smtp_server_command *cmd)
        conn->stats.reply_count++;
 
        i_assert(array_is_created(&cmd->replies));
-       reply = array_idx_modifiable(&cmd->replies, 0);
+       reply = array_first_modifiable(&cmd->replies);
        i_assert(reply->content != NULL);
 
        if (reply->content->status == 221 || reply->content->status == 421) {
index bf33fdabb89d0f0b20d8c8118976f48cd2acfe49..cb5664d726dfa73a25ff6eb24795b3fb27e77908 100644 (file)
@@ -144,7 +144,7 @@ void smtp_server_transaction_write_trace_record(string_t *str,
 
        if (array_count(&trans->rcpt_to) == 1) {
                struct smtp_server_recipient *const *rcpts =
-                       array_idx(&trans->rcpt_to, 0);
+                       array_first(&trans->rcpt_to);
 
                rcpt_to = smtp_address_encode(rcpts[0]->path);
        }
index c87503b17ed5a0653bff0f9007351bba1a2324a6..bf1907de85c229ed03c5a22144dcdeb5591c50b0 100644 (file)
@@ -360,7 +360,7 @@ static void driver_cassandra_close(struct cassandra_db *db, const char *error)
        array_clear(&db->pending_prepares);
 
        while (array_count(&db->results) > 0) {
-               resultp = array_idx(&db->results, 0);
+               resultp = array_first(&db->results);
                if ((*resultp)->error == NULL)
                        (*resultp)->error = i_strdup(error);
                result_finish(*resultp);
@@ -1637,7 +1637,7 @@ driver_cassandra_result_get_values(struct sql_result *_result)
 {
        struct cassandra_result *result = (struct cassandra_result *)_result;
 
-       return array_idx(&result->fields, 0);
+       return array_first(&result->fields);
 }
 
 static const char *driver_cassandra_result_get_error(struct sql_result *_result)
index 071b0ae83851d0a8d2fe5a23022677a742c19a08..98134242c58de9a41830d6f544141f0cfae4793a 100644 (file)
@@ -248,7 +248,7 @@ static void driver_test_exec(struct sql_db *_db, const char *query)
 {
        struct test_sql_db *db = (struct test_sql_db*)_db;
        struct test_driver_result *result =
-               array_idx_modifiable(&db->expected, 0);
+               array_first_modifiable(&db->expected);
        i_assert(result->cur < result->nqueries);
 
 /*     i_debug("DUMMY EXECUTE: %s", query);
@@ -278,7 +278,7 @@ driver_test_query_s(struct sql_db *_db, const char *query)
 {
        struct test_sql_db *db = (struct test_sql_db*)_db;
        struct test_driver_result *result =
-               array_idx_modifiable(&db->expected, 0);
+               array_first_modifiable(&db->expected);
        struct test_sql_result *res = i_new(struct test_sql_result, 1);
 
        driver_test_exec(_db, query);
@@ -353,7 +353,7 @@ driver_test_update(struct sql_transaction_context *ctx, const char *query,
 {
        struct test_sql_db *db= (struct test_sql_db*)ctx->db;
        struct test_driver_result *result =
-               array_idx_modifiable(&db->expected, 0);
+               array_first_modifiable(&db->expected);
        driver_test_exec(ctx->db, query);
 
        if (affected_rows != NULL)
index 696c63e5f010686bc20de8617114d6f9fc161545..687be2950e94f0ae198210ba872153142684f39f 100644 (file)
@@ -538,7 +538,7 @@ static int mdbox_purge_get_primary_files(struct mdbox_purge_context *ctx)
        }
        if (array_count(&ctx->primary_file_ids) > 0) {
                const struct seq_range *range =
-                       array_idx(&ctx->primary_file_ids, 0);
+                       array_first(&ctx->primary_file_ids);
                ctx->lowest_primary_file_id = range[0].seq1;
        }
        if (errno != 0) {
index 0ff8fc3f60d531279c94a2207dad394d8bfec76e..2dede880694b10f32f9f19b9eb5287cc1be87daa 100644 (file)
@@ -331,7 +331,7 @@ int mdbox_transaction_save_commit_pre(struct mail_save_context *_ctx)
                unsigned int highest_pop3_uidl_idx;
                uint32_t uid;
 
-               mails = array_idx(&ctx->mails, 0);
+               mails = array_first(&ctx->mails);
                highest_pop3_uidl_idx =
                        ctx->ctx.highest_pop3_uidl_seq - mails[0].seq;
                i_assert(mails[highest_pop3_uidl_idx].seq == ctx->ctx.highest_pop3_uidl_seq);
index 070cb35120040c3a9280fbc6c543ea6b3dcef354..f87d75e749560e309629fef5b059f4ef3edd1ff0 100644 (file)
@@ -281,7 +281,7 @@ const char *const *index_mail_get_keywords(struct mail *_mail)
        unsigned int i, count, names_count;
 
        if (array_is_created(&data->keywords))
-               return array_idx(&data->keywords, 0);
+               return array_first(&data->keywords);
 
        (void)index_mail_get_keyword_indexes(_mail);
 
@@ -298,7 +298,7 @@ const char *const *index_mail_get_keywords(struct mail *_mail)
 
        /* end with NULL */
        array_append_zero(&data->keywords);
-       return array_idx(&data->keywords, 0);
+       return array_first(&data->keywords);
 }
 
 const ARRAY_TYPE(keyword_indexes) *
index 868fcd090e7c39dabc2662ca52e3d3b4b6b55763..0147a661f4388c8705d1cdf5d2cde8494b175c12 100644 (file)
@@ -1835,7 +1835,7 @@ bool index_storage_search_next_nonblock(struct mail_search_context *_ctx,
        if (!index_sort_list_next(_ctx->sort_program, &seq))
                return FALSE;
 
-       mailp = array_idx(&ctx->mails, 0);
+       mailp = array_first(&ctx->mails);
        mail_set_seq(*mailp, seq);
        index_mail_update_access_parts_pre(*mailp);
        index_mail_update_access_parts_post(*mailp);
index 3c657f47b2dd8ee1dbef9d00f33f44e8f8ba30cf..80797f7c0e92e3497f524bfc2e43c8a37f6f5ea7 100644 (file)
@@ -76,7 +76,7 @@ index_sync_changes_have_expunges(struct index_sync_changes_context *ctx,
        const struct mail_index_sync_rec *syncs;
        unsigned int i;
 
-       syncs = array_idx(&ctx->syncs, 0);
+       syncs = array_first(&ctx->syncs);
        for (i = 0; i < count; i++) {
                if (syncs[i].type == MAIL_INDEX_SYNC_TYPE_EXPUNGE) {
                        memcpy(expunged_guid_128_r, syncs[i].guid_128,
index bc34b26d7e0675a27c2f9a921de67eb811245235..7d0a82595ac7459dbba9f3c000afe3dded8221ee 100644 (file)
@@ -286,7 +286,7 @@ static void mail_thread_root_thread_merge(struct thread_finish_context *ctx,
        } while (root->parent_root_idx1 != 0);
        i_assert(!root->ignore);
 
-       shadows = array_idx_modifiable(&ctx->shadow_nodes, 0);
+       shadows = array_first_modifiable(&ctx->shadow_nodes);
        if (cur->dummy) {
                /* If both messages are dummies, append the current
                    message's children to the children of the message in
@@ -353,7 +353,7 @@ static bool merge_subject_threads(struct thread_finish_context *ctx)
                if (roots[i].parent_root_idx1 != 0 && !roots[i].ignore) {
                        mail_thread_root_thread_merge(ctx, &roots[i]);
                        /* more roots may have been added */
-                       roots = array_idx_modifiable(&ctx->roots, 0);
+                       roots = array_first_modifiable(&ctx->roots);
                        changed = TRUE;
                }
        }
@@ -425,7 +425,7 @@ static void sort_root_nodes_ref2(struct thread_finish_context *ctx,
        roots = array_get_modifiable(&ctx->roots, &root_count);
 
        /* drop childless dummy nodes */
-       shadows = array_idx(&ctx->shadow_nodes, 0);
+       shadows = array_first(&ctx->shadow_nodes);
        for (idx = 1; idx < root_count; idx++) {
                if (roots[idx].dummy &&
                    shadows[roots[idx].node.idx].first_child_idx == 0)
index 3005c421b1e531894e06dc38f2055eaf340d78ea..46dc4f9c98c2fb01eceb1f0033990701b1eec100 100644 (file)
@@ -151,7 +151,7 @@ pop3c_client_async_callback(struct pop3c_client *client,
        i_assert(reply != NULL);
        i_assert(array_count(&client->commands) > 0);
 
-       cmd = array_idx_modifiable(&client->commands, 0);
+       cmd = array_first_modifiable(&client->commands);
        if (cmd->input != NULL && state == POP3C_COMMAND_STATE_OK &&
            !cmd->reading_dot) {
                /* read the full input into seekable-istream before calling
index 0ed88074fd404748a9c154f4b74a57218b2d818a..163bc590782d38add21002fd6dc50aaeea02fbb8 100644 (file)
@@ -146,7 +146,7 @@ struct priorityq_item *priorityq_peek(struct priorityq *pq)
        if (array_count(&pq->items) == 0)
                return NULL;
 
-       items = array_idx(&pq->items, 0);
+       items = array_first(&pq->items);
        return items[0];
 }
 
@@ -167,5 +167,5 @@ struct priorityq_item *const *priorityq_items(struct priorityq *pq)
        if (array_count(&pq->items) == 0)
                return NULL;
 
-       return array_idx(&pq->items, 0);
+       return array_first(&pq->items);
 }
index 6c3930a0c2e99d8792b87d337b851596517b128f..c5df95216bc126bfb3ba020772a38274610da846 100644 (file)
@@ -40,7 +40,7 @@ static void service_process_notify_reset(struct service_process_notify *notify)
        if (notify->io_write == NULL)
                return;
 
-       processes = array_idx_modifiable(&notify->processes, 0);
+       processes = array_first_modifiable(&notify->processes);
        count = aqueue_count(notify->process_queue);
        for (i = 0; i < count; i++) {
                process = processes[aqueue_idx(notify->process_queue, i)];
@@ -57,7 +57,7 @@ static void notify_flush(struct service_process_notify *notify)
        struct service_process *const *processes, *process;
 
        while (aqueue_count(notify->process_queue) > 0) {
-               processes = array_idx_modifiable(&notify->processes, 0);
+               processes = array_first_modifiable(&notify->processes);
                process = processes[aqueue_idx(notify->process_queue, 0)];
 
                if (notify->write_callback(notify->fd, process) < 0) {
index 73792a613934df92ab801ccdd9f845a08f714704..1ad9608b77d3fe8e1f619d94df83510c0c86166f 100644 (file)
@@ -338,7 +338,7 @@ const char *const *acl_cache_get_names(struct acl_cache *cache,
                                       unsigned int *count_r)
 {
        *count_r = array_count(&cache->right_idx_name_map);
-       return array_idx(&cache->right_idx_name_map, 0);
+       return array_first(&cache->right_idx_name_map);
 }
 
 static void
index 5b091b46f37af11654b4f5859ff4265df2e3f171..cd1ee060bf19b54e043e4e1fd2704cf3ec23e7dc 100644 (file)
@@ -489,7 +489,7 @@ int solr_connection_select(struct solr_connection *conn, const char *query,
        hash_table_destroy(&solr_lookup_context.mailboxes);
 
        array_append_zero(&solr_lookup_context.results);
-       *box_results_r = array_idx_modifiable(&solr_lookup_context.results, 0);
+       *box_results_r = array_first_modifiable(&solr_lookup_context.results);
        return parse_ret;
 }
 
index 0cb3da3b0ee08a94ee086e62ff0212b54492c41a..2fd9f883980e595109c24c5822b99e85bba9f7b1 100644 (file)
@@ -278,7 +278,7 @@ fts_expunge_log_export(struct fts_expunge_log_append_ctx *ctx,
                memcpy(rec->guid, mailbox->guid, sizeof(rec->guid));
 
                /* uint32_t expunge_uid_ranges[]; */
-               buffer_append(output, array_idx(&mailbox->uids, 0),
+               buffer_append(output, array_first(&mailbox->uids),
                              array_count(&mailbox->uids) *
                              sizeof(struct seq_range));
                /* uint32_t expunge_count; */
index 77ee38c57b59d1af0529e7db1bb2cabe15fa1cfe..9f1367f777628157e293def98937c57304aa63d6 100644 (file)
@@ -79,7 +79,7 @@ static void test_try_load_keys(void)
                test_assert(strcmp(binary_to_hex(key_id->data, key_id->used), pubid1) == 0);
 
                const struct mail_crypt_global_private_key *key =
-                       array_idx(&keys.private_keys, 0);
+                       array_first(&keys.private_keys);
 
                buffer_set_used_size(key_id, 0);
                test_assert(dcrypt_key_id_private(key->key, MAIL_CRYPT_KEY_ID_ALGORITHM, key_id, &error) == TRUE);
index f75fa09cd90cbdcb0443eecd26afa2e9e63a089c..ddfb862758281b3faed158b4f4dcad0ace2961bc 100644 (file)
@@ -257,7 +257,7 @@ imapc_quota_refresh_update(struct quota *quota,
                return;
        }
        /* use the first quota root for everything */
-       refresh_root = array_idx(&refresh->roots, 0);
+       refresh_root = array_first(&refresh->roots);
 
        array_foreach(&quota->roots, rootp) {
                if ((*rootp)->backend.name == quota_backend_imapc.name) {
@@ -348,7 +348,7 @@ static int imapc_quota_refresh_root(struct imapc_quota_root *root,
           anything we didn't expect. */
        while (array_count(&root->refresh.roots) > 0) {
                const struct imapc_quota_refresh_root *refresh_root =
-                       array_idx(&root->refresh.roots, 0);
+                       array_first(&root->refresh.roots);
                if (strcmp(refresh_root->name, root->root_name) == 0)
                        break;
                array_delete(&root->refresh.roots, 0, 1);
index 5388a2ba50ecdd648e07ad6760ee93cb2b3f2fc9..a4e978c5f0474a15b2e1603721c109f39096477f 100644 (file)
@@ -1078,7 +1078,7 @@ static int virtual_sync_backend_box_sync(struct virtual_sync_context *ctx,
                        if (!virtual_sync_find_seqs(bbox, &sync_rec,
                                                    &idx1, &idx2))
                                break;
-                       uidmap = array_idx(&bbox->uids, 0);
+                       uidmap = array_first(&bbox->uids);
                        for (; idx1 <= idx2; idx1++) {
                                vuid = uidmap[idx1].virtual_uid;
                                if (vuid == 0) {
index 5d41e8be09e4eb04644f58cb6eda715f518ce286..d59d77e5dc9000e36b75c91ece8754b49a9d113b 100644 (file)
@@ -66,7 +66,7 @@ exec_child(struct master_service_connection *conn,
                        env_put(*envs);
         }
 
-       args = array_idx(&exec_args, 0);
+       args = array_first(&exec_args);
        execvp_const(args[0], args);
 }