From aaf7e68c75a907c3c08e83dfd2972665a0f1c1a3 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 1 Mar 2020 21:55:17 +0100 Subject: Fix printf format specifies for sqfs_u64 Signed-off-by: David Oberhollenzer --- include/compat.h | 9 +++++++++ lib/common/statistics.c | 13 +++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/compat.h b/include/compat.h index 5f73158..b67d27f 100644 --- a/include/compat.h +++ b/include/compat.h @@ -31,6 +31,15 @@ # error I do not know how to trap integer overflows with this compiler #endif +#if defined(_WIN32) || defined(__WINDOWS__) +# define PRI_U64 "%I64u" +# define PRI_U32 "%I32u" +#else +# include +# define PRI_U64 PRIu64 +# define PRI_U32 PRIu32 +#endif + #if SIZEOF_SIZE_T <= SIZEOF_INT # define PRI_SZ "%u" #elif SIZEOF_SIZE_T == SIZEOF_LONG diff --git a/lib/common/statistics.c b/lib/common/statistics.c index 92d365c..2f729cb 100644 --- a/lib/common/statistics.c +++ b/lib/common/statistics.c @@ -36,17 +36,18 @@ void sqfs_print_statistics(const sqfs_super_t *super, printf("Data compression ratio: " PRI_SZ "%%\n", ratio); fputc('\n', stdout); - printf("Data blocks written: %lu\n", wr_stats->blocks_written); - printf("Out of which where fragment blocks: %lu\n", + printf("Data blocks written: " PRI_U64 "\n", wr_stats->blocks_written); + printf("Out of which where fragment blocks: " PRI_U64 "\n", proc_stats->frag_block_count); - printf("Duplicate blocks omitted: %lu\n", + printf("Duplicate blocks omitted: " PRI_U64 "\n", wr_stats->blocks_submitted - wr_stats->blocks_written); - printf("Sparse blocks omitted: %lu\n", proc_stats->sparse_block_count); + printf("Sparse blocks omitted: " PRI_U64 "\n", + proc_stats->sparse_block_count); fputc('\n', stdout); - printf("Fragments actually written: %lu\n", + printf("Fragments actually written: " PRI_U64 "\n", proc_stats->actual_frag_count); - printf("Duplicated fragments omitted: %lu\n", + printf("Duplicated fragments omitted: " PRI_U64 "\n", proc_stats->total_frag_count - proc_stats->actual_frag_count); printf("Total number of inodes: %u\n", super->inode_count); printf("Number of unique group/user IDs: %u\n", super->id_count); -- cgit v1.2.3