[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c, 1.66, 1.67 mbox-storage.c, 1.103, 1.104 mbox-sync.c, 1.122, 1.123

cras at dovecot.org cras at dovecot.org
Wed Nov 24 20:40:02 EET 2004


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv7756/lib-storage/index/mbox

Modified Files:
	mbox-save.c mbox-storage.c mbox-sync.c 
Log Message:
Changed mail_index_get_header() to return the header as return value because
it can't fail anymore.



Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- mbox-save.c	11 Nov 2004 22:01:45 -0000	1.66
+++ mbox-save.c	24 Nov 2004 18:39:58 -0000	1.67
@@ -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;

Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- mbox-storage.c	15 Oct 2004 13:37:58 -0000	1.103
+++ mbox-storage.c	24 Nov 2004 18:39:58 -0000	1.104
@@ -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. */

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- mbox-sync.c	11 Nov 2004 22:01:45 -0000	1.122
+++ mbox-sync.c	24 Nov 2004 18:39:58 -0000	1.123
@@ -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,



More information about the dovecot-cvs mailing list