summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e4b09da)
raw | patch | inline | side by side (parent: e4b09da)
author | Dan McGee <dpmcgee@gmail.com> | |
Tue, 12 May 2009 01:17:38 +0000 (20:17 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 17 May 2009 05:41:18 +0000 (22:41 -0700) |
In these two places we are casting part of our unsigned char sha1 array into
an unsigned int, which violates GCCs strict-aliasing rules (and probably
other compilers).
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
an unsigned int, which violates GCCs strict-aliasing rules (and probably
other compilers).
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
decorate.c | patch | blob | history | |
object.c | patch | blob | history |
diff --git a/decorate.c b/decorate.c
index 82d9e221eabab53acc418d0db6327e480836a5ed..e6fd8a7441a7ac6753d93e7156b9f71fe248262d 100644 (file)
--- a/decorate.c
+++ b/decorate.c
static unsigned int hash_obj(const struct object *obj, unsigned int n)
{
- unsigned int hash = *(unsigned int *)obj->sha1;
+ unsigned int hash;
+
+ memcpy(&hash, obj->sha1, sizeof(unsigned int));
return hash % n;
}
diff --git a/object.c b/object.c
index 7e6a92c88e7b139ec03e0ff26e97e1559a06a220..e1feef9c3329e0370e7caff612b4f6c8684cbaef 100644 (file)
--- a/object.c
+++ b/object.c
static unsigned int hash_obj(struct object *obj, unsigned int n)
{
- unsigned int hash = *(unsigned int *)obj->sha1;
+ unsigned int hash;
+ memcpy(&hash, obj->sha1, sizeof(unsigned int));
return hash % n;
}