Skip to content
Snippets Groups Projects
Commit 0289433a authored by Denis Smirnov's avatar Denis Smirnov Committed by Kirill Yukhin
Browse files

sql: fix -Wnull-pointer-subtraction warning


clang 13 includes a check for subtraction from NULL pointer which
is considered UB: historically, we had an alignment checking macro
which is affected by this. It seems like the intention of the
macro's author was to implicitly cast the pointer being checked to
uintptr_t without including stddef.h — replace this subtraction
with an explicit cast.

There is no way to set SQL_4_BYTE_ALIGNED_MALLOC, so the corresponding
part of the code was removed. Now there are only 8 byte alignment
assertions.

NO_CHANGELOG=UB fix
NO_DOC=UB fix
NO_TEST=UB fix

Co-authored-by: default avatarGeorgiy Lebedev <curiousgeorgiy@gmail.com>
parent 76e09548
No related branches found
No related tags found
No related merge requests found
......@@ -832,16 +832,8 @@ typedef u64 uptr;
* Assert that the pointer X is aligned to an 8-byte boundary. This
* macro is used only within assert() to verify that the code gets
* all alignment restrictions correct.
*
* Except, if sql_4_BYTE_ALIGNED_MALLOC is defined, then the
* underlying malloc() implementation might return us 4-byte aligned
* pointers. In that case, only verify 4-byte alignment.
*/
#ifdef SQL_4_BYTE_ALIGNED_MALLOC
#define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&3)==0)
#else
#define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0)
#endif
#define EIGHT_BYTE_ALIGNMENT(X) ((((uintptr_t)((char *)(X))) & 7) == 0)
/*
* Default maximum size of memory used by memory-mapped I/O in the VFS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment