]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Really change array_idx(A, 0) to array_first(A)
authorAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 10 Jan 2019 10:11:24 +0000 (12:11 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 10 Jan 2019 10:19:25 +0000 (12:19 +0200)
Was only partially done in 27b2b51943e0f9440483abeae4c9f5805b236db9

76 files changed:
src/auth/auth-settings.c
src/auth/db-ldap.c
src/config/config-connection.c
src/config/config-filter.c
src/config/config-parser.c
src/config/doveconf.c
src/director/director-connection.c
src/director/director-request.c
src/dns/dns-client.c
src/doveadm/doveadm-cmd.c
src/doveadm/doveadm-dsync.c
src/doveadm/doveadm-mail-fetch.c
src/doveadm/doveadm-mail-flags.c
src/doveadm/doveadm-mail.c
src/doveadm/dsync/dsync-brain-mailbox.c
src/doveadm/dsync/dsync-mailbox-import.c
src/imap-urlauth/imap-urlauth-worker.c
src/imap/cmd-list.c
src/imap/imap-client.c
src/imap/imap-commands-util.c
src/imap/imap-fetch.c
src/lib-auth/auth-master.c
src/lib-dict-backend/dict-ldap.c
src/lib-fts/fts-icu.c
src/lib-fts/test-fts-icu.c
src/lib-imap-storage/imap-msgpart.c
src/lib-imap/imap-match.c
src/lib-index/mail-index-fsck.c
src/lib-index/mail-index-sync.c
src/lib-ldap/ldap-entry.c
src/lib-ldap/ldap-search.c
src/lib-mail/message-part-data.c
src/lib-mail/rfc2231-parser.c
src/lib-master/master-service-settings.c
src/lib-master/master-service.c
src/lib-program-client/program-client-local.c
src/lib-settings/settings-parser.c
src/lib-smtp/smtp-submit.c
src/lib-smtp/smtp-syntax.c
src/lib-sql/driver-sqlpool.c
src/lib-storage/index/dbox-multi/mdbox-map.c
src/lib-storage/index/imapc/imapc-mail-fetch.c
src/lib-storage/index/imapc/imapc-mailbox.c
src/lib-storage/index/index-mail-headers.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-search.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-thread-finish.c
src/lib-storage/index/pop3c/pop3c-sync.c
src/lib-storage/list/mailbox-list-fs-iter.c
src/lib-storage/mail-search.c
src/lib-storage/mail-storage-settings.c
src/lib-storage/mailbox-get.c
src/lib-storage/test-mail-storage.c
src/lib/event-filter.c
src/lib/strfuncs.c
src/lib/test-array.c
src/lib/test-seq-range-array.c
src/lib/var-expand-if.c
src/lib/var-expand.c
src/login-common/client-common-auth.c
src/plugins/acl/acl-api.c
src/plugins/apparmor/apparmor-plugin.c
src/plugins/expire/doveadm-expire.c
src/plugins/expire/expire-plugin.c
src/plugins/fts-lucene/fts-backend-lucene.c
src/plugins/fts-solr/fts-backend-solr-old.c
src/plugins/fts-solr/fts-backend-solr.c
src/plugins/fts-squat/squat-uidlist.c
src/plugins/fts/fts-search.c
src/plugins/fts/fts-storage.c
src/plugins/fts/fts-user.c
src/plugins/imap-acl/imap-acl-plugin.c
src/plugins/virtual/virtual-save.c
src/plugins/virtual/virtual-sync.c
src/util/script.c

index a38d63efcd0a7b668e2a469749c7762027034a0d..5af4f9080840b7cee7a206e20859153e6e42c627 100644 (file)
@@ -380,7 +380,7 @@ auth_settings_set_self_ips(struct auth_settings *set, pool_t pool,
                array_append(&ips_array, ips, ips_count);
        }
        array_append_zero(&ips_array);
-       set->proxy_self_ips = array_idx(&ips_array, 0);
+       set->proxy_self_ips = array_first(&ips_array);
        return TRUE;
 }
 
index 9cdf8a392034a8480c9f6f13be7c4b24efb28cdf..5a75f4413f35f523f0b8f251f76f68dcc17d6d7b 100644 (file)
@@ -651,7 +651,7 @@ ldap_request_send_subquery(struct ldap_connection *conn,
                if (field->ldap_attr_name[0] == '\0') {
                        str_truncate(tmp_str, 0);
                        if (var_expand_with_funcs(tmp_str, field->value, table,
-                                                 array_idx(&var_funcs_table, 0), &ctx, &error) <= 0) {
+                                                 array_first(&var_funcs_table), &ctx, &error) <= 0) {
                                auth_request_log_error(auth_request,
                                        AUTH_SUBSYS_DB,
                                        "Failed to expand subquery %s: %s",
@@ -672,7 +672,7 @@ ldap_request_send_subquery(struct ldap_connection *conn,
 
        request->request.msgid =
                ldap_search(conn->ld, named_res->dn, LDAP_SCOPE_BASE,
-                           NULL, array_idx_modifiable(&ctx.attr_names, 0), 0);
+                           NULL, array_first_modifiable(&ctx.attr_names), 0);
        if (request->request.msgid == -1) {
                auth_request_log_error(auth_request, AUTH_SUBSYS_DB,
                                       "ldap_search(dn=%s) failed: %s",
@@ -1467,7 +1467,7 @@ void db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist,
                }
        }
        array_append_zero(&ctx.attr_names);
-       *attr_names_r = array_idx_modifiable(&ctx.attr_names, 0);
+       *attr_names_r = array_first_modifiable(&ctx.attr_names);
 }
 
 static const struct var_expand_table *
index f3522f1060918fcf15e73dec4018d7f8a0f4ac91..2d11b49d63b994de6a329c751108540d10f85605 100644 (file)
@@ -103,7 +103,7 @@ static int config_connection_request(struct config_connection *conn,
        }
        array_append_zero(&modules);
        wanted_modules = array_count(&modules) == 1 ? NULL :
-               array_idx(&modules, 0);
+               array_first(&modules);
 
        if (is_master) {
                /* master reads configuration only when reloading settings */
index 9e238dc6868d2d9a5bf52451c15d6b9092ac82b0..2908da02626d96bad9547a4961f5d9afa58d6822 100644 (file)
@@ -244,12 +244,12 @@ config_filter_find_all(struct config_filter_context *ctx, pool_t pool,
        }
        if (filter->service == NULL) {
                array_append_zero(&service_names);
-               output_r->specific_services = array_idx(&service_names, 0);
+               output_r->specific_services = array_first(&service_names);
        }
 
        array_sort(&matches, config_filter_parser_cmp);
        array_append_zero(&matches);
-       return array_idx(&matches, 0);
+       return array_first(&matches);
 }
 
 struct config_filter_parser *const *
@@ -264,7 +264,7 @@ config_filter_get_all(struct config_filter_context *ctx)
        }
        array_sort(&filters, config_filter_parser_cmp_rev);
        array_append_zero(&filters);
-       return array_idx(&filters, 0);
+       return array_first(&filters);
 }
 
 struct config_filter_parser *const *
@@ -297,7 +297,7 @@ config_filter_find_subset(struct config_filter_context *ctx,
        }
        array_sort(&matches, config_filter_parser_cmp_rev);
        array_append_zero(&matches);
-       return array_idx(&matches, 0);
+       return array_first(&matches);
 }
 
 static bool
