From aeed86c6829c62359e79f239b849766efb8857a7 Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Tue, 22 Feb 2022 19:18:18 +0800 Subject: Workaround for the warning in nxt_realloc() on GCC 12. This closes #639 issue on Github. --- src/nxt_malloc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/nxt_malloc.c') 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; -- cgit