From: Martti Rannanjärvi Date: Mon, 16 Oct 2017 19:35:31 +0000 (+0300) Subject: quota-dict: Remove T_BEGIN..T_END blocks X-Git-Tag: 2.3.0.rc1~811 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5729882717902b5f3f5d62f71ddf2894b67fc7a6;p=thirdparty%2Fdovecot%2Fcore.git quota-dict: Remove T_BEGIN..T_END blocks This is to enable using t_strdup_printf() with error_r later on. --- diff --git a/src/plugins/quota/quota-dict.c b/src/plugins/quota/quota-dict.c index bec5e5f3b5..262c04a904 100644 --- a/src/plugins/quota/quota-dict.c +++ b/src/plugins/quota/quota-dict.c @@ -115,20 +115,18 @@ dict_quota_count(struct dict_quota_root *root, if (quota_count(&root->root, &bytes, &count) < 0) return -1; - T_BEGIN { - dt = dict_transaction_begin(root->dict); - /* these unsets are mainly necessary for pgsql, because its - trigger otherwise increases quota without deleting it. - but some people with other databases want to store the - quota usage among other data in the same row, which - shouldn't be deleted. */ - if (!root->disable_unset) { - dict_unset(dt, DICT_QUOTA_CURRENT_BYTES_PATH); - dict_unset(dt, DICT_QUOTA_CURRENT_COUNT_PATH); - } - dict_set(dt, DICT_QUOTA_CURRENT_BYTES_PATH, dec2str(bytes)); - dict_set(dt, DICT_QUOTA_CURRENT_COUNT_PATH, dec2str(count)); - } T_END; + dt = dict_transaction_begin(root->dict); + /* these unsets are mainly necessary for pgsql, because its + trigger otherwise increases quota without deleting it. + but some people with other databases want to store the + quota usage among other data in the same row, which + shouldn't be deleted. */ + if (!root->disable_unset) { + dict_unset(dt, DICT_QUOTA_CURRENT_BYTES_PATH); + dict_unset(dt, DICT_QUOTA_CURRENT_COUNT_PATH); + } + dict_set(dt, DICT_QUOTA_CURRENT_BYTES_PATH, dec2str(bytes)); + dict_set(dt, DICT_QUOTA_CURRENT_COUNT_PATH, dec2str(count)); if (root->root.quota->set->debug) { i_debug("dict quota: Quota recalculated: " @@ -155,31 +153,29 @@ dict_quota_get_resource(struct quota_root *_root, else return 0; - T_BEGIN { - const char *key, *value, *error; - - key = want_bytes ? DICT_QUOTA_CURRENT_BYTES_PATH : - DICT_QUOTA_CURRENT_COUNT_PATH; - ret = dict_lookup(root->dict, unsafe_data_stack_pool, - key, &value, &error); - if (ret < 0) { - i_error("dict quota: dict_lookup(%s) failed: %s", key, error); - *value_r = 0; - } else { - intmax_t tmp; - - /* recalculate quota if it's negative or if it - wasn't found */ - if (ret == 0 || str_to_intmax(value, &tmp) < 0) - tmp = -1; - if (tmp >= 0) - *value_r = tmp; - else { - ret = dict_quota_count(root, want_bytes, - value_r); - } + const char *key, *value, *error; + + key = want_bytes ? DICT_QUOTA_CURRENT_BYTES_PATH : + DICT_QUOTA_CURRENT_COUNT_PATH; + ret = dict_lookup(root->dict, unsafe_data_stack_pool, + key, &value, &error); + if (ret < 0) { + i_error("dict quota: dict_lookup(%s) failed: %s", key, error); + *value_r = 0; + } else { + intmax_t tmp; + + /* recalculate quota if it's negative or if it + wasn't found */ + if (ret == 0 || str_to_intmax(value, &tmp) < 0) + tmp = -1; + if (tmp >= 0) + *value_r = tmp; + else { + ret = dict_quota_count(root, want_bytes, + value_r); } - } T_END; + } return ret; }