index 1ac1eebaeb5c1c8795641108533c208cfd39facf..42310dc4ff1af49393c7cd2710759f2fd7ba325c 100644 (file)
@@ -1108,7 +1108,7 @@ void config_parse_load_modules(void)
                for (i = 0; all_roots[i] != NULL; i++)
                        array_append(&new_roots, &all_roots[i], 1);
                array_append_zero(&new_roots);
-               all_roots = array_idx(&new_roots, 0);
+               all_roots = array_first(&new_roots);
                roots_free_at_deinit = new_roots;
        } else {
                array_free(&new_roots);
index 6307c2842edb67b49f5d836d0e331ae16b8892c4..10896cabfe464ab16e20e996f45d60d486c68946 100644 (file)
@@ -938,7 +938,7 @@ int main(int argc, char *argv[])
        }
        array_append_zero(&module_names);
        wanted_modules = array_count(&module_names) == 1 ? NULL :
-               array_idx(&module_names, 0);
+               array_first(&module_names);
 
        config_path = master_service_get_config_path(master_service);
        /* use strcmp() instead of !=, because dovecot -n always gives us
index a694e79f62b4e084549311c2f995ed0742c911bb..9d24a5b3be256933e18c99fb53534aa1d427aef8 100644 (file)
@@ -942,7 +942,7 @@ director_cmd_host_hand_start(struct director_connection *conn,
                          conn->name);
                hosts = mail_hosts_get(conn->dir->mail_hosts);
                while (array_count(hosts) > 0) {
-                       hostp = array_idx(hosts, 0);
+                       hostp = array_first(hosts);
                        director_remove_host(conn->dir, NULL, NULL, *hostp);
                }
        } else if (remote_ring_completed == 0 && conn->dir->ring_handshaked) {
index b73259132c6ee92abf2b6b9ae1b2159e3f4e0a9d..f241330eb8b6608107d78a6fbcb5395f7eec5630 100644 (file)
@@ -89,7 +89,7 @@ static void director_request_timeout(struct director *dir)
        string_t *str = t_str_new(128);
 
        while (array_count(&dir->pending_requests) > 0) {
-               requestp = array_idx_modifiable(&dir->pending_requests, 0);
+               requestp = array_first_modifiable(&dir->pending_requests);
                request = *requestp;
 
                if (request->create_time +
index 82df442c4b199dc90ef1133174e037e938fa938a..3716b04249d706a07e76f0707541713144786d3d 100644 (file)
@@ -71,9 +71,9 @@ static int dns_client_input_args(struct connection *client, const char *const *a
                        }
                        array_append_zero(&tmp);
                        e_debug(e->event(), "Resolve success: %s",
-                               t_strarray_join(array_idx(&tmp, 0), ", "));
+                               t_strarray_join(array_first(&tmp), ", "));
                        o_stream_nsend_str(client->output,
-                                          t_strarray_join(array_idx(&tmp, 0), "\t"));
+                                          t_strarray_join(array_first(&tmp), "\t"));
                        o_stream_nsend_str(client->output, "\n");
                }
        } else if (strcmp(args[0], "NAME") == 0) {
index 2fcd5fdef16a0b740a271f3cf54231785a2b4b4c..eb377d1312d75128f3a3d3a8ecf6cf642109a58d 100644 (file)
@@ -522,7 +522,7 @@ int doveadm_cmd_run_ver2(int argc, const char *const argv[],
        }
        i_assert(pargc == array_count(&opts)-1); /* opts is NULL-terminated */
 
-       while((c = getopt_long(argc, (char*const*)argv, str_c(optbuf), array_idx(&opts, 0), &li)) > -1) {
+       while((c = getopt_long(argc, (char*const*)argv, str_c(optbuf), array_first(&opts), &li)) > -1) {
                switch(c) {
                case 0:
                        for(unsigned int i = 0; i < array_count(&pargv); i++) {
index 9a5054c9f4e2c3bcef3984558b3132107d7ae677..97134d2190351f7b3c572a9a066d62a59d646a64 100644 (file)
@@ -223,7 +223,7 @@ mirror_get_remote_cmd_line(const char *const *argv,
        }
        array_append(&cmd_args, &p, 1);
        array_append_zero(&cmd_args);
-       *cmd_args_r = array_idx(&cmd_args, 0);
+       *cmd_args_r = array_first(&cmd_args);
 }
 
 static const char *const *
@@ -273,7 +273,7 @@ get_ssh_cmd_args(const char *host, const char *login, const char *mail_user)
                array_append(&cmd_args, &value, 1);
        }
        array_append_zero(&cmd_args);
-       return array_idx(&cmd_args, 0);
+       return array_first(&cmd_args);
 }
 
 static bool mirror_get_remote_cmd(struct dsync_cmd_context *ctx,
index 52e613459baacc084a4e0d38e3ce9e7d0c105541..bf8396ba10675ebcf795aa375f7624376f0cb3a4 100644 (file)
@@ -606,7 +606,7 @@ cmd_fetch_box(struct fetch_cmd_context *ctx, const struct mailbox_info *info)
 
        if (doveadm_mail_iter_init(&ctx->ctx, info, ctx->ctx.search_args,
                                   ctx->wanted_fields,
-                                  array_idx(&ctx->header_fields, 0),
+                                  array_first(&ctx->header_fields),
                                   FALSE,
                                   &iter) < 0)
                return -1;
index ead7079ddfe17207f63835a748a901627e996072..c4abd1afbab4af430058cbe7bfc5641f27bc7160 100644 (file)
@@ -108,7 +108,7 @@ static void cmd_flags_init(struct doveadm_mail_cmd_context *_ctx,
        }
        if (array_count(&keywords) > 0 || ctx->modify_type == MODIFY_REPLACE) {
                array_append_zero(&keywords);
-               ctx->keywords = array_idx(&keywords, 0);
+               ctx->keywords = array_first(&keywords);
        }
 
        _ctx->search_args = doveadm_mail_build_search_args(args+1);
index c93cbef079337aaa3e236d35739c27dd5e970fd0..23cb32a46ff098dfa16fb39e068ab0c1d8abf89e 100644 (file)
@@ -1138,7 +1138,7 @@ doveadm_cmd_ver2_to_mail_cmd_wrapper(struct doveadm_cmd_context *cctx)
        array_append_array(&full_args, &pargv);
 
        mctx->args = array_idx(&full_args, args_pos);
-       mctx->full_args = array_idx(&full_args, 0);
+       mctx->full_args = array_first(&full_args);
 
        doveadm_mail_cmd_exec(mctx, wildcard_user);
        doveadm_mail_cmd_free(mctx);
index bd8d454aaf41e3d94c76c76554a1fa5558ed6ccf..c87bb6a92b43584218826c240652af0834d3661a 100644 (file)
@@ -644,7 +644,7 @@ dsync_cache_fields_update(const struct dsync_mailbox *local_box,
        if (array_count(&local_sorted) == 0) {
                /* local has no cached fields. set them to same as remote. */
                array_append_zero(&remote_sorted);
-               update->cache_updates = array_idx(&remote_sorted, 0);
+               update->cache_updates = array_first(&remote_sorted);
                return;
        }
 
@@ -689,7 +689,7 @@ dsync_cache_fields_update(const struct dsync_mailbox *local_box,
        i_assert(li == local_count && ri == remote_count);
        if (array_count(&changes) > 0) {
                array_append_zero(&changes);
-               update->cache_updates = array_idx(&changes, 0);
+               update->cache_updates = array_first(&changes);
        }
 }
 
index e6a8f9b44e8e3164ba0f6ac84c71f904aad6fdf2..707fcc556326641c9c3803703814cd60114a0894 100644 (file)
@@ -1185,14 +1185,14 @@ merge_keywords(struct mail *mail, const ARRAY_TYPE(const_string) *local_changes,
        if (array_count(&add_keywords) > 0) {
                array_append_zero(&add_keywords);
                kw = mailbox_keywords_create_valid(mail->box,
-                       array_idx(&add_keywords, 0));
+                       array_first(&add_keywords));
                mail_update_keywords(mail, MODIFY_ADD, kw);
                mailbox_keywords_unref(&kw);
        }
        if (array_count(&remove_keywords) > 0) {
                array_append_zero(&remove_keywords);
                kw = mailbox_keywords_create_valid(mail->box,
-                       array_idx(&remove_keywords, 0));
+                       array_first(&remove_keywords));
                mail_update_keywords(mail, MODIFY_REMOVE, kw);
                mailbox_keywords_unref(&kw);
        }
@@ -1228,7 +1228,7 @@ dsync_mailbox_import_replace_flags(struct mail *mail,
        }
        array_append_zero(&keywords);
 
-       kw = mailbox_keywords_create_valid(mail->box, array_idx(&keywords, 0));
+       kw = mailbox_keywords_create_valid(mail->box, array_first(&keywords));
        mail_update_keywords(mail, MODIFY_REPLACE, kw);
        mailbox_keywords_unref(&kw);
 
@@ -2324,7 +2324,7 @@ dsync_mailbox_get_final_keywords(const struct dsync_mail_change *change)
                return NULL;
 
        array_append_zero(&keywords);
-       return array_idx(&keywords, 0);
+       return array_first(&keywords);
 }
 
 static void
index 23a483d8283152df0d9a712148aba8e8cdc3f76d..41819e0a06f822e4b4dccf8272f079cbe2f1d128 100644 (file)
@@ -1014,7 +1014,8 @@ int main(int argc, char *argv[])
                T_BEGIN {
                        if (array_count(&access_apps) > 0) {
                                (void)array_append_space(&access_apps);
-                               main_stdio_run(access_user, array_idx(&access_apps,0));
+                               main_stdio_run(access_user,
+                                              array_first(&access_apps));
                        } else {
                                main_stdio_run(access_user, NULL);
                        }
index be3a868621255f76b24658ae33f51a0981973c40..dd61190a2337f0ef96148ee892c8dd5eba6c3dde 100644 (file)
@@ -291,7 +291,7 @@ list_get_ref_patterns(struct cmd_list_context *ctx, const char *ref,
                array_append(&full_patterns, &pattern, 1);
        }
        array_append_zero(&full_patterns); /* NULL-terminate */
-       return array_idx(&full_patterns, 0);
+       return array_first(&full_patterns);
 }
 
 static void cmd_list_init(struct cmd_list_context *ctx,
@@ -455,7 +455,7 @@ bool cmd_list_full(struct client_command_context *cmd, bool lsub)
        }
 
        array_append_zero(&patterns); /* NULL-terminate */
-       patterns_strarr = array_idx(&patterns, 0);
+       patterns_strarr = array_first(&patterns);
        if (!ctx->used_listext && !lsub && *patterns_strarr[0] == '\0') {
                /* Only LIST ref "" gets us here */
                cmd_list_ref_root(client, ref);
index 078a1259b9599e142c442f7e10a3703129a9f8bf..f51458a0f155a2ebcb1a48bb536a0de320d1049a 100644 (file)
@@ -1539,7 +1539,7 @@ const char *const *client_enabled_features(struct client *client)
                }
        }
        array_append_zero(&feature_strings);
