aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2023-01-05 12:56:17 +1300
committerDavid Rowley <drowley@postgresql.org>2023-01-05 12:56:17 +1300
commitb82557ecc2ebbf649142740a1c5ce8d19089f620 (patch)
treef1fe4e679aef1118070b87601e396e0af10ad0ef /src
parenteb5ad4ff05fd382ac98cab60b82f7fd6ce4cfeb8 (diff)
downloadpostgresql-b82557ecc2ebbf649142740a1c5ce8d19089f620.tar.gz
postgresql-b82557ecc2ebbf649142740a1c5ce8d19089f620.zip
Fix some compiler warnings in aset.c and generation.c
This fixes a couple of unused variable warnings that could be seen when compiling with MEMORY_CONTEXT_CHECKING but not USE_ASSERT_CHECKING. Defining MEMORY_CONTEXT_CHECKING without asserts is a little unusual, however, we shouldn't be producing any warnings from such a build. Author: Richard Guo Discussion: https://postgr.es/m/CAMbWs4_D-vgLEh7eO47p=73u1jWO78NWf6Qfv1FndY1kG-Q-jA@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/mmgr/aset.c4
-rw-r--r--src/backend/utils/mmgr/generation.c9
2 files changed, 7 insertions, 6 deletions
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index ef10bb1690b..740729b5d08 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -1024,10 +1024,8 @@ AllocSetFree(void *pointer)
#ifdef MEMORY_CONTEXT_CHECKING
{
- Size chunk_size = block->endptr - (char *) pointer;
-
/* Test for someone scribbling on unused space in chunk */
- Assert(chunk->requested_size < chunk_size);
+ Assert(chunk->requested_size < (block->endptr - (char *) pointer));
if (!sentinel_ok(pointer, chunk->requested_size))
elog(WARNING, "detected write past chunk end in %s %p",
set->header.name, chunk);
diff --git a/src/backend/utils/mmgr/generation.c b/src/backend/utils/mmgr/generation.c
index 93825265a1b..ebcb61e9b6a 100644
--- a/src/backend/utils/mmgr/generation.c
+++ b/src/backend/utils/mmgr/generation.c
@@ -629,7 +629,8 @@ GenerationFree(void *pointer)
MemoryChunk *chunk = PointerGetMemoryChunk(pointer);
GenerationBlock *block;
GenerationContext *set;
-#if defined(MEMORY_CONTEXT_CHECKING) || defined(CLOBBER_FREED_MEMORY)
+#if (defined(MEMORY_CONTEXT_CHECKING) && defined(USE_ASSERT_CHECKING)) \
+ || defined(CLOBBER_FREED_MEMORY)
Size chunksize;
#endif
@@ -644,7 +645,8 @@ GenerationFree(void *pointer)
if (!GenerationBlockIsValid(block))
elog(ERROR, "could not find block containing chunk %p", chunk);
-#if defined(MEMORY_CONTEXT_CHECKING) || defined(CLOBBER_FREED_MEMORY)
+#if (defined(MEMORY_CONTEXT_CHECKING) && defined(USE_ASSERT_CHECKING)) \
+ || defined(CLOBBER_FREED_MEMORY)
chunksize = block->endptr - (char *) pointer;
#endif
}
@@ -659,7 +661,8 @@ GenerationFree(void *pointer)
*/
Assert(GenerationBlockIsValid(block));
-#if defined(MEMORY_CONTEXT_CHECKING) || defined(CLOBBER_FREED_MEMORY)
+#if (defined(MEMORY_CONTEXT_CHECKING) && defined(USE_ASSERT_CHECKING)) \
+ || defined(CLOBBER_FREED_MEMORY)
chunksize = MemoryChunkGetValue(chunk);
#endif
}