Skip to content

Commit 91fe2f9

Browse files
toofishesgitster
authored andcommitted
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>
1 parent 99ddd24 commit 91fe2f9

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

decorate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void *insert_decoration(struct decoration *n, const struct object *base,
1818
{
1919
int size = n->size;
2020
struct object_decoration *hash = n->hash;
21-
int j = hash_obj(base, size);
21+
unsigned int j = hash_obj(base, size);
2222

2323
while (hash[j].base) {
2424
if (hash[j].base == base) {
@@ -70,7 +70,7 @@ void *add_decoration(struct decoration *n, const struct object *obj,
7070
/* Lookup a decoration pointer */
7171
void *lookup_decoration(struct decoration *n, const struct object *obj)
7272
{
73-
int j;
73+
unsigned int j;
7474

7575
/* nothing to lookup */
7676
if (!n->size)

object.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static unsigned int hash_obj(struct object *obj, unsigned int n)
5252

5353
static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
5454
{
55-
int j = hash_obj(obj, size);
55+
unsigned int j = hash_obj(obj, size);
5656

5757
while (hash[j]) {
5858
j++;
@@ -62,16 +62,16 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i
6262
hash[j] = obj;
6363
}
6464

65-
static int hashtable_index(const unsigned char *sha1)
65+
static unsigned int hashtable_index(const unsigned char *sha1)
6666
{
6767
unsigned int i;
6868
memcpy(&i, sha1, sizeof(unsigned int));
69-
return (int)(i % obj_hash_size);
69+
return i % obj_hash_size;
7070
}
7171

7272
struct object *lookup_object(const unsigned char *sha1)
7373
{
74-
int i;
74+
unsigned int i;
7575
struct object *obj;
7676

7777
if (!obj_hash)

0 commit comments

Comments
 (0)