git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Linus TorvaldsNext: Junio C Hamano
Message 5 of 10 in “Fix git-pack-objects for 64-bit platforms”
  1. Fix git-pack-objects for 64-bit platformsDennis Stosberg, May 11, 2006
  2. Linus TorvaldsMay 11, 2006
  3. Junio C HamanoMay 11, 2006
  4. Linus TorvaldsMay 11, 2006
  5. Linus TorvaldsMay 11, 2006
  6. Junio C HamanoMay 13, 2006
  7. Ben CliffordMay 14, 2006
  8. include header to define uint32_t, necessary on Mac OS XBen Clifford, May 14, 2006
  9. Alex RiesenMay 20, 2006
  10. Linus TorvaldsMay 20, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.