Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2892:62d53b49110d HEAD
Changed mail_index_get_header() to return the header as return value because
it can't fail anymore.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 24 Nov 2004 20:39:57 +0200 |
parents | aad29dd2c1c5 |
children | fd431866c674 |
files | src/lib-index/mail-cache-compress.c src/lib-index/mail-cache-decisions.c src/lib-index/mail-index-transaction-view.c src/lib-index/mail-index-view-private.h src/lib-index/mail-index-view.c src/lib-index/mail-index.h src/lib-storage/index/index-mail.c src/lib-storage/index/index-search.c src/lib-storage/index/index-status.c src/lib-storage/index/maildir/maildir-sync.c src/lib-storage/index/maildir/maildir-uidlist.c src/lib-storage/index/mbox/mbox-save.c src/lib-storage/index/mbox/mbox-storage.c src/lib-storage/index/mbox/mbox-sync.c |
diffstat | 14 files changed, 36 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-cache-compress.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-index/mail-cache-compress.c Wed Nov 24 20:39:57 2004 +0200 @@ -124,8 +124,7 @@ /* get sequence of first message which doesn't need it's temp fields removed. */ - if (mail_index_get_header(view, &idx_hdr) < 0) - return -1; + idx_hdr = mail_index_get_header(view); if (idx_hdr->day_first_uid[7] == 0) { first_new_seq = 1; message_count = mail_index_view_get_message_count(view);
--- a/src/lib-index/mail-cache-decisions.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-index/mail-cache-decisions.c Wed Nov 24 20:39:57 2004 +0200 @@ -87,9 +87,9 @@ } /* see if we want to change decision from TEMP to YES */ - if (mail_index_lookup_uid(view->view, seq, &uid) < 0 || - mail_index_get_header(view->view, &hdr) < 0) + if (mail_index_lookup_uid(view->view, seq, &uid) < 0) return; + hdr = mail_index_get_header(view->view); if (ioloop_time - cache->fields[field].last_used > 3600*24) { /* update last_used about once a day */
--- a/src/lib-index/mail-index-transaction-view.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-index/mail-index-transaction-view.c Wed Nov 24 20:39:57 2004 +0200 @@ -31,17 +31,14 @@ tview->t->last_new_seq - tview->t->first_new_seq); } -static int _tview_get_header(struct mail_index_view *view, - const struct mail_index_header **hdr_r) +static const struct mail_index_header * +_tview_get_header(struct mail_index_view *view) { struct mail_index_view_transaction *tview = (struct mail_index_view_transaction *)view; - if (tview->parent->get_header(view, hdr_r) < 0) - return -1; - /* FIXME: header counters may not be correct */ - return 0; + return tview->parent->get_header(view); } static int _tview_lookup_full(struct mail_index_view *view, uint32_t seq,
--- a/src/lib-index/mail-index-view-private.h Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-index/mail-index-view-private.h Wed Nov 24 20:39:57 2004 +0200 @@ -6,8 +6,8 @@ struct mail_index_view_methods { void (*close)(struct mail_index_view *view); uint32_t (*get_message_count)(struct mail_index_view *view); - int (*get_header)(struct mail_index_view *view, - const struct mail_index_header **hdr_r); + const struct mail_index_header * + (*get_header)(struct mail_index_view *view); int (*lookup_full)(struct mail_index_view *view, uint32_t seq, struct mail_index_map **map_r, const struct mail_index_record **rec_r);
--- a/src/lib-index/mail-index-view.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-index/mail-index-view.c Wed Nov 24 20:39:57 2004 +0200 @@ -164,11 +164,10 @@ return view->messages_count; } -static int _view_get_header(struct mail_index_view *view, - const struct mail_index_header **hdr_r) +static const struct mail_index_header * +_view_get_header(struct mail_index_view *view) { - *hdr_r = &view->hdr; - return 0; + return &view->hdr; } static int _view_lookup_full(struct mail_index_view *view, uint32_t seq, @@ -432,10 +431,10 @@ return view->messages_count; } -int mail_index_get_header(struct mail_index_view *view, - const struct mail_index_header **hdr_r) +const struct mail_index_header * +mail_index_get_header(struct mail_index_view *view) { - return view->methods.get_header(view, hdr_r); + return view->methods.get_header(view); } int mail_index_lookup(struct mail_index_view *view, uint32_t seq,
--- a/src/lib-index/mail-index.h Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-index/mail-index.h Wed Nov 24 20:39:57 2004 +0200 @@ -250,8 +250,8 @@ void mail_index_view_sync_end(struct mail_index_view_sync_ctx *ctx); /* Returns the index header. */ -int mail_index_get_header(struct mail_index_view *view, - const struct mail_index_header **hdr_r); +const struct mail_index_header * +mail_index_get_header(struct mail_index_view *view); /* Returns the given message. Returns -1 if error, 1 if ok, 0 if mail was expunged but data was returned from some older index. */ int mail_index_lookup(struct mail_index_view *view, uint32_t seq,
--- a/src/lib-storage/index/index-mail.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-storage/index/index-mail.c Wed Nov 24 20:39:57 2004 +0200 @@ -600,15 +600,13 @@ struct index_header_lookup_ctx *wanted_headers = (struct index_header_lookup_ctx *)_wanted_headers; const struct mail_index_header *hdr; - int ret; mail->mail = *t->ibox->mail_interface; mail->mail.box = &t->ibox->box; /* only reason we couldn't get header is if view is invalidated */ - ret = mail_index_get_header(t->ibox->view, &hdr); - if (ret == 0) - mail->uid_validity = hdr->uid_validity; + hdr = mail_index_get_header(t->ibox->view); + mail->uid_validity = hdr->uid_validity; mail->pool = pool_alloconly_create("index_mail", 16384); mail->ibox = t->ibox;
--- a/src/lib-storage/index/index-search.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-storage/index/index-search.c Wed Nov 24 20:39:57 2004 +0200 @@ -692,11 +692,7 @@ { const struct mail_index_header *hdr; - if (mail_index_get_header(ctx->view, &hdr) < 0) { - mail_storage_set_index_error(ctx->ibox); - return -1; - } - + hdr = mail_index_get_header(ctx->view); if (search_parse_msgset_args(ctx->ibox, hdr, args, &ctx->seq1, &ctx->seq2) < 0) return -1;
--- a/src/lib-storage/index/index-status.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-storage/index/index-status.c Wed Nov 24 20:39:57 2004 +0200 @@ -26,9 +26,7 @@ memset(status_r, 0, sizeof(struct mailbox_status)); /* we can get most of the status items without any trouble */ - if (mail_index_get_header(ibox->view, &hdr) < 0) - return -1; - + hdr = mail_index_get_header(ibox->view); status_r->messages = hdr->messages_count; status_r->recent = ibox->synced_recent_count; status_r->unseen =
--- a/src/lib-storage/index/maildir/maildir-sync.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-storage/index/maildir/maildir-sync.c Wed Nov 24 20:39:57 2004 +0200 @@ -545,11 +545,7 @@ } view = mail_index_view_open(ibox->index); - if (mail_index_get_header(view, &hdr) < 0) { - mail_index_view_close(view); - mail_storage_set_index_error(ibox); - return -1; - } + hdr = mail_index_get_header(view); ibox->last_cur_mtime = hdr->sync_stamp; mail_index_view_close(view); } @@ -616,13 +612,7 @@ uint32_t uid_validity, next_uid; int ret; - if (mail_index_get_header(view, &hdr) < 0) { - /* view is invalidated */ - mail_storage_set_index_error(ibox); - maildir_sync_index_abort(sync_ctx); - return -1; - } - + hdr = mail_index_get_header(view); uid_validity = maildir_uidlist_get_uid_validity(ibox->uidlist); if (uid_validity != hdr->uid_validity && uid_validity != 0 && hdr->uid_validity != 0) {
--- a/src/lib-storage/index/maildir/maildir-uidlist.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Wed Nov 24 20:39:57 2004 +0200 @@ -400,8 +400,7 @@ /* we haven't synced yet, trust index */ const struct mail_index_header *hdr; - if (mail_index_get_header(uidlist->ibox->view, &hdr) < 0) - return 0; + hdr = mail_index_get_header(uidlist->ibox->view); return hdr->recent_messages_count; }
--- a/src/lib-storage/index/mbox/mbox-save.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-save.c Wed Nov 24 20:39:57 2004 +0200 @@ -170,21 +170,18 @@ return ret; } -static int mbox_save_init_sync(struct mbox_transaction_context *t) +static void mbox_save_init_sync(struct mbox_transaction_context *t) { struct mbox_save_context *ctx = t->save_ctx; const struct mail_index_header *hdr; - if (mail_index_get_header(t->ictx.trans_view, &hdr) < 0) { - mail_storage_set_index_error(ctx->ibox); - return -1; - } + hdr = mail_index_get_header(t->ictx.trans_view); + ctx->next_uid = hdr->next_uid; ctx->synced = TRUE; t->mbox_modified = TRUE; index_mail_init(&t->ictx, &ctx->mail, 0, NULL); - return 0; } static void status_flags_append(string_t *str, enum mail_flags flags, @@ -257,10 +254,8 @@ ret = mbox_sync_has_changed(ibox, TRUE); if (ret < 0) return -1; - if (ret == 0) { - if (mbox_save_init_sync(t) < 0) - return -1; - } + if (ret == 0) + mbox_save_init_sync(t); } if (mbox_seek_to_end(ctx, &ctx->append_offset) < 0) @@ -274,8 +269,7 @@ /* we'll need to assign UID for the mail immediately. */ if (mbox_sync(ibox, 0) < 0) return -1; - if (mbox_save_init_sync(t) < 0) - return -1; + mbox_save_init_sync(t); } return 0;
--- a/src/lib-storage/index/mbox/mbox-storage.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-storage.c Wed Nov 24 20:39:57 2004 +0200 @@ -783,10 +783,10 @@ { struct index_mailbox *ibox = (struct index_mailbox *)box; const struct mail_index_header *hdr; - int ret; + int ret = 0; - ret = mail_index_get_header(ibox->view, &hdr); - if (ret == 0 && (hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 && + hdr = mail_index_get_header(ibox->view); + if ((hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 && !ibox->readonly && !ibox->mbox_readonly) { /* we've done changes to mbox which haven't been written yet. do it now. */
--- a/src/lib-storage/index/mbox/mbox-sync.c Wed Nov 24 19:55:05 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync.c Wed Nov 24 20:39:57 2004 +0200 @@ -1187,10 +1187,7 @@ const struct mail_index_header *hdr; struct stat st; - if (mail_index_get_header(ibox->view, &hdr) < 0) { - mail_storage_set_index_error(ibox); - return -1; - } + hdr = mail_index_get_header(ibox->view); if (stat(ibox->path, &st) < 0) { mbox_set_syscall_error(ibox, "stat()"); @@ -1338,14 +1335,7 @@ memset(&sync_ctx, 0, sizeof(sync_ctx)); sync_ctx.ibox = ibox; - if (mail_index_get_header(sync_view, &sync_ctx.hdr) < 0) { - /* view is invalidated */ - mail_storage_set_index_error(ibox); - mail_index_sync_rollback(index_sync_ctx); - (void)mbox_unlock(ibox, lock_id); - return -1; - } - + sync_ctx.hdr = mail_index_get_header(sync_view); sync_ctx.from_line = str_new(default_pool, 256); sync_ctx.header = str_new(default_pool, 4096); sync_ctx.uidl = str_new(default_pool, 128); @@ -1400,8 +1390,8 @@ if (ret < 0) mail_storage_set_index_error(ibox); else { - (void)mail_index_get_header(sync_ctx.sync_view, - &sync_ctx.hdr); + sync_ctx.hdr = + mail_index_get_header(sync_ctx.sync_view); if ((ret = mbox_sync_update_imap_base(&sync_ctx)) < 0) mail_index_transaction_rollback(sync_ctx.t); else if (mail_index_transaction_commit(sync_ctx.t,