Silence GCC's "cast of pointer to integer of a different size" warning

When calculating hashes from pointers, it actually makes sense to cut
off the most significant bits. In that case, said warning does not make
a whole lot of sense.

So let's just work around it by casting the pointer first to intptr_t
and then casting up/down to the final integral type.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2015-10-26 14:15:25 +01:00
committed by Junio C Hamano
parent 8f77442358
commit 56a1a3ab44
3 changed files with 6 additions and 4 deletions

View File

@ -21,7 +21,7 @@ static int pack_revindex_hashsz;
static int pack_revindex_ix(struct packed_git *p)
{
unsigned long ui = (unsigned long)p;
unsigned long ui = (unsigned long)(intptr_t)p;
int i;
ui = ui ^ (ui >> 16); /* defeat structure alignment */