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>
Jeff King committed
Feb 14, 2018 at 13:08 UTC
a6119f82b118c7adea9ede0b3813810b06e37668
1 file changed
+3
-2
t/helper/test-hashmap.c
+3
-2
@@ -30,7 +30,8 @@ static int test_entry_cmp(const void *cmp_data,
30
return strcmp(e1->key, key ? key : e2->key);
31
}
32
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)
35
{
36
size_t klen = strlen(key);
37
size_t vlen = strlen(value);
@@ -156,7 +157,7 @@ int cmd_main(int argc, const char **argv)
157
/* process commands from stdin */
158
while (strbuf_getline(&line, stdin) != EOF) {
159
char *cmd, *p1 = NULL, *p2 = NULL;
159
- int hash = 0;
160
+ unsigned int hash = 0;
161
struct test_entry *entry;
162
163
/* break line into command and up to two parameters */