changeset 21506:4e84b0d61d49

quota: Clarify quota_count() return value.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 07 Feb 2017 21:07:54 +0200
parents 6c88e7e55768
children e14d3d07c47b
files src/plugins/quota/quota-count.c src/plugins/quota/quota-private.h
diffstat 2 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota-count.c	Tue Feb 07 20:41:41 2017 +0200
+++ b/src/plugins/quota/quota-count.c	Tue Feb 07 21:07:54 2017 +0200
@@ -60,7 +60,7 @@
 			ret = 0;
 		}
 	} else {
-		ret = 1;
+		ret = 0;
 		*bytes += root->quota->set->vsizes ?
 			metadata.virtual_size : metadata.physical_size;
 		*count += status.messages;
@@ -147,7 +147,7 @@
 {
 	struct quota_mailbox_iter *iter;
 	const struct mailbox_info *info;
-	int ret = 0, ret2;
+	int ret = 1;
 
 	*bytes_r = *count_r = 0;
 	if (root->recounting)
@@ -156,11 +156,8 @@
 
 	iter = quota_mailbox_iter_begin(root);
 	while ((info = quota_mailbox_iter_next(iter)) != NULL) {
-		ret2 = quota_count_mailbox(root, info->ns, info->vname,
-					   bytes_r, count_r);
-		if (ret2 > 0)
-			ret = 1;
-		else if (ret2 < 0) {
+		if (quota_count_mailbox(root, info->ns, info->vname,
+					bytes_r, count_r) < 0) {
 			ret = -1;
 			break;
 		}
--- a/src/plugins/quota/quota-private.h	Tue Feb 07 20:41:41 2017 +0200
+++ b/src/plugins/quota/quota-private.h	Tue Feb 07 21:07:54 2017 +0200
@@ -202,6 +202,8 @@
 void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set,
 					   int64_t bytes_limit,
 					   int64_t count_limit);
+/* Returns 1 if values were returned successfully, 0 if we're recursing into
+   the same function, -1 if error. */
 int quota_count(struct quota_root *root, uint64_t *bytes_r, uint64_t *count_r);
 
 int quota_root_parse_grace(struct quota_root_settings *root_set,