]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Prefix quota errors with backend name in quota_get_resource()
authorMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Fri, 3 Nov 2017 14:17:44 +0000 (16:17 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Thu, 9 Nov 2017 10:52:11 +0000 (12:52 +0200)
Remove quota backend name error_r prefixing from get_resource() vfuncs.

src/plugins/quota/quota-count.c
src/plugins/quota/quota-dict.c
src/plugins/quota/quota-dirsize.c
src/plugins/quota/quota-fs.c
src/plugins/quota/quota-imapc.c
src/plugins/quota/quota-maildir.c
src/plugins/quota/quota.c

index 46d468a2d4b7bd3fe6c18278633324de41dcff18..be625da74fac3f05584bc802ba6ba857c7771c7c 100644 (file)
@@ -269,15 +269,11 @@ count_quota_get_resource(struct quota_root *_root,
 {
        struct count_quota_root *root = (struct count_quota_root *)_root;
        uint64_t bytes, count;
-       const char *error;
        enum quota_get_result ret;
 
-       ret = quota_count_cached(root, &bytes, &count, &error);
-       if (ret <= QUOTA_GET_RESULT_INTERNAL_ERROR) {
-               *error_r = t_strdup_printf(
-                       "quota-count: Failed to get %s: %s", name, error);
+       ret = quota_count_cached(root, &bytes, &count, error_r);
+       if (ret <= QUOTA_GET_RESULT_INTERNAL_ERROR)
                return ret;
-       }
 
        if (strcmp(name, QUOTA_NAME_STORAGE_BYTES) == 0)
                *value_r = bytes;
index 78db037fdd2c5a9c7a35bd2d99019424f05247dc..be7eec581531525cfed43d40623dd920e4edb2e5 100644 (file)
@@ -112,14 +112,10 @@ dict_quota_count(struct dict_quota_root *root,
 {
        struct dict_transaction_context *dt;
        uint64_t bytes, count;
-       const char *error;
        enum quota_get_result error_res;
 
-       if (quota_count(&root->root, &bytes, &count, &error_res, &error) < 0) {
-               *error_r = t_strdup_printf(
-                       "quota-dict count failed: %s", error);
+       if (quota_count(&root->root, &bytes, &count, &error_res, error_r) < 0)
                return error_res;
-       }
 
        dt = dict_transaction_begin(root->dict);
        /* these unsets are mainly necessary for pgsql, because its
@@ -169,7 +165,7 @@ dict_quota_get_resource(struct quota_root *_root,
                          key, &value, &error);
        if (ret < 0) {
                *error_r = t_strdup_printf(
-                       "quota-dict: dict_lookup(%s) failed: %s", key, error);
+                       "dict_lookup(%s) failed: %s", key, error);
                *value_r = 0;
                return QUOTA_GET_RESULT_INTERNAL_ERROR;
        }
@@ -193,7 +189,7 @@ static void dict_quota_recalc_timeout(struct dict_quota_root *root)
        timeout_remove(&root->to_update);
        if (dict_quota_count(root, TRUE, &value, &error)
            <= QUOTA_GET_RESULT_INTERNAL_ERROR)
-               i_error("%s", error);
+               i_error("quota-dict: Recalculation failed: %s", error);
 }
 
 static void dict_quota_update_callback(const struct dict_commit_result *result,
index a8e1f59104767420fe4a799649cd284d11eaa66b..07b25d7c2bcb003e444ee69d8d090ebbd18fb6e7 100644 (file)
@@ -204,12 +204,7 @@ dirsize_quota_get_resource(struct quota_root *_root, const char *name,
                return QUOTA_GET_RESULT_UNKNOWN_RESOURCE;
        }
 
-       const char *error;
-       ret = get_quota_root_usage(_root, value_r, &error);
-       if (ret < 0)
-               *error_r = t_strdup_printf(
-                       "quota-dirsize: failed to get resource %s: %s",
-                       name, error);
+       ret = get_quota_root_usage(_root, value_r, error_r);
 
        return ret < 0 ? QUOTA_GET_RESULT_INTERNAL_ERROR : QUOTA_GET_RESULT_LIMITED;
 }
index 0df65af18e3891165534b7e2461fbb097a7b44aa..a61e075d180c156bbd1c4c038ddc340741f37a23 100644 (file)
@@ -400,7 +400,7 @@ do_rquota_user(struct fs_quota_root *root,
        cl = clnt_create(host, RQUOTAPROG, RQUOTAVERS, "udp");
        if (cl == NULL) {
                *error_r = t_strdup_printf(
-                       "quota-fs: could not contact RPC service on %s", host);
+                       "could not contact RPC service on %s", host);
                return -1;
        }
 
@@ -427,7 +427,7 @@ do_rquota_user(struct fs_quota_root *root,
                const char *rpc_error_msg = clnt_sperrno(call_status);
 
                *error_r = t_strdup_printf(
-                       "quota-fs: remote rquota call failed: %s",
+                       "remote rquota call failed: %s",
                        rpc_error_msg);
                return -1;
        }
@@ -454,12 +454,12 @@ do_rquota_user(struct fs_quota_root *root,
                fs_quota_root_disable(root, FALSE);
                return 0;
        case Q_EPERM:
-               *error_r = "quota-fs: permission denied to rquota service";
+               *error_r = "permission denied to rquota service";
                return -1;
        default:
                *error_r = t_strdup_printf(
-                       "quota-fs: unrecognized status code (%d) "
-                       "from rquota service", result.status);
+                       "unrecognized status code (%d) from rquota service",
+                       result.status);
                return -1;
        }
 }
@@ -497,8 +497,7 @@ do_rquota_group(struct fs_quota_root *root ATTR_UNUSED,
        cl = clnt_create(host, RQUOTAPROG, EXT_RQUOTAVERS, "udp");
        if (cl == NULL) {
                *error_r = t_strdup_printf(
-                       "quota-fs: could not contact RPC service on %s (group)",
-                       host);
+                       "could not contact RPC service on %s (group)", host);
                return -1;
        }
 
@@ -526,8 +525,7 @@ do_rquota_group(struct fs_quota_root *root ATTR_UNUSED,
                const char *rpc_error_msg = clnt_sperrno(call_status);
 
                *error_r = t_strdup_printf(
-                       "quota-fs: remote ext rquota call failed: %s",
-                       rpc_error_msg);
+                       "remote ext rquota call failed: %s", rpc_error_msg);
                return -1;
        }
 
@@ -553,16 +551,16 @@ do_rquota_group(struct fs_quota_root *root ATTR_UNUSED,
                fs_quota_root_disable(root, TRUE);
                return 0;
        case Q_EPERM:
-               *error_r = "quota-fs: permission denied to ext rquota service";
+               *error_r = "permission denied to ext rquota service";
                return -1;
        default:
                *error_r = t_strdup_printf(
-                       "quota-fs: unrecognized status code (%d) "
-                       "from ext rquota service", result.status);
+                       "unrecognized status code (%d) from ext rquota service",
+                       result.status);
                return -1;
        }
 #else
-       *error_r = "quota-fs: rquota not compiled with group support";
+       *error_r = "rquota not compiled with group support";
        return -1;
 #endif
 }
@@ -593,7 +591,7 @@ fs_quota_get_linux(struct fs_quota_root *root, bool group,
                                return 0;
                        }
                        *error_r = t_strdup_printf(
-                               "quota-fs: %d quotactl(Q_XGETQUOTA, %s) failed: %m",
+                               "errno=%d, quotactl(Q_XGETQUOTA, %s) failed: %m",
                                errno, root->mount->device_path);
                        return -1;
                }
@@ -621,7 +619,7 @@ fs_quota_get_linux(struct fs_quota_root *root, bool group,
                                return 0;
                        }
                        *error_r = t_strdup_printf(
-                               "quota-fs: quotactl(Q_GETQUOTA, %s) failed: %m",
+                               "quotactl(Q_GETQUOTA, %s) failed: %m",
                                root->mount->device_path);
                        if (errno == EINVAL) {
                                *error_r = t_strdup_printf("%s, "
@@ -674,7 +672,7 @@ fs_quota_get_bsdaix(struct fs_quota_root *root, bool group,
                        return 0;
                }
                *error_r = t_strdup_printf(
-                       "quota-fs: quotactl(Q_GETQUOTA, %s) failed: %m",
+                       "quotactl(Q_GETQUOTA, %s) failed: %m",
                        root->mount->mount_path);
                return -1;
        }
@@ -705,9 +703,8 @@ fs_quota_get_netbsd(struct fs_quota_root *root, bool group,
        int ret;
 
        if ((qh = quota_open(root->mount->mount_path)) == NULL) {
-               *error_r = t_strdup_printf(
-                       "quota-fs: cannot open quota for %s: %m",
-                       root->mount->mount_path);
+               *error_r = t_strdup_printf("cannot open quota for %s: %m",
+                                          root->mount->mount_path);
                fs_quota_root_disable(root, group);
                return 0;
        }
@@ -724,7 +721,7 @@ fs_quota_get_netbsd(struct fs_quota_root *root, bool group,
                                return 0;
                        }
                        *error_r = t_strdup_printf(
-                               "quota-fs: quotactl(Q_GETQUOTA, %s) failed: %m",
+                               "quotactl(Q_GETQUOTA, %s) failed: %m",
                                root->mount->mount_path);
                        ret = -1;
                        break;
@@ -759,7 +756,7 @@ fs_quota_get_hpux(struct fs_quota_root *root,
                        return 0;
                }
                *error_r = t_strdup_printf(
-                       "quota-fs: quotactl(Q_GETQUOTA, %s) failed: %m",
+                       "quotactl(Q_GETQUOTA, %s) failed: %m",
                        root->mount->device_path);
                return -1;
        }
@@ -799,7 +796,7 @@ fs_quota_get_solaris(struct fs_quota_root *root,
        ctl.addr = (caddr_t)&dqblk;
        if (ioctl(root->mount->fd, Q_QUOTACTL, &ctl) < 0) {
                *error_r = t_strdup_printf(
-                       "quota-fs: ioctl(%s, Q_QUOTACTL) failed: %m",
+                       "ioctl(%s, Q_QUOTACTL) failed: %m",
                        root->mount->path);
                return -1;
        }
index 744d12b409740f414d268527206dae37ccbef3e6..8efe240bcc7c9ce36dee7cd1041f60e446b480ec 100644 (file)
@@ -368,7 +368,6 @@ static int imapc_quota_refresh(struct imapc_quota_root *root,
                               const char **error_r)
 {
        enum imapc_capability capa;
-       const char *error = ""; /* Initialize this to avoid a gcc warning. */
        int ret;
 
        if (root->imapc_ns == NULL) {
@@ -382,7 +381,7 @@ static int imapc_quota_refresh(struct imapc_quota_root *root,
                return 0;
 
        if (imapc_client_get_capabilities(root->client->client, &capa) < 0) {
-               *error_r = "quota-imapc: Failed to get server capabilities";
+               *error_r = "Failed to get server capabilities";
                return -1;
        }
        if ((capa & IMAPC_CAPABILITY_QUOTA) == 0) {
@@ -393,11 +392,9 @@ static int imapc_quota_refresh(struct imapc_quota_root *root,
        }
 
        if (root->root_name == NULL)
-               ret = imapc_quota_refresh_mailbox(root, &error);
+               ret = imapc_quota_refresh_mailbox(root, error_r);
        else
-               ret = imapc_quota_refresh_root(root, &error);
-       if (ret < 0)
-               *error_r = t_strdup_printf("quota-imapc: %s", error);
+               ret = imapc_quota_refresh_root(root, error_r);
 
        /* set the last_refresh only after the refresh, because it changes
           ioloop_timeval. */
index e5b19c1792407746068c6b383e845110e9fe55f5..0b779312ca4a5ba50d6e2afb60cb392b73ac6f53 100644 (file)
@@ -863,8 +863,7 @@ maildir_quota_get_resource(struct quota_root *_root, const char *name,
        const char *error;
 
        if (maildirquota_refresh(root, &recalculated, &error) < 0) {
-               *error_r = t_strdup_printf(
-                       "quota-maildir: Failed to get %s: %s", name, error);
+               *error_r = t_strdup_printf("Failed to get %s: %s", name, error);
                return QUOTA_GET_RESULT_INTERNAL_ERROR;
        }
 
index ebfa710e29a677069e150e146ba4e7c196f58b40..b130f3c4bd93b28f746ac5c29faa237c88740317 100644 (file)
@@ -775,13 +775,16 @@ quota_get_resource(struct quota_root *root, const char *mailbox_name,
 
        /* Get the value first. This call may also update quota limits if
           they're defined externally. */
-       ret = root->backend.v.get_resource(root, name, value_r, error_r);
+       ret = root->backend.v.get_resource(root, name, value_r, &error);
        if (ret == QUOTA_GET_RESULT_UNLIMITED)
                i_panic("Quota backend %s returned QUOTA_GET_RESULT_UNLIMITED "
                        "while getting resource %s from box %s",
                        root->backend.name, name, mailbox_name);
-       else if (ret != QUOTA_GET_RESULT_LIMITED)
+       else if (ret != QUOTA_GET_RESULT_LIMITED) {
+               *error_r = t_strdup_printf(
+                       "quota-%s: %s", root->set->backend->name, error);
                return ret;
+       }
 
        if (quota_root_get_rule_limits(root, mailbox_name,
                                       &bytes_limit, &count_limit,