@matheusbsbs / matheus-bagliano / commits / 91fe2f9091
Fork 0

Unify signedness in hashing calls

Our hash_obj and hashtable_index calls and functions were doing a lot of funny things with signedness. Unify all of it to 'unsigned int'. Signed-off-by: Dan McGee <dpmcgee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Dan McGee committed May 18, 2009 at 23:34 UTC 91fe2f909154c5cda3b40c68e72c3172a7f137f6
2 files changed +6 -6
decorate.c
+2 -2
@@ -18,7 +18,7 @@ static void *insert_decoration(struct decoration *n, const struct object *base,
18 {
19 int size = n->size;
20 struct object_decoration *hash = n->hash;
21 - int j = hash_obj(base, size);
21 + unsigned int j = hash_obj(base, size);
22
23 while (hash[j].base) {
24 if (hash[j].base == base) {
@@ -70,7 +70,7 @@ void *add_decoration(struct decoration *n, const struct object *obj,
70 /* Lookup a decoration pointer */
71 void *lookup_decoration(struct decoration *n, const struct object *obj)
72 {
73 - int j;
73 + unsigned int j;
74
75 /* nothing to lookup */
76 if (!n->size)
object.c
+4 -4
@@ -52,7 +52,7 @@ static unsigned int hash_obj(struct object *obj, unsigned int n)
52
53 static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
54 {
55 - int j = hash_obj(obj, size);
55 + unsigned int j = hash_obj(obj, size);
56
57 while (hash[j]) {
58 j++;
@@ -62,16 +62,16 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i
62 hash[j] = obj;
63 }
64
65 -static int hashtable_index(const unsigned char *sha1)
65 +static unsigned int hashtable_index(const unsigned char *sha1)
66 {
67 unsigned int i;
68 memcpy(&i, sha1, sizeof(unsigned int));
69 - return (int)(i % obj_hash_size);
69 + return i % obj_hash_size;
70 }
71
72 struct object *lookup_object(const unsigned char *sha1)
73 {
74 - int i;
74 + unsigned int i;
75 struct object *obj;
76
77 if (!obj_hash)