summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminfrin <minfrin@13f79535-47bb-0310-9956-ffa450edef68>2018-09-01 10:25:08 +0000
committerminfrin <minfrin@13f79535-47bb-0310-9956-ffa450edef68>2018-09-01 10:25:08 +0000
commit26f559a5ef9856e44a2a96ae68ec01f19fb8db49 (patch)
treeef65ea285177de608c2e94447f001e74234be756
parentd13f983e9d1629d109a2629da012bcb4c9787694 (diff)
downloadlibapr-26f559a5ef9856e44a2a96ae68ec01f19fb8db49.tar.gz
Simplify apr_errprintf() to return a structure instead of a status.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1839815 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--include/apu_errno.h10
-rw-r--r--util-misc/apr_error.c20
2 files changed, 14 insertions, 16 deletions
diff --git a/include/apu_errno.h b/include/apu_errno.h
index 5c309b4f2..0a8824e69 100644
--- a/include/apu_errno.h
+++ b/include/apu_errno.h
@@ -179,19 +179,19 @@ typedef struct apu_err_t {
* If the result parameter points at a NULL pointer, a apu_err_t
* structure will be allocated, otherwise the apu_err_t structure
* will be reused.
- * @param result If points to NULL, the apu_err_t structure is
- * allocated and returned, otherwise the existing apu_err_t is used.
+ * @param result If NULL, the apu_err_t structure is allocated and
+ * returned, otherwise the existing apu_err_t is used.
* @param p The pool to use.
* @param reason The reason string, may be NULL.
* @param rc The underlying result code.
* @param fmt The format of the string
* @param ... The arguments to use while printing the data
- * @return APR_SUCCESS on success, APR_ENOMEM if out of memory.
+ * @return The apu_err_t structure on success, NULL if out of memory.
*/
-APR_DECLARE_NONSTD(apr_status_t) apr_errprintf(apu_err_t **result,
+APR_DECLARE_NONSTD(apu_err_t *) apr_errprintf(apu_err_t *result,
apr_pool_t *p, const char *reason, int rc, const char *fmt, ...)
__attribute__((format(printf,5,6)))
- __attribute__((nonnull(1,2)));
+ __attribute__((nonnull(2)));
/** @} */
diff --git a/util-misc/apr_error.c b/util-misc/apr_error.c
index a3835e1a9..7cb30cb4e 100644
--- a/util-misc/apr_error.c
+++ b/util-misc/apr_error.c
@@ -19,27 +19,25 @@
#include "apr_pools.h"
#include "apu_errno.h"
-APR_DECLARE_NONSTD(apr_status_t) apr_errprintf(apu_err_t **result,
+APR_DECLARE_NONSTD(apu_err_t *) apr_errprintf(apu_err_t *result,
apr_pool_t *p, const char *reason, int rc, const char *fmt, ...)
{
va_list ap;
- apu_err_t *res;
- res = *result;
- if (!res) {
- res = *result = apr_pcalloc(p, sizeof(apu_err_t));
- if (!res) {
- return APR_ENOMEM;
+ if (!result) {
+ result = apr_pcalloc(p, sizeof(apu_err_t));
+ if (!result) {
+ return NULL;
}
}
va_start(ap, fmt);
- res->msg = apr_pvsprintf(p, fmt, ap);
+ result->msg = apr_pvsprintf(p, fmt, ap);
va_end(ap);
- res->reason = reason;
- res->rc = rc;
+ result->reason = reason;
+ result->rc = rc;
- return APR_SUCCESS;
+ return result;
}