dovecot-2.2: mail-index: trivial robomatic migration from _MAP_I...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 2 11:53:56 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/4b1117b5cd8e
changeset: 17428:4b1117b5cd8e
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jun 02 14:50:34 2014 +0300
description:
mail-index: trivial robomatic migration from _MAP_IDX to new helper
All users which have a '-1' in their MAIL_INDEX_MAP_IDX have been changed
to the new mail_index_rec_at_seq() helper using this sed script:

$ sed -ie 's/MAIL_INDEX_MAP_IDX(\([^,]*[^)]*[^ ]\) \?- \?1)/MAIL_INDEX_REC_AT_SEQ(\1)/' src/lib-index/*.[ch]

No other users have been changed.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib-index/mail-index-map-hdr.c            |   2 +-
 src/lib-index/mail-index-map.c                |   4 ++--
 src/lib-index/mail-index-modseq.c             |   4 ++--
 src/lib-index/mail-index-sync-ext.c           |   4 ++--
 src/lib-index/mail-index-sync-update.c        |  12 ++++++------
 src/lib-index/mail-index-transaction-finish.c |   2 +-
 src/lib-index/mail-index-view-sync.c          |   4 ++--
 src/lib-index/mail-index-view.c               |  10 +++++-----
 8 files changed, 21 insertions(+), 21 deletions(-)

diffs (192 lines):

diff -r c83ef1042679 -r 4b1117b5cd8e src/lib-index/mail-index-map-hdr.c
--- a/src/lib-index/mail-index-map-hdr.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-map-hdr.c	Mon Jun 02 14:50:34 2014 +0300
@@ -290,7 +290,7 @@
 		   also make sure it's not zero. */
 		const struct mail_index_record *rec;
 
-		rec = MAIL_INDEX_MAP_IDX(map, hdr->messages_count-1);
+		rec = MAIL_INDEX_REC_AT_SEQ(map, hdr->messages_count);
 		if (rec->uid == 0 || rec->uid >= hdr->next_uid)
 			return 0;
 	}
diff -r c83ef1042679 -r 4b1117b5cd8e src/lib-index/mail-index-map.c
--- a/src/lib-index/mail-index-map.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-map.c	Mon Jun 02 14:50:34 2014 +0300
@@ -444,7 +444,7 @@
 		if (new_map->records_count == 0)
 			new_map->last_appended_uid = 0;
 		else {
-			rec = MAIL_INDEX_MAP_IDX(map, new_map->records_count-1);
+			rec = MAIL_INDEX_REC_AT_SEQ(map, new_map->records_count);
 			new_map->last_appended_uid = rec->uid;
 		}
 		buffer_set_used_size(new_map->buffer, new_map->records_count *
@@ -554,7 +554,7 @@
 
 	*first_seq_r = mail_index_bsearch_uid(map, first_uid, 0, 1);
 	if (*first_seq_r == 0 ||
-	    MAIL_INDEX_MAP_IDX(map, *first_seq_r-1)->uid > last_uid) {
+	    MAIL_INDEX_REC_AT_SEQ(map, *first_seq_r)->uid > last_uid) {
 		*first_seq_r = *last_seq_r = 0;
 		return;
 	}
diff -r c83ef1042679 -r 4b1117b5cd8e src/lib-index/mail-index-modseq.c
--- a/src/lib-index/mail-index-modseq.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-modseq.c	Mon Jun 02 14:50:34 2014 +0300
@@ -200,7 +200,7 @@
 	if (mmap == NULL)
 		return -1;
 
-	rec = MAIL_INDEX_MAP_IDX(view->map, seq-1);
+	rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 	if (!mail_index_map_get_ext_idx(view->map, view->index->modseq_ext_id,
 					&ext_map_idx))
 		return -1;
@@ -304,7 +304,7 @@
 
 	ext = array_idx(&ctx->view->map->extensions, ext_map_idx);
 	for (; seq1 <= seq2; seq1++) {
-		rec = MAIL_INDEX_MAP_IDX(ctx->view->map, seq1-1);
+		rec = MAIL_INDEX_REC_AT_SEQ(ctx->view->map, seq1);
 		modseqp = PTR_OFFSET(rec, ext->record_offset);
 		if (*modseqp == 0 || (nonzeros && *modseqp < modseq))
 			*modseqp = modseq;
diff -r c83ef1042679 -r 4b1117b5cd8e src/lib-index/mail-index-sync-ext.c
--- a/src/lib-index/mail-index-sync-ext.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-sync-ext.c	Mon Jun 02 14:50:34 2014 +0300
@@ -674,7 +674,7 @@
 	i_assert(ext->record_offset + ext->record_size <=
 		 view->map->hdr.record_size);
 
-	rec = MAIL_INDEX_MAP_IDX(view->map, seq-1);
+	rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 	old_data = PTR_OFFSET(rec, ext->record_offset);
 
 	rext = array_idx(&view->index->extensions, ext->index_idx);
@@ -723,7 +723,7 @@
 	i_assert(ext->record_offset + ext->record_size <=
 		 view->map->hdr.record_size);
 
-	rec = MAIL_INDEX_MAP_IDX(view->map, seq-1);
+	rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 	data = PTR_OFFSET(rec, ext->record_offset);
 
 	min_value = u->diff >= 0 ? 0 : (uint64_t)(-(int64_t)u->diff);
diff -r c83ef1042679 -r 4b1117b5cd8e src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Mon Jun 02 14:50:34 2014 +0300
@@ -208,7 +208,7 @@
 
 	array_foreach(&ctx->expunge_handlers, eh) {
 		for (seq = seq1; seq <= seq2; seq++) {
-			rec = MAIL_INDEX_MAP_IDX(ctx->view->map, seq-1);
+			rec = MAIL_INDEX_REC_AT_SEQ(ctx->view->map, seq);
 			/* FIXME: does expunge handler's return value matter?
 			   we probably shouldn't disallow expunges if the
 			   handler returns failure.. should it be just changed
@@ -267,7 +267,7 @@
 		i_assert(seq1 > prev_seq2);
 
 		for (seq = seq1; seq <= seq2; seq++) {
-			rec = MAIL_INDEX_MAP_IDX(map, seq-1);
+			rec = MAIL_INDEX_REC_AT_SEQ(map, seq);
 			mail_index_sync_header_update_counts(ctx, rec->uid, rec->flags, 0);
 		}
 
@@ -276,8 +276,8 @@
 			   final location in the map if necessary */
 			uint32_t move_count = (seq1-1) - (prev_seq2+1) + 1;
 			if (prev_seq2+1-1 != dest_seq1-1)
-				memmove(MAIL_INDEX_MAP_IDX(map, dest_seq1-1),
-					MAIL_INDEX_MAP_IDX(map, prev_seq2+1-1),
+				memmove(MAIL_INDEX_REC_AT_SEQ(map, dest_seq1),
+					MAIL_INDEX_REC_AT_SEQ(map, prev_seq2+1),
 					move_count * map->hdr.record_size);
 			dest_seq1 += move_count;
 		}
@@ -290,8 +290,8 @@
 	/* Final stragglers */
 	if (orig_rec_count > prev_seq2) {
 		uint32_t final_move_count = orig_rec_count - prev_seq2;
-		memmove(MAIL_INDEX_MAP_IDX(map, dest_seq1-1),
-			MAIL_INDEX_MAP_IDX(map, prev_seq2+1-1),
+		memmove(MAIL_INDEX_REC_AT_SEQ(map, dest_seq1),
+			MAIL_INDEX_REC_AT_SEQ(map, prev_seq2+1),
 			final_move_count * map->hdr.record_size);
 	}
 }
diff -r c83ef1042679 -r 4b1117b5cd8e src/lib-index/mail-index-transaction-finish.c
--- a/src/lib-index/mail-index-transaction-finish.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-transaction-finish.c	Mon Jun 02 14:50:34 2014 +0300
@@ -182,7 +182,7 @@
 		rec = mail_index_transaction_lookup(t, seq);
 	else {
 		i_assert(seq <= t->view->map->hdr.messages_count);
-		rec = MAIL_INDEX_MAP_IDX(t->view->map, seq - 1);
+		rec = MAIL_INDEX_REC_AT_SEQ(t->view->map, seq);
 	}
 	i_assert(rec->uid != 0);
 	return rec->uid;
diff -r c83ef1042679 -r 4b1117b5cd8e src/lib-index/mail-index-view-sync.c
--- a/src/lib-index/mail-index-view-sync.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-view-sync.c	Mon Jun 02 14:50:34 2014 +0300
@@ -328,8 +328,8 @@
 	uint64_t new_modseq;
 	bool changed = FALSE;
 
-	old_rec = MAIL_INDEX_MAP_IDX(old_map, old_seq - 1);
-	new_rec = MAIL_INDEX_MAP_IDX(new_map, new_seq - 1);
+	old_rec = MAIL_INDEX_REC_AT_SEQ(old_map, old_seq);
+	new_rec = MAIL_INDEX_REC_AT_SEQ(new_map, new_seq);
 
 	memset(&thdr, 0, sizeof(thdr));
 	if (old_rec->flags != new_rec->flags) {
diff -r c83ef1042679 -r 4b1117b5cd8e src/lib-index/mail-index-view.c
--- a/src/lib-index/mail-index-view.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-view.c	Mon Jun 02 14:50:34 2014 +0300
@@ -170,7 +170,7 @@
 	i_assert(seq > 0 && seq <= mail_index_view_get_messages_count(view));
 
 	/* look up the record */
-	rec = MAIL_INDEX_MAP_IDX(view->map, seq-1);
+	rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 	if (unlikely(rec->uid == 0)) {
 		if (!view->inconsistent) {
 			mail_index_set_error(view->index,
@@ -243,7 +243,7 @@
 {
 	i_assert(seq > 0 && seq <= mail_index_view_get_messages_count(view));
 
-	*uid_r = MAIL_INDEX_MAP_IDX(view->map, seq-1)->uid;
+	*uid_r = MAIL_INDEX_REC_AT_SEQ(view->map, seq)->uid;
 }
 
 static void view_lookup_seq_range(struct mail_index_view *view,
@@ -281,7 +281,7 @@
 
 	i_assert(hdr->messages_count <= view->map->rec_map->records_count);
 	for (; seq <= hdr->messages_count; seq++) {
-		rec = MAIL_INDEX_MAP_IDX(view->map, seq-1);
+		rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 		if ((rec->flags & flags_mask) == (uint8_t)flags) {
 			*seq_r = seq;
 			break;
@@ -470,7 +470,7 @@
 	if (!mail_index_map_get_ext_idx(map, map->index->keywords_ext_id, &idx))
 		data = NULL;
 	else {
-		rec = MAIL_INDEX_MAP_IDX(map, seq-1);
+		rec = MAIL_INDEX_REC_AT_SEQ(map, seq);
 		ext = array_idx(&map->extensions, idx);
 		data = ext->record_offset == 0 ? NULL :
 			CONST_PTR_OFFSET(rec, ext->record_offset);
@@ -493,7 +493,7 @@
 
 	i_assert(seq > 0 && seq <= mail_index_view_get_messages_count(view));
 
-	rec = MAIL_INDEX_MAP_IDX(view->map, seq-1);
+	rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 	*flags_r = rec->flags;
 
 	keyword_data = view_map_lookup_ext_full(view->map, rec,


More information about the dovecot-cvs mailing list