Skip to content

Commit eeb79ff

Browse files
Philip Oakleydscho
Philip Oakley
authored andcommitted
builtin/index-pack.c,csum-file.c: use size_t for memsized variables
use size_t for Windows compatibility. Also use appropriate format for printing. Signed-off-by: Philip Oakley <[email protected]>
1 parent 8891566 commit eeb79ff

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

builtin/index-pack.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static void *unpack_raw_entry(struct object_entry *obj,
481481
unsigned char *p;
482482
size_t size, c;
483483
off_t base_offset;
484-
unsigned shift;
484+
size_t shift;
485485
void *data;
486486

487487
obj->idx.offset = consumed_bytes;
@@ -1598,10 +1598,10 @@ static void read_idx_option(struct pack_idx_option *opts, const char *pack_name)
15981598
static void show_pack_info(int stat_only)
15991599
{
16001600
int i, baseobjects = nr_objects - nr_ref_deltas - nr_ofs_deltas;
1601-
unsigned long *chain_histogram = NULL;
1601+
size_t *chain_histogram = NULL;
16021602

16031603
if (deepest_delta)
1604-
chain_histogram = xcalloc(deepest_delta, sizeof(unsigned long));
1604+
chain_histogram = xcalloc(deepest_delta, sizeof(size_t));
16051605

16061606
for (i = 0; i < nr_objects; i++) {
16071607
struct object_entry *obj = &objects[i];
@@ -1631,11 +1631,11 @@ static void show_pack_info(int stat_only)
16311631
for (i = 0; i < deepest_delta; i++) {
16321632
if (!chain_histogram[i])
16331633
continue;
1634-
printf_ln(Q_("chain length = %d: %lu object",
1635-
"chain length = %d: %lu objects",
1634+
printf_ln(Q_("chain length = %d: %"PRIuMAX" object",
1635+
"chain length = %d: %"PRIuMAX" objects",
16361636
chain_histogram[i]),
16371637
i + 1,
1638-
chain_histogram[i]);
1638+
(uintmax_t)chain_histogram[i]);
16391639
}
16401640
}
16411641

csum-file.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "progress.h"
1212
#include "csum-file.h"
1313

14-
static void flush(struct hashfile *f, const void *buf, unsigned int count)
14+
static void flush(struct hashfile *f, const void *buf, size_t count)
1515
{
1616
if (0 <= f->check_fd && count) {
1717
unsigned char check_buffer[8192];
@@ -44,7 +44,7 @@ static void flush(struct hashfile *f, const void *buf, unsigned int count)
4444

4545
void hashflush(struct hashfile *f)
4646
{
47-
unsigned offset = f->offset;
47+
size_t offset = f->offset;
4848

4949
if (offset) {
5050
the_hash_algo->update_fn(&f->ctx, f->buffer, offset);
@@ -86,12 +86,12 @@ int finalize_hashfile(struct hashfile *f, unsigned char *result, unsigned int fl
8686
return fd;
8787
}
8888

89-
void hashwrite(struct hashfile *f, const void *buf, unsigned int count)
89+
void hashwrite(struct hashfile *f, const void *buf, size_t count)
9090
{
9191
while (count) {
92-
unsigned offset = f->offset;
93-
unsigned left = sizeof(f->buffer) - offset;
94-
unsigned nr = count > left ? left : count;
92+
size_t offset = f->offset;
93+
size_t left = sizeof(f->buffer) - offset;
94+
size_t nr = count > left ? left : count;
9595
const void *data;
9696

9797
if (f->do_crc)

csum-file.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct progress;
99
struct hashfile {
1010
int fd;
1111
int check_fd;
12-
unsigned int offset;
12+
size_t offset;
1313
git_hash_ctx ctx;
1414
off_t total;
1515
struct progress *tp;
@@ -37,7 +37,7 @@ struct hashfile *hashfd(int fd, const char *name);
3737
struct hashfile *hashfd_check(const char *name);
3838
struct hashfile *hashfd_throughput(int fd, const char *name, struct progress *tp);
3939
int finalize_hashfile(struct hashfile *, unsigned char *, unsigned int);
40-
void hashwrite(struct hashfile *, const void *, unsigned int);
40+
void hashwrite(struct hashfile *, const void *, size_t);
4141
void hashflush(struct hashfile *f);
4242
void crc32_begin(struct hashfile *);
4343
uint32_t crc32_end(struct hashfile *);

0 commit comments

Comments
 (0)