Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2579985

Browse files
committed
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
1 parent a4012a6 commit 2579985

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/include/common/hashfn_unstable.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fasthash_combine(fasthash_state *hs)
138138

139139
/* accumulate up to 8 bytes of input and combine it into the hash */
140140
static inline void
141-
fasthash_accum(fasthash_state *hs, const char *k, int len)
141+
fasthash_accum(fasthash_state *hs, const char *k, size_t len)
142142
{
143143
uint32 lower_four;
144144

@@ -189,14 +189,14 @@ fasthash_accum(fasthash_state *hs, const char *k, int len)
189189
/*
190190
* all-purpose workhorse for fasthash_accum_cstring
191191
*/
192-
static inline int
192+
static inline size_t
193193
fasthash_accum_cstring_unaligned(fasthash_state *hs, const char *str)
194194
{
195195
const char *const start = str;
196196

197197
while (*str)
198198
{
199-
int chunk_len = 0;
199+
size_t chunk_len = 0;
200200

201201
while (chunk_len < FH_SIZEOF_ACCUM && str[chunk_len] != '\0')
202202
chunk_len++;
@@ -215,11 +215,11 @@ fasthash_accum_cstring_unaligned(fasthash_state *hs, const char *str)
215215
* Loading the word containing the NUL terminator cannot segfault since
216216
* allocation boundaries are suitably aligned.
217217
*/
218-
static inline int
218+
static inline size_t
219219
fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
220220
{
221221
const char *const start = str;
222-
int remainder;
222+
size_t remainder;
223223
uint64 zero_byte_low;
224224

225225
Assert(PointerIsAligned(start, uint64));
@@ -269,14 +269,14 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
269269
/*
270270
* Mix 'str' into the hash state and return the length of the string.
271271
*/
272-
static inline int
272+
static inline size_t
273273
fasthash_accum_cstring(fasthash_state *hs, const char *str)
274274
{
275275
#if SIZEOF_VOID_P >= 8
276276

277-
int len;
277+
size_t len;
278278
#ifdef USE_ASSERT_CHECKING
279-
int len_check;
279+
size_t len_check;
280280
fasthash_state hs_check;
281281

282282
memcpy(&hs_check, hs, sizeof(fasthash_state));
@@ -340,7 +340,7 @@ fasthash_final32(fasthash_state *hs, uint64 tweak)
340340
* 'seed' can be zero.
341341
*/
342342
static inline uint64
343-
fasthash64(const char *k, int len, uint64 seed)
343+
fasthash64(const char *k, size_t len, uint64 seed)
344344
{
345345
fasthash_state hs;
346346

@@ -362,7 +362,7 @@ fasthash64(const char *k, int len, uint64 seed)
362362

363363
/* like fasthash64, but returns a 32-bit hashcode */
364364
static inline uint64
365-
fasthash32(const char *k, int len, uint64 seed)
365+
fasthash32(const char *k, size_t len, uint64 seed)
366366
{
367367
return fasthash_reduce32(fasthash64(k, len, seed));
368368
}

0 commit comments

Comments
 (0)