Skip to content

Commit 7800c1e

Browse files
tgummerergitster
authored andcommitted
read-cache: use fixed width integer types
Use the fixed width integer types uint16_t and uint32_t for on-disk structures; unsigned short and unsigned int do not have a guaranteed size. Signed-off-by: Thomas Gummerer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d06473 commit 7800c1e

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

cache.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long);
101101

102102
#define CACHE_SIGNATURE 0x44495243 /* "DIRC" */
103103
struct cache_header {
104-
unsigned int hdr_signature;
105-
unsigned int hdr_version;
106-
unsigned int hdr_entries;
104+
uint32_t hdr_signature;
105+
uint32_t hdr_version;
106+
uint32_t hdr_entries;
107107
};
108108

109109
#define INDEX_FORMAT_LB 2
@@ -115,8 +115,8 @@ struct cache_header {
115115
* check it for equality in the 32 bits we save.
116116
*/
117117
struct cache_time {
118-
unsigned int sec;
119-
unsigned int nsec;
118+
uint32_t sec;
119+
uint32_t nsec;
120120
};
121121

122122
struct stat_data {

read-cache.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,14 +1229,14 @@ static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int reall
12291229
struct ondisk_cache_entry {
12301230
struct cache_time ctime;
12311231
struct cache_time mtime;
1232-
unsigned int dev;
1233-
unsigned int ino;
1234-
unsigned int mode;
1235-
unsigned int uid;
1236-
unsigned int gid;
1237-
unsigned int size;
1232+
uint32_t dev;
1233+
uint32_t ino;
1234+
uint32_t mode;
1235+
uint32_t uid;
1236+
uint32_t gid;
1237+
uint32_t size;
12381238
unsigned char sha1[20];
1239-
unsigned short flags;
1239+
uint16_t flags;
12401240
char name[FLEX_ARRAY]; /* more */
12411241
};
12421242

@@ -1248,15 +1248,15 @@ struct ondisk_cache_entry {
12481248
struct ondisk_cache_entry_extended {
12491249
struct cache_time ctime;
12501250
struct cache_time mtime;
1251-
unsigned int dev;
1252-
unsigned int ino;
1253-
unsigned int mode;
1254-
unsigned int uid;
1255-
unsigned int gid;
1256-
unsigned int size;
1251+
uint32_t dev;
1252+
uint32_t ino;
1253+
uint32_t mode;
1254+
uint32_t uid;
1255+
uint32_t gid;
1256+
uint32_t size;
12571257
unsigned char sha1[20];
1258-
unsigned short flags;
1259-
unsigned short flags2;
1258+
uint16_t flags;
1259+
uint16_t flags2;
12601260
char name[FLEX_ARRAY]; /* more */
12611261
};
12621262

0 commit comments

Comments
 (0)