dovecot-2.1: quota: Allow negative percentage rules up to -99%

dovecot at dovecot.org dovecot at dovecot.org
Tue Sep 18 19:16:21 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/74d639b2a5bf
changeset: 14710:74d639b2a5bf
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Sep 18 19:16:04 2012 +0300
description:
quota: Allow negative percentage rules up to -99%

diffstat:

 src/plugins/quota/quota-private.h |  2 +-
 src/plugins/quota/quota.c         |  6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r f5bb9f6b304d -r 74d639b2a5bf src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Tue Sep 18 18:44:46 2012 +0300
+++ b/src/plugins/quota/quota-private.h	Tue Sep 18 19:16:04 2012 +0300
@@ -34,7 +34,7 @@
 
 	int64_t bytes_limit, count_limit;
 	/* relative to default_rule */
-	unsigned int bytes_percent, count_percent;
+	int bytes_percent, count_percent;
 
 	/* Don't include this mailbox in quota */
 	unsigned int ignore:1;
diff -r f5bb9f6b304d -r 74d639b2a5bf src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Tue Sep 18 18:44:46 2012 +0300
+++ b/src/plugins/quota/quota.c	Tue Sep 18 19:16:04 2012 +0300
@@ -361,7 +361,7 @@
 {
 	int64_t percentage = *limit;
 
-	if (percentage <= 0 || percentage >= -1U) {
+	if (percentage <= -100 || percentage >= -1U) {
 		*error_r = p_strdup_printf(root_set->set->pool,
 			"Invalid rule percentage: %lld", (long long)percentage);
 		return -1;
@@ -385,9 +385,9 @@
 quota_rule_recalculate_relative_rules(struct quota_rule *rule,
 				      int64_t bytes_limit, int64_t count_limit)
 {
-	if (rule->bytes_percent > 0)
+	if (rule->bytes_percent != 0)
 		rule->bytes_limit = bytes_limit * rule->bytes_percent / 100;
-	if (rule->count_percent > 0)
+	if (rule->count_percent != 0)
 		rule->count_limit = count_limit * rule->count_percent / 100;
 }
 


More information about the dovecot-cvs mailing list