diff options
author | Yann Ylavic <ylavic@apache.org> | 2020-11-23 14:38:59 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2020-11-23 14:38:59 +0000 |
commit | 37e773fd76e806ce9ecf72ed983f92a76ab0550c (patch) | |
tree | 6bf7675ead01bec4394e09a13644915b157b475d /memory | |
parent | b38864b817471983eac0784871acdc255bd11532 (diff) | |
download | apr-37e773fd76e806ce9ecf72ed983f92a76ab0550c.tar.gz |
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/trunk@1883749 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory')
-rw-r--r-- | memory/unix/apr_pools.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index 3306a323e..343a30f59 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -2519,14 +2519,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) { @@ -2543,12 +2539,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); @@ -2567,6 +2569,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, |