From: Stephan Bosch Date: Tue, 9 Nov 2021 22:19:23 +0000 (+0100) Subject: quota: quota-util - Rework comments in quota_is_over() X-Git-Tag: 2.4.1~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9525e51858d450169cbe0083e8a40375eb219d19;p=thirdparty%2Fdovecot%2Fcore.git quota: quota-util - Rework comments in quota_is_over() --- diff --git a/src/plugins/quota/quota-util.c b/src/plugins/quota/quota-util.c index 5088e3d296..3e83b66504 100644 --- a/src/plugins/quota/quota-util.c +++ b/src/plugins/quota/quota-util.c @@ -58,32 +58,48 @@ static inline bool quota_is_over(uoff_t alloc, int64_t used, uint64_t ceil, uint64_t over) { if (used < 0) { + /* Resource usage decreased in this transaction. */ const uint64_t deleted = (uint64_t)-used; - /* we've deleted some messages. */ if (over > 0) { + /* We were over quota before deleting the messages. */ if (over > deleted) { - /* even after deletions we're over quota */ + /* We are over quota, even after deletions and + without the new allocation. */ return TRUE; } - if (alloc > (deleted - over)) + if (alloc > (deleted - over)) { + /* We are under quota after deletions, but the + the new allocation exceeds the quota once + more. */ return TRUE; + } } else { - if (alloc > deleted && (alloc - deleted) > ceil) + /* We were under quota even before deleting the + messages. */ + if (alloc > deleted && (alloc - deleted) > ceil) { + /* The new allocation exceeds the quota limit. + */ return TRUE; + } } } else if (alloc == 0) { - /* we need to explicitly test this case, since the generic - check would fail if user is already over quota */ - if (over > 0) + /* Nothing was allocated in this transaction. We need to + explicitly test this case, since the generic check would fail + if user is already over quota. */ + if (over > 0) { + /* Resource usage is already over quota. */ return TRUE; + } } else { + /* Resource usage increased in this transaction. */ if (ceil < alloc || (ceil - alloc) < (uint64_t)used) { - /* limit reached */ + /* Limit reached. */ return TRUE; } } + /* Not over quota. */ return FALSE; }