summaryrefslogtreecommitdiff
path: root/decorate.c
diff options
context:
space:
mode:
authorDan McGee <dpmcgee@gmail.com>2009-05-12 01:17:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-05-17 05:41:18 (GMT)
commitb867d324ceb7e5c4f14a04c6b55d69498812d24b (patch)
tree4995fea8f2d925feaeb0183ac2e87c6fa86a5144 /decorate.c
parente4b09dad9f65395fd4bb8ab165012a3a6698a75b (diff)
downloadgit-b867d324ceb7e5c4f14a04c6b55d69498812d24b.zip
git-b867d324ceb7e5c4f14a04c6b55d69498812d24b.tar.gz
git-b867d324ceb7e5c4f14a04c6b55d69498812d24b.tar.bz2
Fix type-punning issues
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>
Diffstat (limited to 'decorate.c')
-rw-r--r--decorate.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/decorate.c b/decorate.c
index 82d9e22..e6fd8a7 100644
--- a/decorate.c
+++ b/decorate.c
@@ -8,7 +8,9 @@
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;
}