summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2022-02-22 19:18:18 +0800
committerZhidao HONG <z.hong@f5.com>2022-02-22 19:18:18 +0800
commitaeed86c6829c62359e79f239b849766efb8857a7 (patch)
treed88bd07c7d49dddac650dc4d5897544351bfb122
parent170752e96fe06cbf78037ad50563d25ce5e668ec (diff)
downloadunit-aeed86c6829c62359e79f239b849766efb8857a7.tar.gz
unit-aeed86c6829c62359e79f239b849766efb8857a7.tar.bz2
Workaround for the warning in nxt_realloc() on GCC 12.
This closes #639 issue on Github.
-rw-r--r--docs/changes.xml6
-rw-r--r--src/nxt_malloc.c13
2 files changed, 16 insertions, 3 deletions
diff --git a/docs/changes.xml b/docs/changes.xml
index 3ef1ac3f..2e2f9b04 100644
--- a/docs/changes.xml
+++ b/docs/changes.xml
@@ -31,6 +31,12 @@ NGINX Unit updated to 1.27.0.
date="" time=""
packager="Andrei Belov &lt;defan@nginx.com&gt;">
+<change type="feature">
+<para>
+compatibility with GCC 12.
+</para>
+</change>
+
<change type="bugfix">
<para>
the controller process could crash when a chain with more than 4
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;