diff --git a/src/auth/auth-request-handler.c b/src/auth/auth-request-handler.c index ac4578d3aa..97729d84f2 100644 --- a/src/auth/auth-request-handler.c +++ b/src/auth/auth-request-handler.c @@ -859,7 +859,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)]; diff --git a/src/auth/auth-worker-server.c b/src/auth/auth-worker-server.c index a0b16d7657..b8ed2916bd 100644 --- a/src/auth/auth-worker-server.c +++ b/src/auth/auth-worker-server.c @@ -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); } diff --git a/src/auth/db-ldap.c b/src/auth/db-ldap.c index 7a41b6758f..460822a9fa 100644 --- a/src/auth/db-ldap.c +++ b/src/auth/db-ldap.c @@ -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)]; diff --git a/src/config/config-parser.c b/src/config/config-parser.c index 0519644d91..c3bc7649a5 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -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) ; diff --git a/src/dict/dict-commands.c b/src/dict/dict-commands.c index c1b393ebf1..9302c2a8d0 100644 --- a/src/dict/dict-commands.c +++ b/src/dict/dict-commands.c @@ -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; } diff --git a/src/director/director.c b/src/director/director.c index 843f855319..c5661ab765 100644 --- a/src/director/director.c +++ b/src/director/director.c @@ -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); } diff --git a/src/doveadm/doveadm-dsync.c b/src/doveadm/doveadm-dsync.c index 718d5a0c0a..1feed9ffa4 100644 --- a/src/doveadm/doveadm-dsync.c +++ b/src/doveadm/doveadm-dsync.c @@ -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); diff --git a/src/doveadm/doveadm-dump-index.c b/src/doveadm/doveadm-dump-index.c index 1b38de2a4f..250b63a190 100644 --- a/src/doveadm/doveadm-dump-index.c +++ b/src/doveadm/doveadm-dump-index.c @@ -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]]); } diff --git a/src/doveadm/doveadm-kick.c b/src/doveadm/doveadm-kick.c index 03b3cc2f7e..0233583f48 100644 --- a/src/doveadm/doveadm-kick.c +++ b/src/doveadm/doveadm-kick.c @@ -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 { diff --git a/src/doveadm/doveadm-mail-server.c b/src/doveadm/doveadm-mail-server.c index d021584458..4e0466ba56 100644 --- a/src/doveadm/doveadm-mail-server.c +++ b/src/doveadm/doveadm-mail-server.c @@ -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); } diff --git a/src/doveadm/doveadm-mailbox-list-iter.c b/src/doveadm/doveadm-mailbox-list-iter.c index 71179998cb..d76c0cca6d 100644 --- a/src/doveadm/doveadm-mailbox-list-iter.c +++ b/src/doveadm/doveadm-mailbox-list-iter.c @@ -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; } diff --git a/src/doveadm/doveadm-print-formatted.c b/src/doveadm/doveadm-print-formatted.c index 50851cfe04..bd3916cca1 100644 --- a/src/doveadm/doveadm-print-formatted.c +++ b/src/doveadm/doveadm-print-formatted.c @@ -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); } diff --git a/src/doveadm/doveadm-who.c b/src/doveadm/doveadm-who.c index c5a67c0938..d3bd4fd670 100644 --- a/src/doveadm/doveadm-who.c +++ b/src/doveadm/doveadm-who.c @@ -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; } } diff --git a/src/doveadm/dsync/dsync-ibc-pipe.c b/src/doveadm/dsync/dsync-ibc-pipe.c index e9f8ca3719..3d6d2b72e0 100644 --- a/src/doveadm/dsync/dsync-ibc-pipe.c +++ b/src/doveadm/dsync/dsync-ibc-pipe.c @@ -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); diff --git a/src/doveadm/dsync/dsync-mailbox-export.c b/src/doveadm/dsync/dsync-mailbox-export.c index 9cf5e36a4e..8d36300fe0 100644 --- a/src/doveadm/dsync/dsync-mailbox-export.c +++ b/src/doveadm/dsync/dsync-mailbox-export.c @@ -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); } diff --git a/src/imap/cmd-thread.c b/src/imap/cmd-thread.c index 9e109f3a56..04b4a058b0 100644 --- a/src/imap/cmd-thread.c +++ b/src/imap/cmd-thread.c @@ -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) diff --git a/src/imap/imap-commands-util.c b/src/imap/imap-commands-util.c index d7492676ba..a57c64a740 100644 --- a/src/imap/imap-commands-util.c +++ b/src/imap/imap-commands-util.c @@ -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); diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index ed1c51211c..9a2535f2c3 100644 --- a/src/imap/imap-fetch.c +++ b/src/imap/imap-fetch.c @@ -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); diff --git a/src/ipc/ipc-connection.c b/src/ipc/ipc-connection.c index dc8942a1f1..d1c39b1d44 100644 --- a/src/ipc/ipc-connection.c +++ b/src/ipc/ipc-connection.c @@ -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); diff --git a/src/ipc/ipc-group.c b/src/ipc/ipc-group.c index c36285d97d..7f94a74630 100644 --- a/src/ipc/ipc-group.c +++ b/src/ipc/ipc-group.c @@ -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) { diff --git a/src/lib-dict/dict-redis.c b/src/lib-dict/dict-redis.c index d1600dc5d3..6f5709ca4a 100644 --- a/src/lib-dict/dict-redis.c +++ b/src/lib-dict/dict-redis.c @@ -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 = { diff --git a/src/lib-fts/fts-filter-normalizer-icu.c b/src/lib-fts/fts-filter-normalizer-icu.c index b50a70f723..733101d4d4 100644 --- a/src/lib-fts/fts-filter-normalizer-icu.c +++ b/src/lib-fts/fts-filter-normalizer-icu.c @@ -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); diff --git a/src/lib-fts/fts-language.c b/src/lib-fts/fts-language.c index b6b4c68423..679ac238b5 100644 --- a/src/lib-fts/fts-language.c +++ b/src/lib-fts/fts-language.c @@ -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; } diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index d983ab6e1d..5bc3a06582 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -235,7 +235,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); @@ -582,7 +582,7 @@ void http_client_connection_start_request_timeout( i_assert(array_is_created(&conn->request_wait_list)); if (array_count(&conn->request_wait_list) > 0) { struct http_client_request *const *requestp; - requestp = array_idx(&conn->request_wait_list, 0); + requestp = array_first(&conn->request_wait_list); timeout_msecs = (*requestp)->attempt_timeout_msecs; } diff --git a/src/lib-http/http-message-parser.c b/src/lib-http/http-message-parser.c index 94b1393083..22ea1cd28d 100644 --- a/src/lib-http/http-message-parser.c +++ b/src/lib-http/http-message-parser.c @@ -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( diff --git a/src/lib-imap-client/imapc-client.c b/src/lib-imap-client/imapc-client.c index 0088083ab5..a76e6068c9 100644 --- a/src/lib-imap-client/imapc-client.c +++ b/src/lib-imap-client/imapc-client.c @@ -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; } diff --git a/src/lib-imap-client/imapc-connection.c b/src/lib-imap-client/imapc-connection.c index c0dd466471..4eb46f8f35 100644 --- a/src/lib-imap-client/imapc-connection.c +++ b/src/lib-imap-client/imapc-connection.c @@ -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; diff --git a/src/lib-imap-client/imapc-msgmap.c b/src/lib-imap-client/imapc-msgmap.c index 172f2c2299..3f21343b9b 100644 --- a/src/lib-imap-client/imapc-msgmap.c +++ b/src/lib-imap-client/imapc-msgmap.c @@ -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; } diff --git a/src/lib-imap/imap-parser.c b/src/lib-imap/imap-parser.c index 872c320d95..8e9b36e075 100644 --- a/src/lib-imap/imap-parser.c +++ b/src/lib-imap/imap-parser.c @@ -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; diff --git a/src/lib-index/mail-index-sync-ext.c b/src/lib-index/mail-index-sync-ext.c index 1cd7050bf7..d91ee76141 100644 --- a/src/lib-index/mail-index-sync-ext.c +++ b/src/lib-index/mail-index-sync-ext.c @@ -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; diff --git a/src/lib-index/mail-index-transaction-update.c b/src/lib-index/mail-index-transaction-update.c index a1e8d62cad..da3e8ea0a7 100644 --- a/src/lib-index/mail-index-transaction-update.c +++ b/src/lib-index/mail-index-transaction-update.c @@ -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) diff --git a/src/lib-index/mail-index-view-sync.c b/src/lib-index/mail-index-view-sync.c index 40e2508ac9..5dc0ed5cf1 100644 --- a/src/lib-index/mail-index-view-sync.c +++ b/src/lib-index/mail-index-view-sync.c @@ -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; diff --git a/src/lib-index/mail-transaction-log-view.c b/src/lib-index/mail-transaction-log-view.c index 258e443e1d..6cef4e3aa5 100644 --- a/src/lib-index/mail-transaction-log-view.c +++ b/src/lib-index/mail-transaction-log-view.c @@ -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 ? diff --git a/src/lib-lda/mail-deliver.c b/src/lib-lda/mail-deliver.c index 84c109da8b..095f59bfd5 100644 --- a/src/lib-lda/mail-deliver.c +++ b/src/lib-lda/mail-deliver.c @@ -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); } diff --git a/src/lib-ldap/ldap-entry.c b/src/lib-ldap/ldap-entry.c index a5a64e2910..7d288d6500 100644 --- a/src/lib-ldap/ldap-entry.c +++ b/src/lib-ldap/ldap-entry.c @@ -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; diff --git a/src/lib-mail/istream-attachment-connector.c b/src/lib-mail/istream-attachment-connector.c index e6b7c9b5b1..16f2976bd9 100644 --- a/src/lib-mail/istream-attachment-connector.c +++ b/src/lib-mail/istream-attachment-connector.c @@ -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); diff --git a/src/lib-master/anvil-client.c b/src/lib-master/anvil-client.c index 822a9c7336..d5ae772b47 100644 --- a/src/lib-master/anvil-client.c +++ b/src/lib-master/anvil-client.c @@ -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; diff --git a/src/lib-smtp/smtp-reply-parser.c b/src/lib-smtp/smtp-reply-parser.c index cd35ffb731..221892b5ef 100644 --- a/src/lib-smtp/smtp-reply-parser.c +++ b/src/lib-smtp/smtp-reply-parser.c @@ -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; } diff --git a/src/lib-smtp/smtp-server-cmd-mail.c b/src/lib-smtp/smtp-server-cmd-mail.c index 998b9ba486..1d7c9c8d58 100644 --- a/src/lib-smtp/smtp-server-cmd-mail.c +++ b/src/lib-smtp/smtp-server-cmd-mail.c @@ -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) { diff --git a/src/lib-smtp/smtp-server-cmd-rcpt.c b/src/lib-smtp/smtp-server-cmd-rcpt.c index f9a9a8586f..016825e4a0 100644 --- a/src/lib-smtp/smtp-server-cmd-rcpt.c +++ b/src/lib-smtp/smtp-server-cmd-rcpt.c @@ -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) { diff --git a/src/lib-smtp/smtp-server-command.c b/src/lib-smtp/smtp-server-command.c index 6b55468583..a744fa0c4f 100644 --- a/src/lib-smtp/smtp-server-command.c +++ b/src/lib-smtp/smtp-server-command.c @@ -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) { diff --git a/src/lib-smtp/smtp-server-transaction.c b/src/lib-smtp/smtp-server-transaction.c index bf33fdabb8..cb5664d726 100644 --- a/src/lib-smtp/smtp-server-transaction.c +++ b/src/lib-smtp/smtp-server-transaction.c @@ -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); } diff --git a/src/lib-sql/driver-cassandra.c b/src/lib-sql/driver-cassandra.c index c87503b17e..bf1907de85 100644 --- a/src/lib-sql/driver-cassandra.c +++ b/src/lib-sql/driver-cassandra.c @@ -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) diff --git a/src/lib-sql/driver-test.c b/src/lib-sql/driver-test.c index 071b0ae838..98134242c5 100644 --- a/src/lib-sql/driver-test.c +++ b/src/lib-sql/driver-test.c @@ -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) diff --git a/src/lib-storage/index/dbox-multi/mdbox-purge.c b/src/lib-storage/index/dbox-multi/mdbox-purge.c index 696c63e5f0..687be2950e 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-purge.c +++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c @@ -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) { diff --git a/src/lib-storage/index/dbox-multi/mdbox-save.c b/src/lib-storage/index/dbox-multi/mdbox-save.c index 0ff8fc3f60..2dede88069 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-save.c +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c @@ -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); diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 324b52df0a..6e465ad19f 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -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) * diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index 03977a2674..7d0dd5cdde 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -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); diff --git a/src/lib-storage/index/index-sync-changes.c b/src/lib-storage/index/index-sync-changes.c index 3c657f47b2..80797f7c0e 100644 --- a/src/lib-storage/index/index-sync-changes.c +++ b/src/lib-storage/index/index-sync-changes.c @@ -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, diff --git a/src/lib-storage/index/index-thread-finish.c b/src/lib-storage/index/index-thread-finish.c index bc34b26d7e..7d0a82595a 100644 --- a/src/lib-storage/index/index-thread-finish.c +++ b/src/lib-storage/index/index-thread-finish.c @@ -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) diff --git a/src/lib-storage/index/pop3c/pop3c-client.c b/src/lib-storage/index/pop3c/pop3c-client.c index 42a15a2fcd..5265fea7fb 100644 --- a/src/lib-storage/index/pop3c/pop3c-client.c +++ b/src/lib-storage/index/pop3c/pop3c-client.c @@ -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 diff --git a/src/lib/priorityq.c b/src/lib/priorityq.c index 0ed88074fd..163bc59078 100644 --- a/src/lib/priorityq.c +++ b/src/lib/priorityq.c @@ -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); } diff --git a/src/master/service-process-notify.c b/src/master/service-process-notify.c index 6c3930a0c2..c5df95216b 100644 --- a/src/master/service-process-notify.c +++ b/src/master/service-process-notify.c @@ -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(¬ify->processes, 0); + processes = array_first_modifiable(¬ify->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(¬ify->processes, 0); + processes = array_first_modifiable(¬ify->processes); process = processes[aqueue_idx(notify->process_queue, 0)]; if (notify->write_callback(notify->fd, process) < 0) { diff --git a/src/plugins/acl/acl-cache.c b/src/plugins/acl/acl-cache.c index 73792a6139..1ad9608b77 100644 --- a/src/plugins/acl/acl-cache.c +++ b/src/plugins/acl/acl-cache.c @@ -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 diff --git a/src/plugins/fts-solr/solr-connection.c b/src/plugins/fts-solr/solr-connection.c index 947ea76af2..961df1ed36 100644 --- a/src/plugins/fts-solr/solr-connection.c +++ b/src/plugins/fts-solr/solr-connection.c @@ -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; } diff --git a/src/plugins/fts/fts-expunge-log.c b/src/plugins/fts/fts-expunge-log.c index 0cb3da3b0e..2fd9f88398 100644 --- a/src/plugins/fts/fts-expunge-log.c +++ b/src/plugins/fts/fts-expunge-log.c @@ -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; */ diff --git a/src/plugins/mail-crypt/test-mail-global-key.c b/src/plugins/mail-crypt/test-mail-global-key.c index 77ee38c57b..9f1367f777 100644 --- a/src/plugins/mail-crypt/test-mail-global-key.c +++ b/src/plugins/mail-crypt/test-mail-global-key.c @@ -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); diff --git a/src/plugins/quota/quota-imapc.c b/src/plugins/quota/quota-imapc.c index f75fa09cd9..ddfb862758 100644 --- a/src/plugins/quota/quota-imapc.c +++ b/src/plugins/quota/quota-imapc.c @@ -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("a->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); diff --git a/src/plugins/virtual/virtual-sync.c b/src/plugins/virtual/virtual-sync.c index 5388a2ba50..a4e978c5f0 100644 --- a/src/plugins/virtual/virtual-sync.c +++ b/src/plugins/virtual/virtual-sync.c @@ -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) { diff --git a/src/util/script.c b/src/util/script.c index 5d41e8be09..d59d77e5dc 100644 --- a/src/util/script.c +++ b/src/util/script.c @@ -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); }