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

[PATCH 1/2] Use fixed-size integers for the on-disk pack structure.

From
Junio C Hamano <junkio@cox.net>
Date
Jan 18, 2007, 07:24 UTC
Message-ID
<7vejpsol0a.fsf@assigned-by-dhcp.cox.net>
From: Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
Date: Wed, 17 Jan 2007 09:07:23 +0100

Plain integer types without a fixed size can vary between platforms. Even though all common platforms use 32-bit ints, there is no guarantee that this won't change at some point. Furthermore, specifying an integer type with explicit size makes the definition of structures more obvious.

Signed-off-by: Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * For wider review -- this _might_ have issues with "not quite
   POSIX" systems (such as AIX exporting something undesirable
   under _ALL_SOURCE for example).
 git-compat-util.h |    1 +
 pack.h            |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 8d244d0..bf3ceb8 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -46,6 +46,7 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <pwd.h>
+#include <stdint.h>
 #undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
 #include <grp.h>
 #define _ALL_SOURCE 1
diff --git a/pack.h b/pack.h
index 790ff4a..821706f 100644
--- a/pack.h
+++ b/pack.h
@@ -10,9 +10,9 @@
 #define PACK_VERSION 2
 #define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
 struct pack_header {
-	unsigned int hdr_signature;
-	unsigned int hdr_version;
-	unsigned int hdr_entries;
+	uint32_t hdr_signature;
+	uint32_t hdr_version;
+	uint32_t hdr_entries;
 };
 
 /*
-- 
1.5.0.rc1.g05cf8
Message 1 of 1 in “Use fixed-size integers for the on-disk pack structure.”
  1. 1/2 Use fixed-size integers for the on-disk pack structure.Junio C Hamano, Jan 18, 2007

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.