-       return array_idx(&feature_strings, 0);
+       return array_first(&feature_strings);
 }
 
 struct imap_search_update *
index a57c64a740948049d7e2fa91d3354cc0505e952a..eadc7c68c3fdd085996c708e53f99b83de373c8e 100644 (file)
@@ -283,7 +283,7 @@ bool client_parse_mail_flags(struct client_command_context *cmd,
                *keywords_r = NULL;
        else {
                array_append_zero(&keywords); /* NULL-terminate */
-               *keywords_r = array_idx(&keywords, 0);
+               *keywords_r = array_first(&keywords);
        }
        return TRUE;
 }
@@ -360,7 +360,7 @@ client_get_keyword_names(struct client *client, ARRAY_TYPE(keywords) *dest,
        }
 
        array_append_zero(dest);
-       return array_idx(dest, 0);
+       return array_first(dest);
 }
 
 void msgset_generator_init(struct msgset_generator_context *ctx, string_t *str)
index 38a6fe05557ed1a4ea63eb3378396ebbcc59a690..262dbbaea2465868a496012cd42edec4a8e1fd9e 100644 (file)
@@ -200,7 +200,7 @@ expunges_drop_known(struct mailbox *box,
        unsigned int i, count;
 
        seqs = array_get(qresync_args->qresync_sample_seqset, &count);
-       uids = array_idx(qresync_args->qresync_sample_uidset, 0);
+       uids = array_first(qresync_args->qresync_sample_uidset);
        i_assert(array_count(qresync_args->qresync_sample_uidset) == count);
        i_assert(count > 0);
 
index c671654067e29d84c1013d0cd7f5afaf3ae120a8..e251c082d2a5bf1cc3821644249163229eec1539 100644 (file)
@@ -185,7 +185,7 @@ static const char *const *args_hide_passwords(const char *const *args)
                }
        }
        array_append_zero(&new_args);
-       return array_idx(&new_args, 0);
+       return array_first(&new_args);
 }
 
 static bool auth_lookup_reply_callback(const char *cmd, const char *const *args,
index f504833f1c60729678a848189fc16e68a33c26c2..64471c6f3123703612295ffbf9725be7f97e1f19 100644 (file)
@@ -222,7 +222,7 @@ ldap_dict_build_query(struct ldap_dict *dict, const struct dict_ldap_map *map,
 
        array_append_zero(&exp);
 
-       if (var_expand(query_r, template, array_idx(&exp, 0), &error) <= 0) {
+       if (var_expand(query_r, template, array_first(&exp), &error) <= 0) {
                *error_r = t_strdup_printf("Failed to expand %s: %s", template, error);
                return FALSE;
        }
index 7dcd548cb2720119f70f003a0c3f52ff82a41c24..f72b77758f611199c82e0da0707cf3b46cac63bf 100644 (file)
@@ -184,9 +184,9 @@ int fts_icu_transliterator_create(const char *id,
 
        t_array_init(&id_utf16, strlen(id));
        fts_icu_utf8_to_utf16(&id_utf16, id);
-       *transliterator_r = utrans_openU(array_idx(&id_utf16, 0),
-                                       array_count(&id_utf16),
-                                       UTRANS_FORWARD, NULL, 0, &perr, &err);
+       *transliterator_r = utrans_openU(array_first(&id_utf16),
+                                        array_count(&id_utf16),
+                                        UTRANS_FORWARD, NULL, 0, &perr, &err);
        if (U_FAILURE(err)) {
                string_t *str = t_str_new(128);
 
index cdf79c32d65c77e2fe0a14d62fcd6b9e3378b6b1..ad8ec10986afed477f52156b5669b08207ee26ef 100644 (file)
@@ -87,7 +87,8 @@ static UTransliterator *get_translit(const char *id)
 
        t_array_init(&id_utf16, 8);
        fts_icu_utf8_to_utf16(&id_utf16, id);
-       translit = utrans_openU(array_idx(&id_utf16, 0), array_count(&id_utf16),
+       translit = utrans_openU(array_first(&id_utf16),
+                               array_count(&id_utf16),
                                UTRANS_FORWARD, NULL, 0, &perr, &err);
        test_assert(!U_FAILURE(err));
        return translit;
@@ -133,7 +134,7 @@ static void test_fts_icu_translate_resize(void)
                fts_icu_utf8_to_utf16(&src_utf16, src_utf8);
                t_array_init(&dest, i);
                test_assert(buffer_get_writable_size(dest.arr.buffer) == i*2);
-               test_assert(fts_icu_translate(&dest, array_idx(&src_utf16, 0),
+               test_assert(fts_icu_translate(&dest, array_first(&src_utf16),
                                              array_count(&src_utf16),
                                              translit, &error) == 0);
        }
index 20aff041ca7c430d699ca4402a254e0cd9febf9a..80bc7602f9496eb7fdd9cd24357ae203c9e576b1 100644 (file)
@@ -192,7 +192,7 @@ imap_msgpart_parse_header_fields(struct imap_msgpart *msgpart,
                return -1;
 
        array_append_zero(&fields);
-       msgpart->headers = array_idx(&fields, 0);
+       msgpart->headers = array_first(&fields);
        return 0;
 }
 
index 076635f7c17037337e9d5de3448fbc225dba9a72..0ac5fa2fc8a84adb2890bfdeaa89cc7887952c8f 100644 (file)
@@ -193,7 +193,7 @@ imap_match_dup_real(pool_t pool, const struct imap_match_glob *glob)
                array_append(&patterns, &p->pattern, 1);
        }
        array_append_zero(&patterns);
-       return imap_match_init_multiple_real(pool, array_idx(&patterns, 0),
+       return imap_match_init_multiple_real(pool, array_first(&patterns),
                                             inboxcase, glob->sep);
 }
 
index f001eaff065bf02ef2f6015ef835adf9f6dc4402..4a1f956ce8e04be2b3e089ef08cc15e152a1d531 100644 (file)
@@ -197,7 +197,7 @@ mail_index_fsck_keywords(struct mail_index *index, struct mail_index_map *map,
 
        /* give new names to invalid keywords */
        changed_count = 0;
-       name_array = array_idx_modifiable(&names, 0);
+       name_array = array_first_modifiable(&names);
        for (i = j = 0; i < keywords_count; i++) {
                while (name_array[i][0] == '\0') {
                        name = t_strdup_printf("unknown-%d", j++);
index 40fac37fd7ec935ccd98b067f25f1f576f321ec7..c48b12500091743866886a16310f98c474149e46 100644 (file)
@@ -220,7 +220,7 @@ mail_index_sync_read_and_sort(struct mail_index_sync_ctx *ctx)
        }
 
        keyword_updates = keyword_count == 0 ? NULL :
-               array_idx(&sync_trans->keyword_updates, 0);
+               array_first(&sync_trans->keyword_updates);
        for (i = 0; i < keyword_count; i++) {
                if (array_is_created(&keyword_updates[i].add_seq)) {
                        synclist = array_append_space(&ctx->sync_list);
index 7d288d6500d8f44c09b1ff60fe2d32a2d8d7ef3e..cc437e5bae95133f733d967c2cbf64d2aa633017 100644 (file)
@@ -45,7 +45,7 @@ int ldap_entry_init(struct ldap_entry *obj, struct ldap_result *result,
        ber_free(bptr, 0);
 
        array_append_zero(&attr_names);
-       obj->attr_names = array_idx(&attr_names, 0);
+       obj->attr_names = array_first(&attr_names);
 
        return 0;
 }
index 9f217976a66ec803410221144e020c6ff810d6b0..9a5d481e0b22ecf45bbfaf7c756eec6160ea6ccf 100644 (file)
@@ -157,7 +157,7 @@ void ldap_connection_search_start(struct ldap_connection *conn,
                        array_append(&arr, &tmp, 1);
                }
                array_append_zero(&arr);
-               req->input.search.attributes = array_idx_modifiable(&arr, 0);
+               req->input.search.attributes = array_first_modifiable(&arr);
        }
 
        req->send_request_cb = ldap_search_send;
index 1263ab30dda1f92d40ed764f4457458390f379db..74766fb77a2bffbd975748b1ca0505b0f27aad74 100644 (file)
@@ -399,7 +399,7 @@ parse_content_language(struct message_part_data *data,
        if (array_count(&langs) > 0) {
                array_append_zero(&langs);
                data->content_language =
-                       p_strarray_dup(pool, array_idx(&langs, 0));
+                       p_strarray_dup(pool, array_first(&langs));
        }
 }
 
index 6aa25470a3d7e497c4690d180fee40920f0578b6..4f154998082529ecb81cf9647abbddd08bf9d4f1 100644 (file)
@@ -108,7 +108,7 @@ int rfc2231_parse(struct rfc822_parser_context *ctx,
        if (array_count(&rfc2231_params_arr) == 0) {
                /* No RFC 2231 parameters */
                array_append_zero(&result); /* NULL-terminate */
-               *result_r = array_idx(&result, 0);
+               *result_r = array_first(&result);
                return broken ? -1 : 0;
        }
 
@@ -174,6 +174,6 @@ int rfc2231_parse(struct rfc822_parser_context *ctx,
                }
        }
        array_append_zero(&result); /* NULL-terminate */
-       *result_r = array_idx(&result, 0);
+       *result_r = array_first(&result);
        return broken ? -1 : 0;
 }
index c2e79af66fe8a33b7e6b01959155d7dfed42e68f..0cbb1b2c61fb5246b11d4e45e0f0b381ebc459e0 100644 (file)
@@ -167,11 +167,11 @@ static int parse_query(const char *str, struct event_filter_query *query_r,
 
        if (array_is_created(&categories)) {
                array_append_zero(&categories);
-               query_r->categories = array_idx(&categories, 0);
+               query_r->categories = array_first(&categories);
        }
        if (array_is_created(&fields)) {
                array_append_zero(&fields);
-               query_r->fields = array_idx(&fields, 0);
+               query_r->fields = array_first(&fields);
        }
        return 0;
 }
@@ -544,7 +544,7 @@ config_read_reply_header(struct istream *istream, const char *path, pool_t pool,
                }
                if (input->service == NULL) {
                        array_append_zero(&services);
-                       output_r->specific_services = array_idx(&services, 0);
+                       output_r->specific_services = array_first(&services);
                }
        } T_END;
        return 0;
@@ -617,7 +617,7 @@ int master_service_settings_get_filters(struct master_service *service,
        }
 
        array_append_zero(&filters_tmp);
-       *filters = array_idx(&filters_tmp, 0);
+       *filters = array_first(&filters_tmp);
        return 0;
 }
 
@@ -686,7 +686,7 @@ int master_service_settings_read(struct master_service *service,
        }
 
        parser = settings_parser_init_list(service->set_pool,
-                       array_idx(&all_roots, 0), array_count(&all_roots),
+                       array_first(&all_roots), array_count(&all_roots),
                        SETTINGS_PARSER_FLAG_IGNORE_UNKNOWN_KEYS);
 
        if (fd != -1) {
index 3fa86f1f9af6f1123cc020e6693949eff3b30d35..39454c5eac5633b99f7ddd9c789f9cf017975e68 100644 (file)
@@ -656,7 +656,7 @@ static void master_service_import_environment_real(const char *import_environmen
        }
        array_append_zero(&keys);
 
-       value = t_strarray_join(array_idx(&keys, 0), " ");
+       value = t_strarray_join(array_first(&keys), " ");
        env_put(t_strconcat(DOVECOT_PRESERVE_ENVS_ENV"=", value, NULL));
 }
 
index 0a924e40f8b197fdcd97545b1b652df4bf21c028..29ff1f2bdcf264638a8ea9a8f57d71856c0f012e 100644 (file)
@@ -130,7 +130,7 @@ exec_child(const char *bin_path, const char *const *args,
 
        /* Execute */
 
-       args = array_idx(&exec_args, 0);
+       args = array_first(&exec_args);
        execvp_const(args[0], args);
 }
 
index 458b40e6c6a99a85eb28a65c7e503ab303374ddd..8e4b5bc828e109b0f68edd7dd1735bcba53acf37 100644 (file)
@@ -1558,7 +1558,7 @@ setting_copy(enum setting_type type, const void *src, void *dest, pool_t pool,
                i_assert(dest_count % 2 == 0);
                for (i = 0; i < count; i += 2) {
                        if (dest_count > 0) {
-                               dest_strings = array_idx(dest_arr, 0);
+                               dest_strings = array_first(dest_arr);
                                for (j = 0; j < dest_count; j += 2) {
                                        if (strcmp(strings[i], dest_strings[j]) == 0)
                                                break;
@@ -1722,7 +1722,7 @@ info_update_real(pool_t pool, struct setting_parser_info *parent,
        }
        new_defines = p_new(pool, struct setting_define,
                            array_count(&defines) + 1);
-       memcpy(new_defines, array_idx(&defines, 0),
+       memcpy(new_defines, array_first(&defines),
               sizeof(*parent->defines) * array_count(&defines));
        parent->defines = new_defines;
 
@@ -1756,7 +1756,7 @@ info_update_real(pool_t pool, struct setting_parser_info *parent,
        parent->dynamic_parsers =
                p_new(pool, struct dynamic_settings_parser,
                      array_count(&dynamic_parsers) + 1);
-       memcpy(parent->dynamic_parsers, array_idx(&dynamic_parsers, 0),
+       memcpy(parent->dynamic_parsers, array_first(&dynamic_parsers),
               sizeof(*parent->dynamic_parsers) *
               array_count(&dynamic_parsers));
        parent->struct_size = new_struct_size;
index 428eb6ff19aea30691cf177ed3a43941d16109a3..7e9b89aeb2be6164800ce0730d9a4a96e32ea5b2 100644 (file)
@@ -387,7 +387,7 @@ smtp_submit_send_sendmail(struct smtp_submit *subm)
        restrict_access_init(&pc_set.restrict_set);
 
        pc = program_client_local_create
-               (sendmail_bin, array_idx(&args, 0), &pc_set);
+               (sendmail_bin, array_first(&args), &pc_set);
 
        program_client_set_input(pc, subm->input);
        i_stream_unref(&subm->input);
index 9610246c0f8c95bffd1f1d233600964d017df3e8..74f2e7f2c944a2d398a9186531abc2584c30e586 100644 (file)
@@ -288,7 +288,7 @@ static int smtp_parse_ehlo_line(struct smtp_parser *parser,
                param = p_strdup_until(parser->pool, pbegin, parser->cur);
                array_append(&params, &param, 1);
                array_append_zero(&params);
-               *params_r = array_idx(&params, 0);
+               *params_r = array_first(&params);
        }
        return 1;
 }
index fd327131fee294153c6899d1305c6f16e551a143..1be7f2666c1a0b3f29bf0b60756a8e555592ccd2 100644 (file)
@@ -457,7 +457,7 @@ driver_sqlpool_parse_hosts(struct sqlpool_db *db, const char *connect_string,
 
        /* build a new connect string without our settings or hosts */
        array_append_zero(&connect_args);
-       connect_string = t_strarray_join(array_idx(&connect_args, 0), " ");
+       connect_string = t_strarray_join(array_first(&connect_args), " ");
 
        if (array_count(&hostnames) == 0) {
                /* no hosts specified. create a default one. */
index 9a4d47cb7c9ed57208cced7093eb75f2feb0282f..dc03b0ce1f795233f85d7106dca42d62da213b3b 100644 (file)
@@ -1321,7 +1321,7 @@ int mdbox_map_append_assign_map_uids(struct mdbox_map_append_context *ctx,
        hdr = mail_index_get_header(ctx->atomic->sync_view);
        t_array_init(&uids, 1);
        mail_index_append_finish_uids(ctx->trans, hdr->next_uid, &uids);
-       range = array_idx(&uids, 0);
+       range = array_first(&uids);
        i_assert(range[0].seq2 - range[0].seq1 + 1 == count);
 
        if (hdr->uid_validity == 0) {
index c5a3aa4801af9feaaf457b7f9e368143b80d3aa4..3b4b1c0ba4104d28f62a8278d688c8b46c7d1cb7 100644 (file)
@@ -137,7 +137,7 @@ headers_merge(pool_t pool, const char *const *h1, const char *const *h2)
                }
        }
        array_append_zero(&headers);
-       return array_idx(&headers, 0);
+       return array_first(&headers);
 }
 
 static bool
@@ -734,7 +734,7 @@ imapc_fetch_header_stream(struct imapc_mail *mail,
                return;
        array_append_zero(&hdr_arr);
 
-       if (headers_have_subset(array_idx(&hdr_arr, 0), mail->fetching_headers))
+       if (headers_have_subset(array_first(&hdr_arr), mail->fetching_headers))
                mail->header_list_fetched = TRUE;
 
        if (args->type == IMAP_ARG_LITERAL_SIZE) {
@@ -752,7 +752,7 @@ imapc_fetch_header_stream(struct imapc_mail *mail,
        }
 
        headers_ctx = mailbox_header_lookup_init(mail->imail.mail.mail.box,
-                                                array_idx(&hdr_arr, 0));
+                                                array_first(&hdr_arr));
        index_mail_parse_header_init(&mail->imail, headers_ctx);
 
        parser = message_parse_header_init(input, NULL, hdr_parser_flags);
index 0bcefce486295934eb2a355bfd8c22f6b970fa7d..0bf1bbf059ab9276a54626ce1cd7ac1e12e9acf4 100644 (file)
@@ -603,7 +603,7 @@ static void imapc_untagged_fetch(const struct imapc_untagged_reply *reply,
 
                array_append_zero(&keywords);
                kw = mail_index_keywords_create(mbox->box.index,
-                                               array_idx(&keywords, 0));
+                                               array_first(&keywords));
                if (!keywords_are_equal(kw, &old_kws)) {
                        mail_index_update_keywords(mbox->delayed_sync_trans,
                                                   lseq, MODIFY_REPLACE, kw);
index ce048230e691143c19736f6e0c5c6c24a4a49972..969a91c1968106b99d0de3b3bd67d044a088cb77 100644 (file)
@@ -621,7 +621,7 @@ index_mail_get_parsed_header(struct index_mail *mail, unsigned int field_idx)
        }
 
        array_append_zero(&header_values);
-       return array_idx(&header_values, 0);
+       return array_first(&header_values);
 }
 
 static int
@@ -707,7 +707,7 @@ index_mail_get_raw_headers(struct index_mail *mail, const char *field,
        }
 
        array_append_zero(&header_values);
-       *value_r = array_idx(&header_values, 0);
+       *value_r = array_first(&header_values);
        return 0;
 }
 
index 232d7033ca847d40e27758fb93ec4c1ed9a79485..1f2cea297cf49ecbdb278570a2ddaef6ad2b7ca5 100644 (file)
@@ -2084,7 +2084,7 @@ void index_mail_add_temp_wanted_fields(struct mail *_mail,
                array_append_zero(&names);
                new_wanted_headers =
                        mailbox_header_lookup_init(_mail->box,
-                                                  array_idx(&names, 0));
+                                                  array_first(&names));
                if (data->wanted_headers != NULL)
                        mailbox_header_lookup_unref(&data->wanted_headers);
                data->wanted_headers = new_wanted_headers;
index 4cc97d710c7ad2e3ae1b4128edc1fd6ae69b15fb..9e7d5f1e3b84a10a0587516d9c9f8598790b1842 100644 (file)
@@ -1263,7 +1263,7 @@ wanted_sort_fields_get(struct mailbox *box,
        if (array_count(&headers) > 0) {
                array_append_zero(&headers);
                *headers_ctx_r = mailbox_header_lookup_init(box,
-                                                       array_idx(&headers, 0));
+                                                       array_first(&headers));
        }
 }
 
index 56199fdb4f98ae415bb5c455b0d999205f83bc55..11505960112a7bd1642593a58b1f31f7194ecc74 100644 (file)
@@ -501,7 +501,7 @@ index_storage_mailbox_update_cache(struct mailbox *box,
        }
        if (array_count(&new_fields) > 0) {
                mail_cache_register_fields(box->cache,
-                                          array_idx_modifiable(&new_fields, 0),
+                                          array_first_modifiable(&new_fields),
                                           array_count(&new_fields));
        }
 }
index d4fb68809b5ee608e2f9d9d1aade9ae91b609545..9f82ad7acf3cc213f5b5e8d06229beec91701a99 100644 (file)
@@ -230,7 +230,7 @@ static void gather_base_subjects(struct thread_finish_context *ctx)
                        /* find the oldest child */
                        thread_sort_children(ctx, roots[i].node.idx,
                                             &sorted_children);
-                       children = array_idx(&sorted_children, 0);
+                       children = array_first(&sorted_children);
                        idx = children[0].idx;
                } else {
                        /* dummy without children */
@@ -370,7 +370,7 @@ static void sort_root_nodes(struct thread_finish_context *ctx)
        unsigned int i, count, child_count;
 
        i_array_init(&sorted_children, 64);
-       shadows = array_idx(&ctx->shadow_nodes, 0);
+       shadows = array_first(&ctx->shadow_nodes);
        roots = array_get_modifiable(&ctx->roots, &count);
        for (i = 0; i < count; i++) {
                if (roots[i].ignore)
index 7dbe40e70fdf894d9245e9e91bf50f7a1fa4d7b4..d2f4ec929d7dc3cfd25bc8157f448177754a1888 100644 (file)
@@ -72,7 +72,7 @@ int pop3c_sync_get_uidls(struct pop3c_mailbox *mbox)
                /* make msg_uidls non-NULL */
                array_append_zero(&uidls);
        }
-       mbox->msg_uidls = array_idx(&uidls, 0);
+       mbox->msg_uidls = array_first(&uidls);
        mbox->msg_count = seq;
        return 0;
 }
index ace5974346ce4e4c29186f44fcbcc8203bb56957..098df35e5953cbf5bb014ad81569c80b403076e2 100644 (file)
@@ -390,7 +390,7 @@ fs_list_get_valid_patterns(struct fs_list_iterate_context *ctx,
                }
        }
        array_append_zero(&valid_patterns); /* NULL-terminate */
-       ctx->valid_patterns = array_idx(&valid_patterns, 0);
+       ctx->valid_patterns = array_first(&valid_patterns);
 
        return array_count(&valid_patterns) > 1;
 }
index 8abd4b993311b84077762637fa199bf60cfa6c6d..ff91399d51e0b4a91b93e5e7785009e379c82b03 100644 (file)
@@ -38,7 +38,7 @@ mailbox_uidset_change(struct mail_search_arg *arg, struct mailbox *box,
                return;
        }
        uids = t_new(struct seq_range, count);
-       memcpy(uids, array_idx(&arg->value.seqset, 0), sizeof(*uids) * count);
+       memcpy(uids, array_first(&arg->value.seqset), sizeof(*uids) * count);
 
        /* put them back to the range as sequences */
        array_clear(&arg->value.seqset);
index 1a26908e4f39fdda4f3f2d30dff0ae402b31b739..eb3c389f0b1a99e4ac39e08f805f7498d88d4ab7 100644 (file)
@@ -560,7 +560,7 @@ static bool mail_storage_settings_check(void *_set, pool_t pool,
                }
 
                array_append_zero(&content_types);
-               set->parsed_mail_attachment_content_type_filter = array_idx(&content_types, 0);
+               set->parsed_mail_attachment_content_type_filter = array_first(&content_types);
        }
 
        return TRUE;
index 8e9864b3f466debf2c71e2b9144b3ff12910f875..0886ef2573ef3f5ccdeb1ecb565c1a2cb08dbe8a 100644 (file)
@@ -176,7 +176,7 @@ mailbox_get_expunges_full(struct mailbox *box, uint64_t prev_modseq,
        if (ret != 0)
                return ret > 0;
 
-       range = array_idx(uids_filter, 0);
+       range = array_first(uids_filter);
        min_uid = range->seq1;
 
        /* first get UIDs of all actual expunges */
index a0a4e8009641de4809462753a00163ea0b0bcd30..32a6a26cc2c90a7897948012e07d5b9793a24d5c 100644 (file)
@@ -299,7 +299,7 @@ static int test_mail_init_user(const char *user, const char *driver,
 
        array_append_zero(&opts);
        struct mail_storage_service_input input = {
-               .userdb_fields = array_idx(&opts, 0),
+               .userdb_fields = array_first(&opts),
                .username = user,
                .no_userdb_lookup = TRUE,
                .debug = FALSE,
index b98692a60fc07c8a5ce9670fe56e66c0d1d58ea0..2141e24345f6a097f2c5a936ccabf4d14315dacc 100644 (file)
@@ -240,7 +240,7 @@ void event_filter_merge(struct event_filter *dest,
                                             &event_filter_log_type_names[i], 1);
                        }
                        array_append_zero(&categories);
-                       query.categories = array_idx(&categories, 0);
+                       query.categories = array_first(&categories);
                }
                if (int_query->fields_count > 0) {
                        ARRAY(struct event_filter_field) fields;
@@ -253,7 +253,7 @@ void event_filter_merge(struct event_filter *dest,
                                field->value = p_strdup(dest->pool, int_query->fields[i].value.str);
                        }
                        array_append_zero(&fields);
-                       query.fields = array_idx(&fields, 0);
+                       query.fields = array_first(&fields);
                }
 
                event_filter_add(dest, &query);
@@ -340,11 +340,11 @@ bool event_filter_import_unescaped(struct event_filter *filter,
                        /* finish the query */
                        if (array_count(&categories) > 0) {
                                array_append_zero(&categories);
-                               query.categories = array_idx(&categories, 0);
+                               query.categories = array_first(&categories);
                        }
                        if (array_count(&fields) > 0) {
                                array_append_zero(&fields);
-                               query.fields = array_idx(&fields, 0);
+                               query.fields = array_first(&fields);
                        }
                        event_filter_add(filter, &query);
 
index 406762921444fbeeb962501cca2955e22ab57e4b..ef4c3270dc6fb7873217b7a0deec1027be0cf8e3 100644 (file)
@@ -861,5 +861,6 @@ char *p_array_const_string_join(pool_t pool, const ARRAY_TYPE(const_string) *arr
 {
        if (array_count(arr) == 0)
                return "";
-       return p_strarray_join_n(pool, array_idx(arr, 0), array_count(arr), separator);
+       return p_strarray_join_n(pool, array_first(arr), array_count(arr),
+                                separator);
 }
index 4f92f1f98dba962fb6a9926af37fcf4e9af33cbd..c7044a6a57f7738c7c150a1b8db813693c69e7e4 100644 (file)
@@ -144,7 +144,7 @@ static void test_array_reverse(void)
                array_append(&intarr, input, i);
                array_reverse(&intarr);
 
-               output = i == 0 ? NULL : array_idx(&intarr, 0);
+               output = i == 0 ? NULL : array_first(&intarr);
                for (j = 0; j < i; j++)
                        test_assert(input[i-j-1] == output[j]);
        }
@@ -335,7 +335,7 @@ enum fatal_test_state fatal_array(unsigned int stage)
                t_array_init(&ad, 3);
                /* allocation big enough, but memory not initialised */
                test_expect_fatal_string("(array_idx_i): assertion failed: (idx < array->buffer->used / array->element_size)");
-               useless_ptr = array_idx(&ad, 0);
+               useless_ptr = array_first(&ad);
                return FATAL_TEST_FAILURE;
        }
 
index f17960dfd66b294669b534610db543d62ec192af..0a23937691113c835099e09470cc78fad55776bd 100644 (file)
@@ -71,10 +71,10 @@ static void test_seq_range_array_remove_nth(void)
        test_assert(array_count(&range) == 3);
 
        seq_range_array_remove_nth(&range, 0, 2);
-       r = array_idx(&range, 0); test_assert(r->seq1 == 3 && r->seq2 == 5);
+       r = array_first(&range); test_assert(r->seq1 == 3 && r->seq2 == 5);
 
        seq_range_array_remove_nth(&range, 1, 4);
-       r = array_idx(&range, 0); test_assert(r->seq1 == 3 && r->seq2 == 3);
+       r = array_first(&range); test_assert(r->seq1 == 3 && r->seq2 == 3);
        r = array_idx(&range, 1); test_assert(r->seq1 == 11 && r->seq2 == 20);
 
        seq_range_array_remove_nth(&range, 5, (uint32_t)-1);
index 05a0d2638ae235314ba92c6d3004b04c1afa8c1c..79d72869b4c719b698cc347dff11ce89ed0aab10 100644 (file)
@@ -242,7 +242,7 @@ int var_expand_if(struct var_expand_context *ctx,
        }
 
        array_append_zero(&params);
-       parms = array_idx(&params, 0);
+       parms = array_first(&params);
        t_array_init(&params, 6);
 
        for(;*parms != NULL; parms++) {
@@ -260,7 +260,7 @@ int var_expand_if(struct var_expand_context *ctx,
        i_assert(array_count(&params) == 5);
 
        /* execute comparison */
-       const char *const *args = array_idx(&params, 0);
+       const char *const *args = array_first(&params);
        if (var_expand_if_comp(args[0], args[1], args[2], &result, error_r)<0)
                return -1;
        *result_r = result ? args[3] : args[4];
index 52c2bdb6f4ffd5ec53d9715928749643a38e0f26..56ea67a05c6a886fedddbedc09770221034d2638 100644 (file)
@@ -824,5 +824,5 @@ var_expand_merge_tables(pool_t pool, const struct var_expand_table *a,
                entry->long_key = p_strdup(pool, b[i].long_key);
        }
        array_append_zero(&table);
-       return array_idx_modifiable(&table, 0);
+       return array_first_modifiable(&table);
 }
index 29ad6abd118ded96efd87c0dbb56d944d32da888..2f04f200fcc6ced9ed74a530f32507ee8a532261 100644 (file)
@@ -224,7 +224,7 @@ static void client_auth_parse_args(struct client *client, bool success,
 
                alt = p_new(client->pool, const char *,
                            array_count(&alt_usernames) + 1);
-               memcpy(alt, array_idx(&alt_usernames, 0),
+               memcpy(alt, array_first(&alt_usernames),
                       sizeof(*alt) * array_count(&alt_usernames));
                client->alt_usernames = alt;
        }
index cbedae42b2d15deb2212944a4d29ddfb6ad8b02c..c82599b1e4aef4398affa6b58386a9a006bf1a4c 100644 (file)
@@ -364,13 +364,13 @@ int acl_rights_update_import(struct acl_rights_update *update,
        }
        if (array_count(&dest_rights) > 0) {
                array_append_zero(&dest_rights);
-               update->rights.rights = array_idx(&dest_rights, 0);
+               update->rights.rights = array_first(&dest_rights);
        } else if (update->modify_mode == ACL_MODIFY_MODE_REPLACE) {
                update->modify_mode = ACL_MODIFY_MODE_CLEAR;
        }
        if (array_count(&dest_neg_rights) > 0) {
                array_append_zero(&dest_neg_rights);
-               update->rights.neg_rights = array_idx(&dest_neg_rights, 0);
+               update->rights.neg_rights = array_first(&dest_neg_rights);
        } else if (update->neg_modify_mode == ACL_MODIFY_MODE_REPLACE) {
                update->neg_modify_mode = ACL_MODIFY_MODE_CLEAR;
        }
@@ -695,7 +695,7 @@ bool acl_right_names_modify(pool_t pool,
                }
                new_rights = &null;
                modify_rights = array_count(&rights) == 0 ? NULL :
-                       array_idx(&rights, 0);
+                       array_first(&rights);
                acl_right_names_merge(pool, &new_rights, modify_rights, TRUE);
                break;
        case ACL_MODIFY_MODE_ADD:
index a847c5f1286a4b460e6655a8ccbcde043baefb78..3ba26c432da4efa6f9348ea6c4305595732ae24b 100644 (file)
@@ -88,7 +88,7 @@ static void apparmor_mail_user_created(struct mail_user *user)
        random_fill(&auser->token, sizeof(auser->token));
 
        /* try change hat */
-       if (aa_change_hatv(array_idx_modifiable(&hats, 0), auser->token) < 0) {
+       if (aa_change_hatv(array_first_modifiable(&hats), auser->token) < 0) {
                i_fatal("aa_change_hatv(%s) failed: %m",
                        t_array_const_string_join(&hats, ","));
        }
index 649e39b9e0733f75433a38fd9a94db025fa09c40..a577dc491cbeb80d8668837cabef8d642d5b7b9b 100644 (file)
@@ -184,7 +184,7 @@ static const char *const *doveadm_expire_get_patterns(void)
                str = doveadm_plugin_getenv(set_name);
        }
        array_append_zero(&patterns);
-       return array_idx(&patterns, 0);
+       return array_first(&patterns);
 }
 
 static bool
index 13bc83f624e0289e0bb80bf0b5e07592258a4cae..39a194961e351d29398415f4c4c0b35bb3682f98 100644 (file)
@@ -395,7 +395,7 @@ static const char *const *expire_get_patterns(struct mail_user *user)
                str = mail_user_set_plugin_getenv(user->set, set_name);
        }
        array_append_zero(&patterns);
-       return array_idx(&patterns, 0);
+       return array_first(&patterns);
 }
 
 static void expire_mail_user_created(struct mail_user *user)
index 70dc16d4873671c650ed59f6db1931ddec803bdb..3f5733b691967a608f6ea474eebae51b603202c2 100644 (file)
@@ -540,7 +540,7 @@ mailboxes_get_guids(struct mailbox *const boxes[],
        }
 
        array_append_zero(&box_results);
-       result->box_results = array_idx_modifiable(&box_results, 0);
+       result->box_results = array_first_modifiable(&box_results);
        return 0;
 }
 
index 9b412f4cbdbf7e757eaa0c81fe23ac2cbcb6d15f..d776f9c0422243214fdf84f0dbabf8f85fdf471f 100644 (file)
@@ -822,7 +822,7 @@ solr_search_multi(struct solr_fts_backend *backend, string_t *str,
                fts_result->scores_sorted = TRUE;
        }
        array_append_zero(&fts_results);
-       result->box_results = array_idx_modifiable(&fts_results, 0);
+       result->box_results = array_first_modifiable(&fts_results);
        hash_table_destroy(&mailboxes);
        return 0;
 }
index 679fc292ac9a19ac9d54d5841d404b3bd601f62c..d9ef975bd7c159ab8db2de7bff25bf4fbb8a6678 100644 (file)
@@ -928,7 +928,7 @@ solr_search_multi(struct fts_backend *_backend, string_t *str,
                fts_result->scores_sorted = TRUE;
        }
        array_append_zero(&fts_results);
-       result->box_results = array_idx_modifiable(&fts_results, 0);
+       result->box_results = array_first_modifiable(&fts_results);
        hash_table_destroy(&mailboxes);
        return 0;
 }
index b8f8b8728925c5925966677309ed8d305f45d7f3..16eb04320ddefa1e9b0aada8239714212ceaa041 100644 (file)
@@ -766,12 +766,12 @@ uidlist_write_block_list_and_header(struct squat_uidlist_build_context *ctx,
        /* write end indexes */
        o_stream_nsend(output, uidlist->cur_block_end_indexes,
                       old_block_count * sizeof(uint32_t));
-       o_stream_nsend(output, array_idx(block_end_indexes, 0),
+       o_stream_nsend(output, array_first(block_end_indexes),
                       new_block_count * sizeof(uint32_t));
        /* write offsets */
        o_stream_nsend(output, uidlist->cur_block_offsets,
                       old_block_count * sizeof(uint32_t));
-       o_stream_nsend(output, array_idx(block_offsets, 0),
+       o_stream_nsend(output, array_first(block_offsets),
                       new_block_count * sizeof(uint32_t));
        (void)o_stream_flush(output);
 
@@ -977,7 +977,7 @@ uint32_t squat_uidlist_rebuild_next(struct squat_uidlist_rebuild_context *ctx,
        int ret;
 
        T_BEGIN {
-               ret = uidlist_write_array(ctx->output, array_idx(uids, 0),
+               ret = uidlist_write_array(ctx->output, array_first(uids),
                                          array_count(uids), 0, 0, FALSE,
                                          &ctx->list_sizes[ctx->list_idx]);
        } T_END;
index d3e388528f64fca3d04f7ece38c12c3d01748123..91d3ca7ed14ee8fa95ae7e746b37f7598269c430 100644 (file)
@@ -189,7 +189,7 @@ static int fts_search_lookup_level_multi(struct fts_search_context *fctx,
 
                mail_search_args_reset(args, TRUE);
                if (fts_backend_lookup_multi(backend,
-                                            array_idx(&tmp_mailboxes, 0),
+                                            array_first(&tmp_mailboxes),
                                             args, flags, &result) < 0)
                        return -1;
 
index a3fbb9eb64fb4284aa0902db3373f5d961afff51..4bd11aed71e6903fcdbf23bc1a216a98bf5b3d6e 100644 (file)
@@ -807,7 +807,7 @@ static const char *const *fts_exclude_get_patterns(struct mail_user *user)
                str = mail_user_plugin_getenv(user, set_name);
        }
        array_append_zero(&patterns);
-       return array_idx(&patterns, 0);
+       return array_first(&patterns);
 }
 
 static bool fts_autoindex_exclude_match(struct mailbox *box)
index eafc1a4a933357182829d122883383a8e0ca5a0c..091e119afc976bacc976c07e21106ddce49a8f86 100644 (file)
@@ -46,7 +46,7 @@ static const char *const *str_keyvalues_to_array(const char *str)
                array_append(&arr, &value, 1);
        }
        array_append_zero(&arr);
-       return array_idx(&arr, 0);
+       return array_first(&arr);
 }
 
 static int
index c4c3c0070a28e1cb3c2d16e10bb35f7ccd693e3d..4b221e10260d401d6a4b48b81219b214df311d48 100644 (file)
@@ -424,7 +424,7 @@ imap_acl_letters_parse(const char *letters, const char *const **rights_r,
                }
        }
        array_append_zero(&rights);
-       *rights_r = array_idx(&rights, 0);
+       *rights_r = array_first(&rights);
        return 0;
 }
 
@@ -526,7 +526,7 @@ static void imap_acl_update_ensure_keep_admins(struct acl_backend *backend,
                return;
        }
        array_append_zero(&new_rights);
-       update->rights.rights = array_idx(&new_rights, 0);
+       update->rights.rights = array_first(&new_rights);
 }
 
 static int
index 6851319b81a9426d58e4bc32a854e79cbf18ea86..9d3f1240945856a234331b6586428a9d0c9e4887 100644 (file)
@@ -72,7 +72,7 @@ virtual_copy_keywords(struct mailbox *src_box,
        }
        array_append_zero(&kw_strings);
        return mailbox_keywords_create_valid(dest_box,
-                                            array_idx(&kw_strings, 0));
+                                            array_first(&kw_strings));
 }
 
 int virtual_save_begin(struct mail_save_context *_ctx, struct istream *input)
