diff --git a/cmdline/check.c b/cmdline/check.c index d618ff2e..dbaf5503 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -1334,7 +1334,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna failed[failed_count].handle = &handle[j]; ++failed_count; - log_tag("error:%u:%s:%s: Data error at position %u, diff hash bits %u/%u\n", i, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8); + log_tag("error:%u:%s:%s: Data error at position %u, diff hash bits %u/%zu\n", i, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8); ++silent_error; continue; } diff --git a/cmdline/elem.c b/cmdline/elem.c index df88b106..3427be03 100644 --- a/cmdline/elem.c +++ b/cmdline/elem.c @@ -11,7 +11,7 @@ /****************************************************************************/ /* snapraid */ -int BLOCK_HASH_SIZE = HASH_MAX; +size_t BLOCK_HASH_SIZE = HASH_MAX; struct snapraid_content* content_alloc(const char* path, uint64_t dev) { diff --git a/cmdline/elem.h b/cmdline/elem.h index 5fe432d0..9c42ce23 100644 --- a/cmdline/elem.h +++ b/cmdline/elem.h @@ -138,7 +138,7 @@ struct snapraid_filter { * * At max HASH_MAX. */ -extern int BLOCK_HASH_SIZE; +extern size_t BLOCK_HASH_SIZE; /** * Block of a file. @@ -646,7 +646,7 @@ int filter_content(tommy_list* contentlist, const char* path); */ static inline int hash_is_invalid(const unsigned char* hash) { - int i; + size_t i; /* if the hash is reduced, we cannot grant that it's a specific kind of hash */ if (BLOCK_HASH_SIZE != HASH_MAX) @@ -668,7 +668,7 @@ static inline int hash_is_invalid(const unsigned char* hash) */ static inline int hash_is_zero(const unsigned char* hash) { - int i; + size_t i; /* if the hash is reduced, we cannot grant that it's a specific kind of hash */ if (BLOCK_HASH_SIZE != HASH_MAX) diff --git a/cmdline/portable.h b/cmdline/portable.h index ccfa4f14..791cb0e6 100644 --- a/cmdline/portable.h +++ b/cmdline/portable.h @@ -46,6 +46,7 @@ #ifdef __MINGW32__ #if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO == 1 #define attribute_printf gnu_printf /* GNU format */ +#define printf __mingw_printf #else #define attribute_printf ms_printf /* MSVCRT format */ #endif diff --git a/cmdline/scrub.c b/cmdline/scrub.c index 6e35b92f..871e3075 100644 --- a/cmdline/scrub.c +++ b/cmdline/scrub.c @@ -485,12 +485,12 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par /* it's a silent error only if we are dealing with synced files */ if (file_is_unsynced) { - log_tag("error:%u:%s:%s: Data error at position %u, diff hash bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8); + log_tag("error:%u:%s:%s: Data error at position %u, diff hash bits %u/%zu\n", blockcur, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8); ++soft_error; error_on_this_block = 1; } else { - log_tag("error_data:%u:%s:%s: Data error at position %u, diff hash bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8); - log_error(EDATA, "Data error in file '%s' at position '%u', diff hash bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8); + log_tag("error_data:%u:%s:%s: Data error at position %u, diff hash bits %u/%zu\n", blockcur, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8); + log_error(EDATA, "Data error in file '%s' at position '%u', diff hash bits %u/%zu\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8); ++silent_error; silent_error_on_this_block = 1; } diff --git a/cmdline/state.c b/cmdline/state.c index 13dc34e4..47a044f0 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -2964,7 +2964,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S BLOCK_HASH_SIZE = hash_size; } - if ((int)hash_size != BLOCK_HASH_SIZE) { + if (hash_size != BLOCK_HASH_SIZE) { /* LCOV_EXCL_START */ decoding_error(path, f); log_fatal(EUSER, "Mismatching 'hashsize' specification in the content file!\n"); @@ -5659,7 +5659,7 @@ void generate_configuration(const char* path) printf("blocksize %u\n", state.block_size / KIBI); printf("\n"); printf("# Use this hashsize\n"); - printf("hashsize %u\n", BLOCK_HASH_SIZE); + printf("hashsize %zu\n", BLOCK_HASH_SIZE); printf("\n"); for (l = 0; l < state.level; ++l) { printf("# Set the correct path for the %s files\n", lev_name(l)); diff --git a/cmdline/sync.c b/cmdline/sync.c index 56a9cf22..8ccf7ae8 100644 --- a/cmdline/sync.c +++ b/cmdline/sync.c @@ -966,8 +966,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari continue; } else { /* otherwise it's a BLK with silent error */ unsigned diff = memdiff(hash, block->hash, BLOCK_HASH_SIZE); - log_tag("error_data:%u:%s:%s: Data error at position %u, diff hash bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8); - log_error(EDATA, "Data error in file '%s' at position '%u', diff hash bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8); + log_tag("error_data:%u:%s:%s: Data error at position %u, diff hash bits %u/%zu\n", blockcur, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8); + log_error(EDATA, "Data error in file '%s' at position '%u', diff hash bits %u/%zu\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8); /* save the failed block for the fix */ failed[failed_count].index = diskcur;