dovecot-2.2: seq-range-array: Reverted most of recent API changes.
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jun 25 02:38:46 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/67b9119fbd09
changeset: 14685:67b9119fbd09
user: Timo Sirainen <tss at iki.fi>
date: Mon Jun 25 02:22:12 2012 +0300
description:
seq-range-array: Reverted most of recent API changes.
Added ATTR_NOWARN_UNUSED_RESULT for the functions whose return value can
safely be ignored.
diffstat:
src/lib-index/mail-index-transaction-update.c | 2 +-
src/lib-storage/index/dbox-multi/mdbox-sync.c | 2 +-
src/lib-storage/index/index-sync.c | 12 ++--
src/lib-storage/mailbox-search-result.c | 2 +-
src/lib/seq-range-array.c | 67 +++++++++-----------------
src/lib/seq-range-array.h | 32 +++++-------
src/lib/test-seq-range-array.c | 4 +-
src/plugins/fts/fts-expunge-log.c | 2 +-
src/plugins/virtual/virtual-sync.c | 2 +-
9 files changed, 49 insertions(+), 76 deletions(-)
diffs (truncated from 327 to 300 lines):
diff -r b39e93576e6a -r 67b9119fbd09 src/lib-index/mail-index-transaction-update.c
--- a/src/lib-index/mail-index-transaction-update.c Mon Jun 25 02:20:30 2012 +0300
+++ b/src/lib-index/mail-index-transaction-update.c Mon Jun 25 02:22:12 2012 +0300
@@ -1148,7 +1148,7 @@
static bool mail_index_cancel_array(ARRAY_TYPE(seq_range) *array, uint32_t seq)
{
if (array_is_created(array)) {
- if (seq_range_array_try_remove(array, seq)) {
+ if (seq_range_array_remove(array, seq)) {
if (array_count(array) == 0)
array_free(array);
return TRUE;
diff -r b39e93576e6a -r 67b9119fbd09 src/lib-storage/index/dbox-multi/mdbox-sync.c
--- a/src/lib-storage/index/dbox-multi/mdbox-sync.c Mon Jun 25 02:20:30 2012 +0300
+++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c Mon Jun 25 02:22:12 2012 +0300
@@ -52,7 +52,7 @@
{
uint32_t map_uid;
- if (seq_range_array_try_add(&ctx->expunged_seqs, seq)) {
+ if (seq_range_array_add(&ctx->expunged_seqs, seq)) {
/* already marked as expunged in this sync */
return 0;
}
diff -r b39e93576e6a -r 67b9119fbd09 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c Mon Jun 25 02:20:30 2012 +0300
+++ b/src/lib-storage/index/index-sync.c Mon Jun 25 02:22:12 2012 +0300
@@ -129,7 +129,7 @@
for (; seq1 <= seq2; seq1++) {
mail_index_lookup_uid(box->view, seq1, &uid);
- if (seq_range_array_try_remove(&ibox->recent_flags, uid))
+ if (seq_range_array_remove(&ibox->recent_flags, uid))
ibox->recent_flags_count--;
}
}
@@ -305,15 +305,15 @@
continue;
ibox->recent_flags_count -=
- seq_range_array_remove_range_count(&ibox->recent_flags,
- start_uid + 1, uid - 1);
+ seq_range_array_remove_range(&ibox->recent_flags,
+ start_uid + 1, uid - 1);
}
if (uid + 1 < hdr->next_uid) {
ibox->recent_flags_count -=
- seq_range_array_remove_range_count(&ibox->recent_flags,
- uid + 1,
- hdr->next_uid - 1);
+ seq_range_array_remove_range(&ibox->recent_flags,
+ uid + 1,
+ hdr->next_uid - 1);
}
#ifdef DEBUG
if (!mail_index_view_is_inconsistent(view)) {
diff -r b39e93576e6a -r 67b9119fbd09 src/lib-storage/mailbox-search-result.c
--- a/src/lib-storage/mailbox-search-result.c Mon Jun 25 02:20:30 2012 +0300
+++ b/src/lib-storage/mailbox-search-result.c Mon Jun 25 02:22:12 2012 +0300
@@ -131,7 +131,7 @@
void mailbox_search_result_remove(struct mail_search_result *result,
uint32_t uid)
{
- if (seq_range_array_try_remove(&result->uids, uid)) {
+ if (seq_range_array_remove(&result->uids, uid)) {
if (array_is_created(&result->removed_uids)) {
seq_range_array_add(&result->removed_uids, uid);
seq_range_array_remove(&result->added_uids, uid);
diff -r b39e93576e6a -r 67b9119fbd09 src/lib/seq-range-array.c
--- a/src/lib/seq-range-array.c Mon Jun 25 02:20:30 2012 +0300
+++ b/src/lib/seq-range-array.c Mon Jun 25 02:22:12 2012 +0300
@@ -4,8 +4,9 @@
#include "array.h"
#include "seq-range-array.h"
-static bool seq_range_lookup(const ARRAY_TYPE(seq_range) *array,
- uint32_t seq, unsigned int *idx_r)
+static bool ATTR_NOWARN_UNUSED_RESULT
+seq_range_lookup(const ARRAY_TYPE(seq_range) *array,
+ uint32_t seq, unsigned int *idx_r)
{
const struct seq_range *data;
unsigned int idx, left_idx, right_idx, count;
@@ -33,7 +34,7 @@
return FALSE;
}
-bool seq_range_array_try_add(ARRAY_TYPE(seq_range) *array, uint32_t seq)
+bool seq_range_array_add(ARRAY_TYPE(seq_range) *array, uint32_t seq)
{
struct seq_range *data, value;
unsigned int idx, count;
@@ -100,17 +101,12 @@
return FALSE;
}
-void seq_range_array_add(ARRAY_TYPE(seq_range) *array, uint32_t seq)
-{
- (void)seq_range_array_try_add(array, seq);
-}
-
void seq_range_array_add_with_init(ARRAY_TYPE(seq_range) *array,
unsigned int init_count, uint32_t seq)
{
if (!array_is_created(array))
i_array_init(array, init_count);
- (void)seq_range_array_try_add(array, seq);
+ seq_range_array_add(array, seq);
}
void seq_range_array_add_range(ARRAY_TYPE(seq_range) *array,
@@ -119,8 +115,8 @@
struct seq_range *data, value;
unsigned int idx1, idx2, count;
- (void)seq_range_lookup(array, seq1, &idx1);
- (void)seq_range_lookup(array, seq2, &idx2);
+ seq_range_lookup(array, seq1, &idx1);
+ seq_range_lookup(array, seq2, &idx2);
data = array_get_modifiable(array, &count);
if (idx1 > 0 && data[idx1-1].seq2+1 == seq1)
@@ -166,12 +162,7 @@
seq_range_array_add_range(dest, range->seq1, range->seq2);
}
-void seq_range_array_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq)
-{
- (void)seq_range_array_remove(array, seq);
-}
-
-bool seq_range_array_try_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq)
+bool seq_range_array_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq)
{
struct seq_range *data, value;
unsigned int idx, left_idx, right_idx, count;
@@ -243,20 +234,8 @@
return FALSE;
}
-void seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
- uint32_t seq1, uint32_t seq2)
-{
- (void)seq_range_array_remove_range_count(array, seq1, seq2);
-}
-
-void seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src)
-{
- (void)seq_range_array_remove_seq_range_count(dest, src);
-}
-
-unsigned int seq_range_array_remove_range_count(ARRAY_TYPE(seq_range) *array,
- uint32_t seq1, uint32_t seq2)
+unsigned int seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
+ uint32_t seq1, uint32_t seq2)
{
const struct seq_range *data;
unsigned int idx, idx2, count, remove_count = 0;
@@ -266,20 +245,20 @@
FIXME: it would be faster if we did only one binary lookup here
and handled the splitting ourself.. */
- if (seq_range_array_try_remove(array, seq1))
+ if (seq_range_array_remove(array, seq1))
remove_count++;
if (seq1 == seq2)
return remove_count;
seq1++;
- if (seq_range_array_try_remove(array, seq2--))
+ if (seq_range_array_remove(array, seq2--))
remove_count++;
if (seq1 > seq2)
return remove_count;
/* find the beginning */
data = array_get(array, &count);
- (void)seq_range_lookup(array, seq1, &idx);
+ seq_range_lookup(array, seq1, &idx);
if (idx == count)
return remove_count;
@@ -294,22 +273,21 @@
return remove_count;
}
-unsigned int
-seq_range_array_remove_seq_range_count(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src)
+unsigned int seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src)
{
unsigned int ret = 0;
const struct seq_range *src_range;
array_foreach(src, src_range) {
- ret += seq_range_array_remove_range_count(dest, src_range->seq1,
- src_range->seq2);
+ ret += seq_range_array_remove_range(dest, src_range->seq1,
+ src_range->seq2);
}
return ret;
}
-void seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src)
+unsigned int seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src)
{
const struct seq_range *src_range;
unsigned int i, count, ret = 0;
@@ -318,15 +296,16 @@
src_range = array_get(src, &count);
for (i = 0; i < count; i++) {
if (last_seq + 1 < src_range[i].seq1) {
- ret += seq_range_array_remove_range_count(dest,
+ ret += seq_range_array_remove_range(dest,
last_seq + 1, src_range[i].seq1 - 1);
}
last_seq = src_range[i].seq2;
}
if (last_seq != (uint32_t)-1) {
- ret += seq_range_array_remove_range_count(dest, last_seq + 1,
- (uint32_t)-1);
+ ret += seq_range_array_remove_range(dest, last_seq + 1,
+ (uint32_t)-1);
}
+ return ret;
}
bool seq_range_exists(const ARRAY_TYPE(seq_range) *array, uint32_t seq)
diff -r b39e93576e6a -r 67b9119fbd09 src/lib/seq-range-array.h
--- a/src/lib/seq-range-array.h Mon Jun 25 02:20:30 2012 +0300
+++ b/src/lib/seq-range-array.h Mon Jun 25 02:22:12 2012 +0300
@@ -13,10 +13,8 @@
/* Add sequrence to range. If the array isn't created yet, create it with
initial size of init_count. */
-void seq_range_array_add(ARRAY_TYPE(seq_range) *array, uint32_t seq);
-/* Like seq_range_array_add(), but reutrn TRUE if seq was already in the
- array. */
-bool seq_range_array_try_add(ARRAY_TYPE(seq_range) *array, uint32_t seq);
+bool ATTR_NOWARN_UNUSED_RESULT
+seq_range_array_add(ARRAY_TYPE(seq_range) *array, uint32_t seq);
/* Like seq_range_array_add(), but if the array isn't already initialized do
it with i_array_init(). */
void seq_range_array_add_with_init(ARRAY_TYPE(seq_range) *array,
@@ -25,24 +23,20 @@
uint32_t seq1, uint32_t seq2);
void seq_range_array_merge(ARRAY_TYPE(seq_range) *dest,
const ARRAY_TYPE(seq_range) *src);
-/* Remove the given sequrence from range. */
-void seq_range_array_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
/* Remove the given sequrence from range. Returns TRUE if it was found. */
-bool seq_range_array_try_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
-/* Remove a sequence range. */
-void seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
- uint32_t seq1, uint32_t seq2);
-void seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src);
+bool ATTR_NOWARN_UNUSED_RESULT
+seq_range_array_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
/* Remove a sequence range. Returns number of sequences actually removed. */
-unsigned int seq_range_array_remove_range_count(ARRAY_TYPE(seq_range) *array,
- uint32_t seq1, uint32_t seq2);
-unsigned int
-seq_range_array_remove_seq_range_count(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src);
+unsigned int ATTR_NOWARN_UNUSED_RESULT
+seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
+ uint32_t seq1, uint32_t seq2);
+unsigned int ATTR_NOWARN_UNUSED_RESULT
+seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src);
/* Remove sequences from dest that don't exist in src. */
-void seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src);
+unsigned int ATTR_NOWARN_UNUSED_RESULT
+seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src);
/* Returns TRUE if sequence exists in the range. */
bool seq_range_exists(const ARRAY_TYPE(seq_range) *array,
uint32_t seq) ATTR_PURE;
diff -r b39e93576e6a -r 67b9119fbd09 src/lib/test-seq-range-array.c
--- a/src/lib/test-seq-range-array.c Mon Jun 25 02:20:30 2012 +0300
+++ b/src/lib/test-seq-range-array.c Mon Jun 25 02:22:12 2012 +0300
@@ -47,12 +47,12 @@
memset(shadowbuf + seq1, 1, seq2 - seq1 + 1);
break;
case 2:
- ret = seq_range_array_try_remove(&range, seq1) ? 1 : 0;
+ ret = seq_range_array_remove(&range, seq1) ? 1 : 0;
ret2 = shadowbuf[seq1] != 0 ? 1 : 0;
shadowbuf[seq1] = 0;
break;
case 3:
- ret = seq_range_array_remove_range_count(&range, seq1, seq2);
+ ret = seq_range_array_remove_range(&range, seq1, seq2);
More information about the dovecot-cvs
mailing list