diff options
author | Zhidao HONG <z.hong@f5.com> | 2022-02-22 19:18:18 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2022-02-22 19:18:18 +0800 |
commit | aeed86c6829c62359e79f239b849766efb8857a7 (patch) | |
tree | d88bd07c7d49dddac650dc4d5897544351bfb122 /src/nxt_malloc.c | |
parent | 170752e96fe06cbf78037ad50563d25ce5e668ec (diff) | |
download | unit-aeed86c6829c62359e79f239b849766efb8857a7.tar.gz unit-aeed86c6829c62359e79f239b849766efb8857a7.tar.bz2 |
Workaround for the warning in nxt_realloc() on GCC 12.
This closes #639 issue on Github.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_malloc.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/nxt_malloc.c b/src/nxt_malloc.c index fed58e96..5ea7322f 100644 --- a/src/nxt_malloc.c +++ b/src/nxt_malloc.c @@ -64,17 +64,24 @@ nxt_zalloc(size_t size) void * nxt_realloc(void *p, size_t size) { - void *n; + void *n; + uintptr_t ptr; + + /* + * Workaround for a warning on GCC 12 about using "p" pointer in debug log + * after realloc(). + */ + ptr = (uintptr_t) p; n = realloc(p, size); if (nxt_fast_path(n != NULL)) { - nxt_log_debug(nxt_malloc_log(), "realloc(%p, %uz): %p", p, size, n); + nxt_log_debug(nxt_malloc_log(), "realloc(%p, %uz): %p", ptr, size, n); } else { nxt_log_alert_moderate(&nxt_malloc_log_moderation, nxt_malloc_log(), "realloc(%p, %uz) failed %E", - p, size, nxt_errno); + ptr, size, nxt_errno); } return n; |