You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-03 00:26:59 +02:00
Use uintptr_t in ASSERT_ALLOC_VALID() to avoid pointer arithmetic.
Clang justifiably complains about pointer arithmetic on a known NULL value during testing. We know this is fine but use uintptr_t to silence the warnings. Found on MacOS M1.
This commit is contained in:
@ -41,7 +41,7 @@ typedef struct MemContextAlloc
|
|||||||
// belongs to another context. Otherwise, there is likely to be a segfault.
|
// belongs to another context. Otherwise, there is likely to be a segfault.
|
||||||
#define ASSERT_ALLOC_VALID(alloc) \
|
#define ASSERT_ALLOC_VALID(alloc) \
|
||||||
ASSERT( \
|
ASSERT( \
|
||||||
alloc != NULL && alloc != MEM_CONTEXT_ALLOC_HEADER(NULL) && \
|
alloc != NULL && (uintptr_t)alloc != (uintptr_t)-sizeof(MemContextAlloc) && \
|
||||||
alloc->allocIdx < memContextStack[memContextCurrentStackIdx].memContext->allocListSize && \
|
alloc->allocIdx < memContextStack[memContextCurrentStackIdx].memContext->allocListSize && \
|
||||||
memContextStack[memContextCurrentStackIdx].memContext->allocList[alloc->allocIdx]);
|
memContextStack[memContextCurrentStackIdx].memContext->allocList[alloc->allocIdx]);
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ testRun(void)
|
|||||||
TEST_ERROR(
|
TEST_ERROR(
|
||||||
memFree(NULL), AssertError,
|
memFree(NULL), AssertError,
|
||||||
"assertion '((MemContextAlloc *)buffer - 1) != NULL"
|
"assertion '((MemContextAlloc *)buffer - 1) != NULL"
|
||||||
" && ((MemContextAlloc *)buffer - 1) != MEM_CONTEXT_ALLOC_HEADER(NULL)"
|
" && (uintptr_t)((MemContextAlloc *)buffer - 1) != (uintptr_t)-sizeof(MemContextAlloc)"
|
||||||
" && ((MemContextAlloc *)buffer - 1)->allocIdx <"
|
" && ((MemContextAlloc *)buffer - 1)->allocIdx <"
|
||||||
" memContextStack[memContextCurrentStackIdx].memContext->allocListSize"
|
" memContextStack[memContextCurrentStackIdx].memContext->allocListSize"
|
||||||
" && memContextStack[memContextCurrentStackIdx].memContext->allocList[((MemContextAlloc *)buffer - 1)->allocIdx]'"
|
" && memContextStack[memContextCurrentStackIdx].memContext->allocList[((MemContextAlloc *)buffer - 1)->allocIdx]'"
|
||||||
|
Reference in New Issue
Block a user