Skip to content

Commit a6119f8

Browse files
peffgitster
authored andcommitted
test-hashmap: use "unsigned int" for hash storage
The hashmap API always use an unsigned value for storing and comparing hashes. Whereas this test code uses "int". This works out in practice since one can typically round-trip between "int" and "unsigned int". But since this is essentially reference code for the hashmap API, we should model using the correct types. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7daa825 commit a6119f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

t/helper/test-hashmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ static int test_entry_cmp(const void *cmp_data,
3030
return strcmp(e1->key, key ? key : e2->key);
3131
}
3232

33-
static struct test_entry *alloc_test_entry(int hash, char *key, char *value)
33+
static struct test_entry *alloc_test_entry(unsigned int hash,
34+
char *key, char *value)
3435
{
3536
size_t klen = strlen(key);
3637
size_t vlen = strlen(value);
@@ -156,7 +157,7 @@ int cmd_main(int argc, const char **argv)
156157
/* process commands from stdin */
157158
while (strbuf_getline(&line, stdin) != EOF) {
158159
char *cmd, *p1 = NULL, *p2 = NULL;
159-
int hash = 0;
160+
unsigned int hash = 0;
160161
struct test_entry *entry;
161162

162163
/* break line into command and up to two parameters */

0 commit comments

Comments
 (0)