Skip to content

Commit fd3e674

Browse files
pcloudsgitster
authored andcommitted
index-pack: report correct bad object offsets even if they are large
Use the right type for offsets in this case, off_t, which makes a difference on 32-bit systems with large file support, and change formatting code accordingly. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7171a0b commit fd3e674

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

builtin/index-pack.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,19 @@ static void parse_pack_header(void)
338338
use(sizeof(struct pack_header));
339339
}
340340

341-
static NORETURN void bad_object(unsigned long offset, const char *format,
341+
static NORETURN void bad_object(off_t offset, const char *format,
342342
...) __attribute__((format (printf, 2, 3)));
343343

344-
static NORETURN void bad_object(unsigned long offset, const char *format, ...)
344+
static NORETURN void bad_object(off_t offset, const char *format, ...)
345345
{
346346
va_list params;
347347
char buf[1024];
348348

349349
va_start(params, format);
350350
vsnprintf(buf, sizeof(buf), format, params);
351351
va_end(params);
352-
die(_("pack has bad object at offset %lu: %s"), offset, buf);
352+
die(_("pack has bad object at offset %"PRIuMAX": %s"),
353+
(uintmax_t)offset, buf);
353354
}
354355

355356
static inline struct thread_local *get_thread_data(void)

0 commit comments

Comments
 (0)