summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2020-11-23 16:10:43 +0000
committerYann Ylavic <ylavic@apache.org>2020-11-23 16:10:43 +0000
commita6fc15853e813e8d844dc85b33c7ab0572d390e2 (patch)
tree96f1bc70e6424d9e3459a24bcf5849a994cd9aad
parent2b85c175f7e03047f3249abc63dc0834e9ce5ef2 (diff)
downloadapr-a6fc15853e813e8d844dc85b33c7ab0572d390e2.tar.gz
Merge r1883749 from trunk:
apr_pools: fix __attribute__((nonnull)) warning in [pre_]cleanup_register. Since apr_[pre_]cleanup_register() functions are declared ((nonnull)) for plain_cleanup_fn and child_cleanup_fn, the compiler (gcc-9 here) issues a warning when we check them for !NULL is the code. To preserve APR_POOL_DEBUG checks still with compilers that don't support this __attribute__, let's work around this by checking NULL values afterward for c, c->plain_cleanup_fn and c->child_cleanup_fn. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1883752 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--memory/unix/apr_pools.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index 9bc4bdb51..3a21aef24 100644
--- a/memory/unix/apr_pools.c
+++ b/memory/unix/apr_pools.c
@@ -2511,14 +2511,10 @@ APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data,
apr_status_t (*plain_cleanup_fn)(void *data),
apr_status_t (*child_cleanup_fn)(void *data))
{
- cleanup_t *c;
+ cleanup_t *c = NULL;
#if APR_POOL_DEBUG
apr_pool_check_integrity(p);
-
- if (!p || !plain_cleanup_fn || !child_cleanup_fn) {
- abort();
- }
#endif /* APR_POOL_DEBUG */
if (p != NULL) {
@@ -2535,12 +2531,18 @@ APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data,
c->next = p->cleanups;
p->cleanups = c;
}
+
+#if APR_POOL_DEBUG
+ if (!c || !c->plain_cleanup_fn || !c->child_cleanup_fn) {
+ abort();
+ }
+#endif /* APR_POOL_DEBUG */
}
APR_DECLARE(void) apr_pool_pre_cleanup_register(apr_pool_t *p, const void *data,
apr_status_t (*plain_cleanup_fn)(void *data))
{
- cleanup_t *c;
+ cleanup_t *c = NULL;
#if APR_POOL_DEBUG
apr_pool_check_integrity(p);
@@ -2559,6 +2561,12 @@ APR_DECLARE(void) apr_pool_pre_cleanup_register(apr_pool_t *p, const void *data,
c->next = p->pre_cleanups;
p->pre_cleanups = c;
}
+
+#if APR_POOL_DEBUG
+ if (!c || !c->plain_cleanup_fn) {
+ abort();
+ }
+#endif /* APR_POOL_DEBUG */
}
APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data,