From: Dan McGee <dpmcgee@gmail.com>
To: git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, gitster@pobox.com,
Dan McGee <dpmcgee@gmail.com>
Subject: [PATCH 1/3] Unify signedness in hashing calls
Date: Mon, 18 May 2009 23:34:02 -0500 [thread overview]
Message-ID: <1242707644-29893-1-git-send-email-dpmcgee@gmail.com> (raw)
In-Reply-To: <449c10960905182132h2c1b38b4jd28721adaeb38484@mail.gmail.com>
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>
---
decorate.c | 4 ++--
object.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/decorate.c b/decorate.c
index e6fd8a7..2f8a63e 100644
--- a/decorate.c
+++ b/decorate.c
@@ -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) {
@@ -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)
diff --git a/object.c b/object.c
index e1feef9..a6ef439 100644
--- a/object.c
+++ b/object.c
@@ -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++;
@@ -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)
--
1.6.3.1
next prev parent reply other threads:[~2009-05-19 4:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 1:17 [PATCH] Fix type-punning issues Dan McGee
2009-05-12 7:57 ` Junio C Hamano
2009-05-19 4:32 ` Dan McGee
2009-05-19 4:34 ` Dan McGee [this message]
2009-05-19 4:34 ` [PATCH 2/3] Convert hash functions to char instead of struct object Dan McGee
2009-05-19 4:34 ` [PATCH 3/3] Unify sha1 char hash functions Dan McGee
2009-05-19 6:23 ` [PATCH 2/3] Convert hash functions to char instead of struct object Johannes Sixt
2009-05-19 7:04 ` Junio C Hamano
2009-05-12 8:13 ` [PATCH] Fix type-punning issues Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1242707644-29893-1-git-send-email-dpmcgee@gmail.com \
--to=dpmcgee@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).