Skip to content

Commit d9d0e8f

Browse files
committed
MDEV-34321: call to crc32c_3way through pointer to incorrect function type
In commit 9ec7819 the CRC-32 function signatures had been unified somewhat, but not enough. clang -fsanitize=undefined would flag a function pointer signature mismatch between const char* and const void*, but not between uint32_t and unsigned. We try to fix both inconsistencies anyway. Reviewed by: Vladislav Vaintroub
1 parent b7a75fb commit d9d0e8f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

mysys/crc32/crc32c.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ extern "C" const char *my_crc32c_implementation()
526526
} // namespace crc32c
527527
} // namespace mysys_namespace
528528

529-
extern "C" unsigned my_crc32c(unsigned int crc, const char *buf, size_t size)
529+
extern "C" uint32 my_crc32c(uint32 crc, const void *buf, size_t size)
530530
{
531531
return mysys_namespace::crc32c::ChosenExtend(crc,buf, size);
532532
}

mysys/crc32/crc32c_amd64.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ static inline uint64_t CombineCRC(
184184
// Compute CRC-32C using the Intel hardware instruction.
185185
extern "C"
186186
USE_PCLMUL
187-
uint32_t crc32c_3way(uint32_t crc, const char *buf, size_t len)
187+
uint32_t crc32c_3way(uint32_t crc, const void *buf, size_t len)
188188
{
189-
const unsigned char* next = (const unsigned char*)buf;
189+
const unsigned char* next = static_cast<const unsigned char*>(buf);
190190
uint64_t count;
191191
uint64_t crc0, crc1, crc2;
192192
crc0 = crc ^ 0xffffffffu;

mysys/crc32/crc32c_x86.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ static uint32_t cpuid_ecx()
5454
#endif
5555
}
5656

57-
typedef unsigned (*my_crc32_t)(unsigned, const void *, size_t);
58-
extern "C" unsigned int crc32_pclmul(unsigned int, const void *, size_t);
59-
extern "C" unsigned int crc32c_3way(unsigned int, const void *, size_t);
57+
typedef uint32_t (*my_crc32_t)(uint32_t, const void *, size_t);
58+
extern "C" uint32_t crc32_pclmul(uint32_t, const void *, size_t);
59+
extern "C" uint32_t crc32c_3way(uint32_t, const void *, size_t);
6060

6161
#ifdef USE_VPCLMULQDQ
6262
# include <immintrin.h>

0 commit comments

Comments
 (0)