dovecot-2.2: mail-index: use _REC_AT_SEQ not _MAP_IDX in loops o...

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/293966cc6e39
changeset: 17429:293966cc6e39
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jun 02 14:50:34 2014 +0300
description:
mail-index: use _REC_AT_SEQ not _MAP_IDX in loops over every record
Just change the loop bounds from [0..count) to [1..count], and make the
loop variale explicitly a seq.

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

diffstat:

 src/lib-index/mail-index-map-hdr.c     |   6 +++---
 src/lib-index/mail-index-sync-ext.c    |   6 +++---
 src/lib-index/mail-index-sync-update.c |  14 +++++++-------
 3 files changed, 13 insertions(+), 13 deletions(-)

diffs (78 lines):

diff -r 4b1117b5cd8e -r 293966cc6e39 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
@@ -225,10 +225,10 @@
 static void mail_index_map_clear_recent_flags(struct mail_index_map *map)
 {
 	struct mail_index_record *rec;
-	unsigned int i;
+	uint32_t seq;
 
-	for (i = 0; i < map->hdr.messages_count; i++) {
-		rec = MAIL_INDEX_MAP_IDX(map, i);
+	for (seq = 1; seq <= map->hdr.messages_count; seq++) {
+		rec = MAIL_INDEX_REC_AT_SEQ(map, seq);
 		rec->flags &= ~MAIL_RECENT;
 	}
 }
diff -r 4b1117b5cd8e -r 293966cc6e39 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
@@ -565,14 +565,14 @@
 				      struct mail_index_ext *ext)
 {
 	struct mail_index_record *rec;
-	uint32_t i;
+	uint32_t seq;
 
 	memset(buffer_get_space_unsafe(map->hdr_copy_buf, ext->hdr_offset,
 				       ext->hdr_size), 0, ext->hdr_size);
 	map->hdr_base = map->hdr_copy_buf->data;
 
-	for (i = 0; i < view->map->rec_map->records_count; i++) {
-		rec = MAIL_INDEX_MAP_IDX(view->map, i);
+	for (seq = 1; seq <= view->map->rec_map->records_count; seq++) {
+		rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 		memset(PTR_OFFSET(rec, ext->record_offset), 0,
 		       ext->record_size);
 	}
diff -r 4b1117b5cd8e -r 293966cc6e39 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
@@ -854,14 +854,14 @@
 static void mail_index_sync_update_hdr_dirty_flag(struct mail_index_map *map)
 {
 	const struct mail_index_record *rec;
-	unsigned int i;
+	uint32_t seq;
 
 	if ((map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0)
 		return;
 
 	/* do we have dirty flags anymore? */
-	for (i = 0; i < map->rec_map->records_count; i++) {
-		rec = MAIL_INDEX_MAP_IDX(map, i);
+	for (seq = 1; seq <= map->rec_map->records_count; seq++) {
+		rec = MAIL_INDEX_REC_AT_SEQ(map, seq);
 		if ((rec->flags & MAIL_INDEX_MAIL_FLAG_DIRTY) != 0) {
 			map->hdr.flags |= MAIL_INDEX_HDR_FLAG_HAVE_DIRTY;
 			break;
@@ -873,14 +873,14 @@
 void mail_index_map_check(struct mail_index_map *map)
 {
 	const struct mail_index_header *hdr = &map->hdr;
-	unsigned int i, del = 0, seen = 0;
-	uint32_t prev_uid = 0;
+	unsigned int del = 0, seen = 0;
+	uint32_t seq, prev_uid = 0;
 
 	i_assert(hdr->messages_count <= map->rec_map->records_count);
-	for (i = 0; i < hdr->messages_count; i++) {
+	for (seq = 1; seq <= hdr->messages_count; seq++) {
 		const struct mail_index_record *rec;
 
-		rec = MAIL_INDEX_MAP_IDX(map, i);
+		rec = MAIL_INDEX_REC_AT_SEQ(map, seq);
 		i_assert(rec->uid > prev_uid);
 		prev_uid = rec->uid;
 


More information about the dovecot-cvs mailing list