Fix warnings in cpluspluscheck

Various int variables were compared to macros that are of type size_t,
which caused -Wsign-compare warnings in cpluspluscheck.  Change those
to size_t, which also better describes their purpose.

Per report from Peter Eisentraut

Discussion: https://postgr.es/m/486847dc-6de5-464a-938e-bac98ec2438b%40eisentraut.org
This commit is contained in:
John Naylor 2024-02-08 10:04:57 +07:00
parent a4012a697e
commit 2579985086

View File

@ -138,7 +138,7 @@ fasthash_combine(fasthash_state *hs)
/* accumulate up to 8 bytes of input and combine it into the hash */ /* accumulate up to 8 bytes of input and combine it into the hash */
static inline void static inline void
fasthash_accum(fasthash_state *hs, const char *k, int len) fasthash_accum(fasthash_state *hs, const char *k, size_t len)
{ {
uint32 lower_four; uint32 lower_four;
@ -189,14 +189,14 @@ fasthash_accum(fasthash_state *hs, const char *k, int len)
/* /*
* all-purpose workhorse for fasthash_accum_cstring * all-purpose workhorse for fasthash_accum_cstring
*/ */
static inline int static inline size_t
fasthash_accum_cstring_unaligned(fasthash_state *hs, const char *str) fasthash_accum_cstring_unaligned(fasthash_state *hs, const char *str)
{ {
const char *const start = str; const char *const start = str;
while (*str) while (*str)
{ {
int chunk_len = 0; size_t chunk_len = 0;
while (chunk_len < FH_SIZEOF_ACCUM && str[chunk_len] != '\0') while (chunk_len < FH_SIZEOF_ACCUM && str[chunk_len] != '\0')
chunk_len++; chunk_len++;
@ -215,11 +215,11 @@ fasthash_accum_cstring_unaligned(fasthash_state *hs, const char *str)
* Loading the word containing the NUL terminator cannot segfault since * Loading the word containing the NUL terminator cannot segfault since
* allocation boundaries are suitably aligned. * allocation boundaries are suitably aligned.
*/ */
static inline int static inline size_t
fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str) fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
{ {
const char *const start = str; const char *const start = str;
int remainder; size_t remainder;
uint64 zero_byte_low; uint64 zero_byte_low;
Assert(PointerIsAligned(start, uint64)); Assert(PointerIsAligned(start, uint64));
@ -269,14 +269,14 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
/* /*
* Mix 'str' into the hash state and return the length of the string. * Mix 'str' into the hash state and return the length of the string.
*/ */
static inline int static inline size_t
fasthash_accum_cstring(fasthash_state *hs, const char *str) fasthash_accum_cstring(fasthash_state *hs, const char *str)
{ {
#if SIZEOF_VOID_P >= 8 #if SIZEOF_VOID_P >= 8
int len; size_t len;
#ifdef USE_ASSERT_CHECKING #ifdef USE_ASSERT_CHECKING
int len_check; size_t len_check;
fasthash_state hs_check; fasthash_state hs_check;
memcpy(&hs_check, hs, sizeof(fasthash_state)); memcpy(&hs_check, hs, sizeof(fasthash_state));
@ -340,7 +340,7 @@ fasthash_final32(fasthash_state *hs, uint64 tweak)
* 'seed' can be zero. * 'seed' can be zero.
*/ */
static inline uint64 static inline uint64
fasthash64(const char *k, int len, uint64 seed) fasthash64(const char *k, size_t len, uint64 seed)
{ {
fasthash_state hs; fasthash_state hs;
@ -362,7 +362,7 @@ fasthash64(const char *k, int len, uint64 seed)
/* like fasthash64, but returns a 32-bit hashcode */ /* like fasthash64, but returns a 32-bit hashcode */
static inline uint64 static inline uint64
fasthash32(const char *k, int len, uint64 seed) fasthash32(const char *k, size_t len, uint64 seed)
{ {
return fasthash_reduce32(fasthash64(k, len, seed)); return fasthash_reduce32(fasthash64(k, len, seed));
} }