]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Clarify quota_count() return value.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 7 Feb 2017 19:07:54 +0000 (21:07 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 7 Feb 2017 19:22:40 +0000 (21:22 +0200)
src/plugins/quota/quota-count.c
src/plugins/quota/quota-private.h

index 61681d9d5d0e06f4cc23b87dadc45e9cb366288f..64691bb1dbba45d92ad59466e1ff34146efad400 100644 (file)
@@ -60,7 +60,7 @@ quota_count_mailbox(struct quota_root *root, struct mail_namespace *ns,
                        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 @@ int quota_count(struct quota_root *root, uint64_t *bytes_r, uint64_t *count_r)
 {
        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 @@ int quota_count(struct quota_root *root, uint64_t *bytes_r, uint64_t *count_r)
 
        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;
                }
index 01eb5eb8880f33fc7c9a94981701120a2789a947..2b1b9e405928b63711830b11558a248472303e43 100644 (file)
@@ -202,6 +202,8 @@ quota_root_rule_find(struct quota_root_settings *root_set, const char *name);
 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,