Re: [PATCH] Fix git-pack-objects for 64-bit platforms
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- May 11, 2006, 19:27 UTC
- Message-ID
- <Pine.LNX.4.64.0605111218380.3866@g5.osdl.org>
- In-Reply-To
- <7v7j4swg0r.fsf@assigned-by-dhcp.cox.net>
On Thu, 11 May 2006, Junio C Hamano wrote:
Show 6 quoted lines
> > Since I saw a patch that touches only one place, I thought I'd > better point this out... > > There are a few more places that knows about this > ((char*)base_pointer + (entry_count * 24)) magic in our code.
Since I _do_ have a 64-bit big-endian architecture, I decided to install some of the 64-bit development libraries that I didn't already have, and I added "-m64" to the compiler flags.
All the tests seem to pass with the simple fix (and without it, we do indeed fail at least t5700-clone-reference.sh).
Of course, there might well be something else that doesn't get coverage, but passing all tests is at least a good sign. And since x86-64 has been getting pretty extensive coverage, I don't think we have a lot of 64-bit bugs per se, this one just happened to hide.
Linus
---
diff --git a/pack-objects.c b/pack-objects.c index 523a1c7..1b9e7a1 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -156,7 +156,7 @@ static void prepare_pack_revindex(struct rix->revindex = xmalloc(sizeof(unsigned long) * (num_ent + 1)); for (i = 0; i < num_ent; i++) { - long hl = *((long *)(index + 24 * i)); + uint32_t hl = *((uint32_t *)(index + 24 * i)); rix->revindex[i] = ntohl(hl); } /* This knows the pack format -- the 20-byte trailer