1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-33161 Function pointer signature mismatch in LF_HASH

In cmake -DWITH_UBSAN=ON builds with clang but not with GCC,
-fsanitize=undefined will flag several runtime errors on
function pointer mismatch related to the lock-free hash table LF_HASH.

Let us use matching function signatures and remove function pointer
casts in order to avoid potential bugs due to undefined behaviour.

These errors could be caught at compilation time by
-Wcast-function-type-strict, which is available starting with clang-16,
but not available in any version of GCC as of now. The old GCC flag
-Wcast-function-type is enabled as part of -Wextra, but it specifically
does not catch these errors.

Reviewed by: Vladislav Vaintroub
This commit is contained in:
Marko Mäkelä
2024-06-10 12:35:33 +03:00
parent 246c0b3a35
commit a2bd936c52
12 changed files with 137 additions and 131 deletions

View File

@@ -424,8 +424,10 @@ static void wt_resource_destroy(uchar *arg)
It's called from lf_hash when an element is inserted.
*/
static void wt_resource_init(LF_HASH *hash __attribute__((unused)),
WT_RESOURCE *rc, WT_RESOURCE_ID *id)
void *resource, const void *ident)
{
WT_RESOURCE *rc= resource;
const WT_RESOURCE_ID *id= ident;
DBUG_ENTER("wt_resource_init");
rc->id= *id;
rc->waiter_count= 0;