index a2792f4968c12758ea9ae4d0f319ea2024307eab..332cd945ea7afa7b2a60989582944b09765ade25 100644 (file)
@@ -447,7 +447,7 @@ static int virtual_sync_index_changes(struct virtual_sync_context *ctx)
 
        keywords = mail_index_get_keywords(ctx->index);
        ctx->kw_all = array_count(keywords) == 0 ? NULL :
-               array_idx(keywords, 0);
+               array_first(keywords);
        while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) {
                if (virtual_sync_index_rec(ctx, &sync_rec) < 0)
                        return -1;
index 57c372f09bcdb9fe705470d9e9763103bf9a6049..56ae49371b765e78ad529bd593b0b0fa71ea9a1b 100644 (file)
@@ -187,7 +187,7 @@ static bool client_exec_script(struct master_service_connection *conn)
 
        if (noreply) {
                /* no need to fork and check exit status */
-               exec_child(conn, args, array_idx(&envs, 0));
+               exec_child(conn, args, array_first(&envs));
                i_unreached();
        }
 
@@ -198,7 +198,7 @@ static bool client_exec_script(struct master_service_connection *conn)
 
        if (pid == 0) {
                /* child */
-               exec_child(conn, args, array_idx(&envs, 0));
+               exec_child(conn, args, array_first(&envs));
                i_unreached();
        }
 
@@ -267,7 +267,7 @@ int main(int argc, char *argv[])
        argv += optind;
 
        array_append_zero(&aenvs);
-       accepted_envs = p_strarray_dup(default_pool, array_idx(&aenvs, 0));
+       accepted_envs = p_strarray_dup(default_pool, array_first(&aenvs));
 
        master_service_init_log(master_service, "script: ");
        if (argv[0] == NULL)