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
This commit is contained in:
David Rowley 2023-01-05 12:56:17 +13:00
parent eb5ad4ff05
commit b82557ecc2
2 changed files with 7 additions and 6 deletions

View File

@ -1024,10 +1024,8 @@ AllocSetFree(void *pointer)
#ifdef MEMORY_CONTEXT_CHECKING #ifdef MEMORY_CONTEXT_CHECKING
{ {
Size chunk_size = block->endptr - (char *) pointer;
/* Test for someone scribbling on unused space in chunk */ /* 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)) if (!sentinel_ok(pointer, chunk->requested_size))
elog(WARNING, "detected write past chunk end in %s %p", elog(WARNING, "detected write past chunk end in %s %p",
set->header.name, chunk); set->header.name, chunk);

View File

@ -629,7 +629,8 @@ GenerationFree(void *pointer)
MemoryChunk *chunk = PointerGetMemoryChunk(pointer); MemoryChunk *chunk = PointerGetMemoryChunk(pointer);
GenerationBlock *block; GenerationBlock *block;
GenerationContext *set; 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; Size chunksize;
#endif #endif
@ -644,7 +645,8 @@ GenerationFree(void *pointer)
if (!GenerationBlockIsValid(block)) if (!GenerationBlockIsValid(block))
elog(ERROR, "could not find block containing chunk %p", chunk); 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; chunksize = block->endptr - (char *) pointer;
#endif #endif
} }
@ -659,7 +661,8 @@ GenerationFree(void *pointer)
*/ */
Assert(GenerationBlockIsValid(block)); 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); chunksize = MemoryChunkGetValue(chunk);
#endif #endif
} }