Skip to content

Commit

Permalink
Unify signedness in hashing calls
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
toofishes authored and gitster committed May 20, 2009
1 parent 99ddd24 commit 91fe2f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions decorate.c
Expand Up @@ -18,7 +18,7 @@ static void *insert_decoration(struct decoration *n, const struct object *base,
{
int size = n->size;
struct object_decoration *hash = n->hash;
int j = hash_obj(base, size);
unsigned int j = hash_obj(base, size);

while (hash[j].base) {
if (hash[j].base == base) {
Expand Down Expand Up @@ -70,7 +70,7 @@ void *add_decoration(struct decoration *n, const struct object *obj,
/* Lookup a decoration pointer */
void *lookup_decoration(struct decoration *n, const struct object *obj)
{
int j;
unsigned int j;

/* nothing to lookup */
if (!n->size)
Expand Down
8 changes: 4 additions & 4 deletions object.c
Expand Up @@ -52,7 +52,7 @@ static unsigned int hash_obj(struct object *obj, unsigned int n)

static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
{
int j = hash_obj(obj, size);
unsigned int j = hash_obj(obj, size);

while (hash[j]) {
j++;
Expand All @@ -62,16 +62,16 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i
hash[j] = obj;
}

static int hashtable_index(const unsigned char *sha1)
static unsigned int hashtable_index(const unsigned char *sha1)
{
unsigned int i;
memcpy(&i, sha1, sizeof(unsigned int));
return (int)(i % obj_hash_size);
return i % obj_hash_size;
}

struct object *lookup_object(const unsigned char *sha1)
{
int i;
unsigned int i;
struct object *obj;

if (!obj_hash)
Expand Down

0 comments on commit 91fe2f9

Please sign in to comment.