Skip to content

Commit b82557e

Browse files
committed
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
1 parent eb5ad4f commit b82557e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/backend/utils/mmgr/aset.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,10 +1024,8 @@ AllocSetFree(void *pointer)
10241024

10251025
#ifdef MEMORY_CONTEXT_CHECKING
10261026
{
1027-
Size chunk_size = block->endptr - (char *) pointer;
1028-
10291027
/* Test for someone scribbling on unused space in chunk */
1030-
Assert(chunk->requested_size < chunk_size);
1028+
Assert(chunk->requested_size < (block->endptr - (char *) pointer));
10311029
if (!sentinel_ok(pointer, chunk->requested_size))
10321030
elog(WARNING, "detected write past chunk end in %s %p",
10331031
set->header.name, chunk);

src/backend/utils/mmgr/generation.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,8 @@ GenerationFree(void *pointer)
629629
MemoryChunk *chunk = PointerGetMemoryChunk(pointer);
630630
GenerationBlock *block;
631631
GenerationContext *set;
632-
#if defined(MEMORY_CONTEXT_CHECKING) || defined(CLOBBER_FREED_MEMORY)
632+
#if (defined(MEMORY_CONTEXT_CHECKING) && defined(USE_ASSERT_CHECKING)) \
633+
|| defined(CLOBBER_FREED_MEMORY)
633634
Size chunksize;
634635
#endif
635636

@@ -644,7 +645,8 @@ GenerationFree(void *pointer)
644645
if (!GenerationBlockIsValid(block))
645646
elog(ERROR, "could not find block containing chunk %p", chunk);
646647

647-
#if defined(MEMORY_CONTEXT_CHECKING) || defined(CLOBBER_FREED_MEMORY)
648+
#if (defined(MEMORY_CONTEXT_CHECKING) && defined(USE_ASSERT_CHECKING)) \
649+
|| defined(CLOBBER_FREED_MEMORY)
648650
chunksize = block->endptr - (char *) pointer;
649651
#endif
650652
}
@@ -659,7 +661,8 @@ GenerationFree(void *pointer)
659661
*/
660662
Assert(GenerationBlockIsValid(block));
661663

662-
#if defined(MEMORY_CONTEXT_CHECKING) || defined(CLOBBER_FREED_MEMORY)
664+
#if (defined(MEMORY_CONTEXT_CHECKING) && defined(USE_ASSERT_CHECKING)) \
665+
|| defined(CLOBBER_FREED_MEMORY)
663666
chunksize = MemoryChunkGetValue(chunk);
664667
#endif
665668
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy