From c1b62b2eded035d22584c427487503335f519d4c Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Tue, 1 Jun 2010 19:35:49 +0100 Subject: [PATCH] Fix a "dereference of type-punned pointer" compiler warning gcc (4.4.0) issues the following warning: src/revobject.c:33: warning: dereferencing type-punned pointer \ will break strict-aliasing rules We suppress the warning by copying the first 4 bytes from the oid structure into an 'unsigned int' using memcpy(). This will also fix any potential alignment issues on certain platforms. Signed-off-by: Ramsay Jones Signed-off-by: Andreas Ericsson --- src/revobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/revobject.c b/src/revobject.c index 7b6c856c6..5130f2343 100644 --- a/src/revobject.c +++ b/src/revobject.c @@ -30,7 +30,9 @@ static const double max_load_factor = 0.65; static unsigned int git_revpool_table__hash(const git_oid *id) { - return *((unsigned int *)id->id); + unsigned int r; + memcpy(&r, id->id, sizeof(r)); + return r; } git_revpool_table *git_revpool_table_create(unsigned int min_size)