]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Use array_foreach_elem() where possible
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 10 Feb 2021 18:13:52 +0000 (20:13 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 7 May 2021 10:09:35 +0000 (10:09 +0000)
16 files changed:
src/lib-storage/index/dbox-single/sdbox-file.c
src/lib-storage/index/dbox-single/sdbox-sync.c
src/lib-storage/index/imapc/imapc-mail-fetch.c
src/lib-storage/index/imapc/imapc-mailbox.c
src/lib-storage/index/index-search.c
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/list/mailbox-list-index-sync.c
src/lib-storage/list/mailbox-list-index.c
src/lib-storage/mail-autoexpunge.c
src/lib-storage/mail-namespace.c
src/lib-storage/mail-storage-hooks.c
src/lib-storage/mail-storage.c
src/lib-storage/mailbox-list.c
src/lib-storage/mailbox-lua.c
src/lib-storage/mailbox-tree.c
src/lib-storage/mailbox-watch.c

index 6907d7fbb458b7cace9faa5aacef8f9aaf6be271..fed111a77fee88e6e81ba987e4dfa363f177ca87 100644 (file)
@@ -124,13 +124,13 @@ static int sdbox_file_rename_attachments(struct sdbox_file *file)
 {
        struct dbox_storage *storage = file->file.storage;
        struct fs_file *src_file, *dest_file;
-       const char *const *pathp, *src, *dest;
+       const char *path, *src, *dest;
        int ret = 0;
 
-       array_foreach(&file->attachment_paths, pathp) T_BEGIN {
-               src = t_strdup_printf("%s/%s", storage->attachment_dir, *pathp);
+       array_foreach_elem(&file->attachment_paths, path) T_BEGIN {
+               src = t_strdup_printf("%s/%s", storage->attachment_dir, path);
                dest = t_strdup_printf("%s/%s", storage->attachment_dir,
-                               sdbox_file_attachment_relpath(file, *pathp));
+                               sdbox_file_attachment_relpath(file, path));
                src_file = fs_file_init(storage->attachment_fs, src,
                                        FS_OPEN_MODE_READONLY);
                dest_file = fs_file_init(storage->attachment_fs, dest,
@@ -189,16 +189,16 @@ static int sdbox_file_unlink_aborted_save_attachments(struct sdbox_file *file)
        struct dbox_storage *storage = file->file.storage;
        struct fs *fs = storage->attachment_fs;
        struct fs_file *fs_file;
-       const char *const *pathp, *path;
+       const char *path, *att_path;
        int ret = 0;
 
-       array_foreach(&file->attachment_paths, pathp) T_BEGIN {
+       array_foreach_elem(&file->attachment_paths, att_path) T_BEGIN {
                /* we don't know if we aborted before renaming this attachment,
                   so try deleting both source and dest path. the source paths
                   point to temporary files (not to source messages'
                   attachment paths), so it's safe to delete them. */
                path = t_strdup_printf("%s/%s", storage->attachment_dir,
-                                      *pathp);
+                                      att_path);
                fs_file = fs_file_init(fs, path, FS_OPEN_MODE_READONLY);
                if (fs_delete(fs_file) < 0 &&
                    errno != ENOENT) {
@@ -209,7 +209,7 @@ static int sdbox_file_unlink_aborted_save_attachments(struct sdbox_file *file)
                fs_file_deinit(&fs_file);
 
                path = t_strdup_printf("%s/%s", storage->attachment_dir,
-                               sdbox_file_attachment_relpath(file, *pathp));
+                               sdbox_file_attachment_relpath(file, att_path));
                fs_file = fs_file_init(fs, path, FS_OPEN_MODE_READONLY);
                if (fs_delete(fs_file) < 0 &&
                    errno != ENOENT) {
index e525895b40e4d10d3003b5d857e86800396e0fd3..d7c5b7da16e0ac67cd2fbafa7b29bd44931c7e66 100644 (file)
@@ -155,13 +155,13 @@ static void dbox_sync_file_expunge(struct sdbox_sync_context *ctx,
 
 static void dbox_sync_expunge_files(struct sdbox_sync_context *ctx)
 {
-       const uint32_t *uidp;
+       uint32_t uid;
 
        /* NOTE: Index is no longer locked. Multiple processes may be unlinking
           the files at the same time. */
        ctx->mbox->box.tmp_sync_view = ctx->sync_view;
-       array_foreach(&ctx->expunged_uids, uidp) T_BEGIN {
-               dbox_sync_file_expunge(ctx, *uidp);
+       array_foreach_elem(&ctx->expunged_uids, uid) T_BEGIN {
+               dbox_sync_file_expunge(ctx, uid);
        } T_END;
        mailbox_sync_notify(&ctx->mbox->box, 0, 0);
        ctx->mbox->box.tmp_sync_view = NULL;
index 4275c657f00ae8f385c9112d1bc15312f2430bea..03ad26844d5e8b319b9b9fc040473b8b7000542a 100644 (file)
@@ -57,13 +57,11 @@ imapc_mail_fetch_callback(const struct imapc_command_reply *reply,
 {
        struct imapc_fetch_request *request = context;
        struct imapc_fetch_request *const *requests;
-       struct imapc_mail *const *mailp;
+       struct imapc_mail *mail;
        struct imapc_mailbox *mbox = NULL;
        unsigned int i, count;
 
-       array_foreach(&request->mails, mailp) {
-               struct imapc_mail *mail = *mailp;
-
+       array_foreach_elem(&request->mails, mail) {
                i_assert(mail->fetch_count > 0);
                imapc_mail_set_failure(mail, reply);
                if (--mail->fetch_count == 0)
@@ -512,15 +510,15 @@ int imapc_mail_fetch(struct mail *_mail, enum mail_fetch_field fields,
 void imapc_mail_fetch_flush(struct imapc_mailbox *mbox)
 {
        struct imapc_command *cmd;
-       struct imapc_mail *const *mailp;
+       struct imapc_mail *mail;
 
        if (mbox->pending_fetch_request == NULL) {
                i_assert(mbox->to_pending_fetch_send == NULL);
                return;
        }
 
-       array_foreach(&mbox->pending_fetch_request->mails, mailp)
-               (*mailp)->fetch_sent = TRUE;
+       array_foreach_elem(&mbox->pending_fetch_request->mails, mail)
+               mail->fetch_sent = TRUE;
 
        cmd = imapc_client_mailbox_cmd(mbox->client_box,
                                       imapc_mail_fetch_callback,
index ce517693fa309740f4b159791857e1b8bee354d3..d8956f6c4e222815b7afb330136a82d3eb4cc229 100644 (file)
@@ -461,8 +461,8 @@ static void imapc_untagged_fetch(const struct imapc_untagged_reply *reply,
                                 struct imapc_mailbox *mbox)
 {
        uint32_t lseq, rseq = reply->num;
-       struct imapc_fetch_request *const *fetch_requestp;
-       struct imapc_mail *const *mailp;
+       struct imapc_fetch_request *fetch_request;
+       struct imapc_mail *mail;
        const struct imap_arg *list, *flags_list, *modseq_list;
        const char *atom, *guid = NULL;
        const struct mail_index_record *rec = NULL;
@@ -547,10 +547,8 @@ static void imapc_untagged_fetch(const struct imapc_untagged_reply *reply,
        flags &= ENUM_NEGATE(MAIL_RECENT);
 
        /* if this is a reply to some FETCH request, update the mail's fields */
-       array_foreach(&mbox->fetch_requests, fetch_requestp) {
-               array_foreach(&(*fetch_requestp)->mails, mailp) {
-                       struct imapc_mail *mail = *mailp;
-
+       array_foreach_elem(&mbox->fetch_requests, fetch_request) {
+               array_foreach_elem(&fetch_request->mails, mail) {
                        if (mail->imail.mail.mail.uid == uid)
                                imapc_mail_fetch_update(mail, reply, list);
                }
index 12c536b327111d4adbc1ad84a09e7eddf983c80a..929aa4b3fd3ca53d20a5b42de726835bfd238001 100644 (file)
@@ -1354,7 +1354,7 @@ search_arg_deinit(struct mail_search_arg *arg,
 int index_storage_search_deinit(struct mail_search_context *_ctx)
 {
         struct index_search_context *ctx = (struct index_search_context *)_ctx;
-       struct mail **mailp;
+       struct mail *mail;
        int ret;
 
        ret = ctx->failed ? -1 : 0;
@@ -1373,11 +1373,11 @@ int index_storage_search_deinit(struct mail_search_context *_ctx)
        array_free(&ctx->mail_ctx.results);
        array_free(&ctx->mail_ctx.module_contexts);
 
-       array_foreach_modifiable(&ctx->mail_ctx.mails, mailp) {
-               struct index_mail *imail = INDEX_MAIL(*mailp);
+       array_foreach_elem(&ctx->mail_ctx.mails, mail) {
+               struct index_mail *imail = INDEX_MAIL(mail);
 
                imail->mail.search_mail = FALSE;
-               mail_free(mailp);
+               mail_free(&mail);
        }
 
        if (ctx->failed)
index 6a79532692b50049e9f472437d2c0d4160b71d3b..f4396fcf15fbd5108a7cb32b6b476511cd8eba50 100644 (file)
@@ -865,7 +865,7 @@ static int
 maildir_save_move_files_to_newcur(struct maildir_save_context *ctx)
 {
        ARRAY(struct maildir_filename *) files;
-       struct maildir_filename *mf, *const *mfp, *prev_mf;
+       struct maildir_filename *mf, *prev_mf;
        bool newdir, new_changed, cur_changed;
        int ret;
 
@@ -879,8 +879,7 @@ maildir_save_move_files_to_newcur(struct maildir_save_context *ctx)
 
        new_changed = cur_changed = FALSE;
        prev_mf = NULL;
-       array_foreach(&files, mfp) {
-               mf = *mfp;
+       array_foreach_elem(&files, mf) {
                T_BEGIN {
                        const char *dest;
 
index 07ca21df4de786977672c48f4648a82c4b0bde22..240aeb94349a1ff7f22025991d9aa7a5df127970 100644 (file)
@@ -154,8 +154,7 @@ mailbox_list_index_sync_names(struct mailbox_list_index_sync_context *ctx)
        const void *ext_data;
        size_t ext_size;
        const char *name;
-       const uint32_t *id_p;
-       uint32_t prev_id = 0;
+       uint32_t id, prev_id = 0;
 
        /* get all existing name IDs sorted */
        t_array_init(&existing_name_ids, 64);
@@ -166,17 +165,17 @@ mailbox_list_index_sync_names(struct mailbox_list_index_sync_context *ctx)
        buffer_append_zero(hdr_buf, sizeof(struct mailbox_list_index_header));
 
        /* add existing names to header (with deduplication) */
-       array_foreach(&existing_name_ids, id_p) {
-               if (*id_p != prev_id) {
-                       buffer_append(hdr_buf, id_p, sizeof(*id_p));
+       array_foreach_elem(&existing_name_ids, id) {
+               if (id != prev_id) {
+                       buffer_append(hdr_buf, &id, sizeof(id));
                        name = hash_table_lookup(ilist->mailbox_names,
-                                                POINTER_CAST(*id_p));
+                                                POINTER_CAST(id));
                        i_assert(name != NULL);
                        buffer_append(hdr_buf, name, strlen(name) + 1);
-                       prev_id = *id_p;
+                       prev_id = id;
                }
        }
-       buffer_append_zero(hdr_buf, sizeof(*id_p));
+       buffer_append_zero(hdr_buf, sizeof(id));
 
        /* make sure header size is ok in index and update it */
        mail_index_get_header_ext(ctx->view, ilist->ext_id,
index 08db83ff42ac1882c900128d9361efaab60a7d0e..2db0d47292db12c96008e5ddaddafef98fbde816 100644 (file)
@@ -614,16 +614,16 @@ static int
 list_handle_corruption_locked(struct mailbox_list *list,
                              enum mail_storage_list_index_rebuild_reason reason)
 {
-       struct mail_storage *const *storagep;
+       struct mail_storage *storage;
        const char *errstr;
        enum mail_error error;
 
-       array_foreach(&list->ns->all_storages, storagep) {
-               if ((*storagep)->v.list_index_rebuild == NULL)
+       array_foreach_elem(&list->ns->all_storages, storage) {
+               if (storage->v.list_index_rebuild == NULL)
                        continue;
 
-               if ((*storagep)->v.list_index_rebuild(*storagep, reason) < 0) {
-                       errstr = mail_storage_get_last_internal_error(*storagep, &error);
+               if (storage->v.list_index_rebuild(storage, reason) < 0) {
+                       errstr = mail_storage_get_last_internal_error(storage, &error);
                        mailbox_list_set_error(list, error, errstr);
                        return -1;
                } else {
index e2a231080e99cea9924722a84f5c2f0d763f020f..44ce5dcd211ded0a4b62cf7a3afb2e2add565997 100644 (file)
@@ -218,30 +218,30 @@ static bool
 mail_namespace_autoexpunge(struct mail_namespace *ns, struct file_lock **lock,
                           unsigned int *expunged_count)
 {
-       struct mailbox_settings *const *box_set;
+       struct mailbox_settings *box_set;
        const char *vname;
 
        if (!array_is_created(&ns->set->mailboxes))
                return TRUE;
 
-       array_foreach(&ns->set->mailboxes, box_set) {
-               if ((*box_set)->autoexpunge == 0 &&
-                   (*box_set)->autoexpunge_max_mails == 0)
+       array_foreach_elem(&ns->set->mailboxes, box_set) {
+               if (box_set->autoexpunge == 0 &&
+                   box_set->autoexpunge_max_mails == 0)
                        continue;
 
                if (!mailbox_autoexpunge_lock(ns->user, lock))
                        return FALSE;
 
-               if (strpbrk((*box_set)->name, "*?") != NULL)
-                       mailbox_autoexpunge_wildcards(ns, *box_set, expunged_count);
+               if (strpbrk(box_set->name, "*?") != NULL)
+                       mailbox_autoexpunge_wildcards(ns, box_set, expunged_count);
                else {
-                       if ((*box_set)->name[0] == '\0' && ns->prefix_len > 0 &&
+                       if (box_set->name[0] == '\0' && ns->prefix_len > 0 &&
                            ns->prefix[ns->prefix_len-1] == mail_namespace_get_sep(ns))
                                vname = t_strndup(ns->prefix, ns->prefix_len - 1);
                        else
-                               vname = t_strconcat(ns->prefix, (*box_set)->name, NULL);
-                       mailbox_autoexpunge_set(ns, vname, (*box_set)->autoexpunge,
-                                               (*box_set)->autoexpunge_max_mails,
+                               vname = t_strconcat(ns->prefix, box_set->name, NULL);
+                       mailbox_autoexpunge_set(ns, vname, box_set->autoexpunge,
+                                               box_set->autoexpunge_max_mails,
                                                expunged_count);
                }
        }
index 580cdcb3a4f8e640676f42fa02281a6ed80a308c..0b3d45869a0b13cd52bf3e70deaa8a0645d03f60 100644 (file)
@@ -51,11 +51,11 @@ void mail_namespace_finish_list_init(struct mail_namespace *ns,
 
 static void mail_namespace_free(struct mail_namespace *ns)
 {
-       struct mail_storage **storagep;
+       struct mail_storage *storage;
 
        if (array_is_created(&ns->all_storages)) {
-               array_foreach_modifiable(&ns->all_storages, storagep)
-                       mail_storage_unref(storagep);
+               array_foreach_elem(&ns->all_storages, storage)
+                       mail_storage_unref(&storage);
                array_free(&ns->all_storages);
        }
        if (ns->list != NULL)
@@ -70,13 +70,13 @@ static void mail_namespace_free(struct mail_namespace *ns)
 static bool
 namespace_has_special_use_mailboxes(struct mail_namespace_settings *ns_set)
 {
-       struct mailbox_settings *const *box_set;
+       struct mailbox_settings *box_set;
 
        if (!array_is_created(&ns_set->mailboxes))
                return FALSE;
 
-       array_foreach(&ns_set->mailboxes, box_set) {
-               if ((*box_set)->special_use[0] != '\0')
+       array_foreach_elem(&ns_set->mailboxes, box_set) {
+               if (box_set->special_use[0] != '\0')
                        return TRUE;
        }
        return FALSE;
@@ -607,11 +607,11 @@ void mail_namespaces_set_storage_callbacks(struct mail_namespace *namespaces,
                                           void *context)
 {
        struct mail_namespace *ns;
-       struct mail_storage *const *storagep;
+       struct mail_storage *storage;
 
        for (ns = namespaces; ns != NULL; ns = ns->next) {
-               array_foreach(&ns->all_storages, storagep)
-                       mail_storage_set_callbacks(*storagep, callbacks, context);
+               array_foreach_elem(&ns->all_storages, storage)
+                       mail_storage_set_callbacks(storage, callbacks, context);
        }
 }
 
@@ -849,7 +849,7 @@ mail_namespace_find_prefix_nosep(struct mail_namespace *namespaces,
 
 bool mail_namespace_is_shared_user_root(struct mail_namespace *ns)
 {
-       struct mail_storage *const *storagep;
+       struct mail_storage *storage;
 
        if (ns->type != MAIL_NAMESPACE_TYPE_SHARED)
                return FALSE;
@@ -858,8 +858,8 @@ bool mail_namespace_is_shared_user_root(struct mail_namespace *ns)
                return FALSE;
        }
        /* if we have driver=shared storage, we're a real shared root */
-       array_foreach(&ns->all_storages, storagep) {
-               if (strcmp((*storagep)->name, MAIL_SHARED_STORAGE_NAME) == 0)
+       array_foreach_elem(&ns->all_storages, storage) {
+               if (strcmp(storage->name, MAIL_SHARED_STORAGE_NAME) == 0)
                        return TRUE;
        }
        return FALSE;
index c09c31c67513e4b2c6ed9d102ba5964145eb94a1..d368bd7c80b2c0c302bb1e46e8f6ad4c898660b9 100644 (file)
@@ -81,11 +81,11 @@ void mail_storage_hooks_remove(const struct mail_storage_hooks *hooks)
 
 void mail_storage_hooks_add_internal(const struct mail_storage_hooks *hooks)
 {
-       const struct mail_storage_hooks *const *existing_hooksp;
+       const struct mail_storage_hooks *existing_hooks;
 
        /* make sure we don't add duplicate hooks */
-       array_foreach(&internal_hooks, existing_hooksp)
-               i_assert(*existing_hooksp != hooks);
+       array_foreach_elem(&internal_hooks, existing_hooks)
+               i_assert(existing_hooks != hooks);
        array_push_back(&internal_hooks, &hooks);
 }
 
@@ -156,16 +156,16 @@ static void mail_user_add_plugin_hooks(struct mail_user *user)
 
 void hook_mail_user_created(struct mail_user *user)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
        struct hook_build_context *ctx;
 
        mail_user_add_plugin_hooks(user);
 
        ctx = hook_build_init((void *)&user->v, sizeof(user->v));
        user->vlast = &user->v;
-       array_foreach(&user->hooks, hooks) {
-               if ((*hooks)->mail_user_created != NULL) T_BEGIN {
-                       (*hooks)->mail_user_created(user);
+       array_foreach_elem(&user->hooks, hooks) {
+               if (hooks->mail_user_created != NULL) T_BEGIN {
+                       hooks->mail_user_created(user);
                        hook_build_update(ctx, user->vlast);
                } T_END;
        }
@@ -175,51 +175,51 @@ void hook_mail_user_created(struct mail_user *user)
 
 void hook_mail_namespace_storage_added(struct mail_namespace *ns)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
 
-       array_foreach(&ns->user->hooks, hooks) {
-               if ((*hooks)->mail_namespace_storage_added != NULL) T_BEGIN {
-                       (*hooks)->mail_namespace_storage_added(ns);
+       array_foreach_elem(&ns->user->hooks, hooks) {
+               if (hooks->mail_namespace_storage_added != NULL) T_BEGIN {
+                       hooks->mail_namespace_storage_added(ns);
                } T_END;
        }
 }
 
 void hook_mail_namespaces_created(struct mail_namespace *namespaces)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
 
-       array_foreach(&namespaces->user->hooks, hooks) {
+       array_foreach_elem(&namespaces->user->hooks, hooks) {
                if (namespaces->user->error != NULL)
                        break;
-               if ((*hooks)->mail_namespaces_created != NULL) T_BEGIN {
-                       (*hooks)->mail_namespaces_created(namespaces);
+               if (hooks->mail_namespaces_created != NULL) T_BEGIN {
+                       hooks->mail_namespaces_created(namespaces);
                } T_END;
        }
 }
 
 void hook_mail_namespaces_added(struct mail_namespace *namespaces)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
 
-       array_foreach(&namespaces->user->hooks, hooks) {
+       array_foreach_elem(&namespaces->user->hooks, hooks) {
                if (namespaces->user->error != NULL)
                        break;
-               if ((*hooks)->mail_namespaces_added != NULL) T_BEGIN {
-                       (*hooks)->mail_namespaces_added(namespaces);
+               if (hooks->mail_namespaces_added != NULL) T_BEGIN {
+                       hooks->mail_namespaces_added(namespaces);
                } T_END;
        }
 }
 
 void hook_mail_storage_created(struct mail_storage *storage)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
        struct hook_build_context *ctx;
 
        ctx = hook_build_init((void *)&storage->v, sizeof(storage->v));
        storage->vlast = &storage->v;
-       array_foreach(&storage->user->hooks, hooks) {
-               if ((*hooks)->mail_storage_created != NULL) T_BEGIN {
-                       (*hooks)->mail_storage_created(storage);
+       array_foreach_elem(&storage->user->hooks, hooks) {
+               if (hooks->mail_storage_created != NULL) T_BEGIN {
+                       hooks->mail_storage_created(storage);
                        hook_build_update(ctx, storage->vlast);
                } T_END;
        }
@@ -229,14 +229,14 @@ void hook_mail_storage_created(struct mail_storage *storage)
 
 void hook_mailbox_list_created(struct mailbox_list *list)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
        struct hook_build_context *ctx;
 
        ctx = hook_build_init((void *)&list->v, sizeof(list->v));
        list->vlast = &list->v;
-       array_foreach(&list->ns->user->hooks, hooks) {
-               if ((*hooks)->mailbox_list_created != NULL) T_BEGIN {
-                       (*hooks)->mailbox_list_created(list);
+       array_foreach_elem(&list->ns->user->hooks, hooks) {
+               if (hooks->mailbox_list_created != NULL) T_BEGIN {
+                       hooks->mailbox_list_created(list);
                        hook_build_update(ctx, list->vlast);
                } T_END;
        }
@@ -246,14 +246,14 @@ void hook_mailbox_list_created(struct mailbox_list *list)
 
 void hook_mailbox_allocated(struct mailbox *box)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
        struct hook_build_context *ctx;
 
        ctx = hook_build_init((void *)&box->v, sizeof(box->v));
        box->vlast = &box->v;
-       array_foreach(&box->storage->user->hooks, hooks) {
-               if ((*hooks)->mailbox_allocated != NULL) T_BEGIN {
-                       (*hooks)->mailbox_allocated(box);
+       array_foreach_elem(&box->storage->user->hooks, hooks) {
+               if (hooks->mailbox_allocated != NULL) T_BEGIN {
+                       hooks->mailbox_allocated(box);
                        hook_build_update(ctx, box->vlast);
                } T_END;
        }
@@ -263,26 +263,26 @@ void hook_mailbox_allocated(struct mailbox *box)
 
 void hook_mailbox_opened(struct mailbox *box)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
 
-       array_foreach(&box->storage->user->hooks, hooks) {
-               if ((*hooks)->mailbox_opened != NULL) T_BEGIN {
-                       (*hooks)->mailbox_opened(box);
+       array_foreach_elem(&box->storage->user->hooks, hooks) {
+               if (hooks->mailbox_opened != NULL) T_BEGIN {
+                       hooks->mailbox_opened(box);
                } T_END;
        }
 }
 
 void hook_mail_allocated(struct mail *mail)
 {
-       const struct mail_storage_hooks *const *hooks;
+       const struct mail_storage_hooks *hooks;
        struct mail_private *pmail = (struct mail_private *)mail;
        struct hook_build_context *ctx;
 
        ctx = hook_build_init((void *)&pmail->v, sizeof(pmail->v));
        pmail->vlast = &pmail->v;
-       array_foreach(&mail->box->storage->user->hooks, hooks) {
-               if ((*hooks)->mail_allocated != NULL) T_BEGIN {
-                       (*hooks)->mail_allocated(mail);
+       array_foreach_elem(&mail->box->storage->user->hooks, hooks) {
+               if (hooks->mail_allocated != NULL) T_BEGIN {
+                       hooks->mail_allocated(mail);
                        hook_build_update(ctx, pmail->vlast);
                } T_END;
        }
index 5813f1d490eec7d358f2f8cfd3285718fdce6576..df1f59a4c67b27d3e5511ba8e541e9a97a78f5de 100644 (file)
@@ -790,7 +790,7 @@ bool mail_storage_set_error_from_errno(struct mail_storage *storage)
 const struct mailbox_settings *
 mailbox_settings_find(struct mail_namespace *ns, const char *vname)
 {
-       struct mailbox_settings *const *box_set;
+       struct mailbox_settings *box_set;
 
        if (!array_is_created(&ns->set->mailboxes))
                return NULL;
@@ -804,9 +804,9 @@ mailbox_settings_find(struct mail_namespace *ns, const char *vname)
                        vname = "";
                }
        }
-       array_foreach(&ns->set->mailboxes, box_set) {
-               if (strcmp((*box_set)->name, vname) == 0)
-                       return *box_set;
+       array_foreach_elem(&ns->set->mailboxes, box_set) {
+               if (strcmp(box_set->name, vname) == 0)
+                       return box_set;
        }
        return NULL;
 }
index 6c194711c227311cdd10c77e5cfe50655d012d1b..cfcf29e319dc5c7f9b49db4926fe063d48ab2d58 100644 (file)
@@ -871,12 +871,12 @@ static int
 mailbox_list_get_storage_driver(struct mailbox_list *list, const char *driver,
                                struct mail_storage **storage_r)
 {
-       struct mail_storage *const *storagep;
+       struct mail_storage *storage;
        const char *error, *data;
 
-       array_foreach(&list->ns->all_storages, storagep) {
-               if (strcmp((*storagep)->name, driver) == 0) {
-                       *storage_r = *storagep;
+       array_foreach_elem(&list->ns->all_storages, storage) {
+               if (strcmp(storage->name, driver) == 0) {
+                       *storage_r = storage;
                        return 0;
                }
        }
index a16107f7dfb01af3696451fd76d238bed215ff77..a02587ed0226b562eeae6ad6968adff5b9a54d1f 100644 (file)
@@ -160,7 +160,7 @@ static int lua_storage_mailbox_sync(lua_State *L)
 static int lua_storage_mailbox_status(lua_State *L)
 {
        struct mailbox_status status;
-       const char *const *keyword;
+       const char *keyword;
        struct mailbox *mbox = lua_check_storage_mailbox(L, 1);
        /* get items as list of parameters */
        enum mailbox_status_items items = 0;
@@ -215,8 +215,8 @@ static int lua_storage_mailbox_status(lua_State *L)
        if (status.keywords != NULL && array_is_created(status.keywords)) {
                int i = 1;
                lua_createtable(L, array_count(status.keywords), 0);
-               array_foreach(status.keywords, keyword) {
-                       lua_pushstring(L, *keyword);
+               array_foreach_elem(status.keywords, keyword) {
+                       lua_pushstring(L, keyword);
                        lua_rawseti(L, -2, i++);
                }
                lua_setfield(L, -2, "keywords");
index 8f86833a6ef6e4e029d906ccb03eb4a2873dc50d..9333fb61399a669e602a7f878d8f2d31c89ccef4 100644 (file)
@@ -306,7 +306,7 @@ static int mailbox_node_name_cmp(struct mailbox_node *const *node1,
 static void mailbox_tree_sort_branch(struct mailbox_node **nodes,
                                     ARRAY_TYPE(mailbox_node) *tmparr)
 {
-       struct mailbox_node *node, *const *nodep, **dest;
+       struct mailbox_node *node, **dest;
 
        if (*nodes == NULL)
                return;
@@ -319,8 +319,8 @@ static void mailbox_tree_sort_branch(struct mailbox_node **nodes,
 
        /* update the node pointers */
        dest = nodes;
-       array_foreach(tmparr, nodep) {
-               *dest = *nodep;
+       array_foreach_elem(tmparr, node) {
+               *dest = node;
                dest = &(*dest)->next;
        }
        *dest = NULL;
index 07f7762444c06dd3e5e87275542039c8df2e0e79..659cab3810f1ba9c2f8fc2642b8c79434bdd633d 100644 (file)
@@ -110,7 +110,7 @@ int mailbox_watch_extract_notify_fd(struct mailbox *box, const char **reason_r)
 {
        struct ioloop *ioloop;
        struct mailbox_notify_file *file;
-       struct io *io, *const *iop;
+       struct io *io;
        ARRAY(struct io *) temp_ios;
        int ret;
        bool failed = FALSE;
@@ -145,10 +145,8 @@ int mailbox_watch_extract_notify_fd(struct mailbox *box, const char **reason_r)
                if (ret == -1)
                        *reason_r = "Couldn't extra notify fd";
        }
-       array_foreach(&temp_ios, iop) {
-               struct io *io = *iop;
+       array_foreach_elem(&temp_ios, io)
                io_remove(&io);
-       }
        io_loop_destroy(&ioloop);
        return ret;
 }