Skip to content

Commit 166df26

Browse files
pcloudsgitster
authored andcommitted
sha1_file.c: use type off_t* for object_info->disk_sizep
This field, filled by sha1_object_info() contains the on-disk size of an object, which could go over 4GB limit of unsigned long on 32-bit systems. Use off_t for it instead and update all callers. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 211c61c commit 166df26

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builtin/cat-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct expand_data {
131131
unsigned char sha1[20];
132132
enum object_type type;
133133
unsigned long size;
134-
unsigned long disk_size;
134+
off_t disk_size;
135135
const char *rest;
136136
unsigned char delta_base_sha1[20];
137137

@@ -184,7 +184,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
184184
if (data->mark_query)
185185
data->info.disk_sizep = &data->disk_size;
186186
else
187-
strbuf_addf(sb, "%lu", data->disk_size);
187+
strbuf_addf(sb, "%"PRIuMAX, (uintmax_t)data->disk_size);
188188
} else if (is_atom("rest", atom, len)) {
189189
if (data->mark_query)
190190
data->split_on_whitespace = 1;

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ struct object_info {
15021502
/* Request */
15031503
enum object_type *typep;
15041504
unsigned long *sizep;
1505-
unsigned long *disk_sizep;
1505+
off_t *disk_sizep;
15061506
unsigned char *delta_base_sha1;
15071507
struct strbuf *typename;
15081508

0 commit comments

Comments
 (0)