Skip to content

Commit

Permalink
quota: Clarify quota_count() return value.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Feb 17, 2017
1 parent a3eb846 commit aabb256
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/plugins/quota/quota-count.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/quota/quota-private.h
Expand Up @@ -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,
Expand Down

0 comments on commit aabb256

Please sign in to comment.