Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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>
  • Loading branch information...
commit 91fe2f909154c5cda3b40c68e72c3172a7f137f6 1 parent 99ddd24
Dan McGee toofishes authored committed

Showing 2 changed files with 6 additions and 6 deletions. Show diff stats Hide diff stats

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

0 comments on commit 91fe2f9

Please sign in to comment.
Something went wrong with that request. Please try again.