Skip to content

Commit

Permalink
builtin/index-pack.c,csum-file.c: use size_t for memsized variables
Browse files Browse the repository at this point in the history
use size_t for Windows compatibility.
Also use appropriate format for printing.

Signed-off-by: Philip Oakley <[email protected]>
  • Loading branch information
Philip Oakley authored and dscho committed Jun 4, 2019
1 parent 8891566 commit eeb79ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ static void *unpack_raw_entry(struct object_entry *obj,
unsigned char *p;
size_t size, c;
off_t base_offset;
unsigned shift;
size_t shift;
void *data;

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

if (deepest_delta)
chain_histogram = xcalloc(deepest_delta, sizeof(unsigned long));
chain_histogram = xcalloc(deepest_delta, sizeof(size_t));

for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
Expand Down Expand Up @@ -1631,11 +1631,11 @@ static void show_pack_info(int stat_only)
for (i = 0; i < deepest_delta; i++) {
if (!chain_histogram[i])
continue;
printf_ln(Q_("chain length = %d: %lu object",
"chain length = %d: %lu objects",
printf_ln(Q_("chain length = %d: %"PRIuMAX" object",
"chain length = %d: %"PRIuMAX" objects",
chain_histogram[i]),
i + 1,
chain_histogram[i]);
(uintmax_t)chain_histogram[i]);
}
}

Expand Down
12 changes: 6 additions & 6 deletions csum-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "progress.h"
#include "csum-file.h"

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

void hashflush(struct hashfile *f)
{
unsigned offset = f->offset;
size_t offset = f->offset;

if (offset) {
the_hash_algo->update_fn(&f->ctx, f->buffer, offset);
Expand Down Expand Up @@ -86,12 +86,12 @@ int finalize_hashfile(struct hashfile *f, unsigned char *result, unsigned int fl
return fd;
}

void hashwrite(struct hashfile *f, const void *buf, unsigned int count)
void hashwrite(struct hashfile *f, const void *buf, size_t count)
{
while (count) {
unsigned offset = f->offset;
unsigned left = sizeof(f->buffer) - offset;
unsigned nr = count > left ? left : count;
size_t offset = f->offset;
size_t left = sizeof(f->buffer) - offset;
size_t nr = count > left ? left : count;
const void *data;

if (f->do_crc)
Expand Down
4 changes: 2 additions & 2 deletions csum-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct progress;
struct hashfile {
int fd;
int check_fd;
unsigned int offset;
size_t offset;
git_hash_ctx ctx;
off_t total;
struct progress *tp;
Expand Down Expand Up @@ -37,7 +37,7 @@ struct hashfile *hashfd(int fd, const char *name);
struct hashfile *hashfd_check(const char *name);
struct hashfile *hashfd_throughput(int fd, const char *name, struct progress *tp);
int finalize_hashfile(struct hashfile *, unsigned char *, unsigned int);
void hashwrite(struct hashfile *, const void *, unsigned int);
void hashwrite(struct hashfile *, const void *, size_t);
void hashflush(struct hashfile *f);
void crc32_begin(struct hashfile *);
uint32_t crc32_end(struct hashfile *);
Expand Down

0 comments on commit eeb79ff

Please sign in to comment.