diff --git a/adaptive_compress.c b/adaptive_compress.c index 571e435..3b2cf53 100644 --- a/adaptive_compress.c +++ b/adaptive_compress.c @@ -84,11 +84,15 @@ void adapt_stats(int show) { if (show) { - fprintf(stderr, "Adaptive mode stats:\n"); - fprintf(stderr, " BZIP2 chunk count: %u\n", bzip2_count); - fprintf(stderr, " LIBBSC chunk count: %u\n", bsc_count); - fprintf(stderr, " PPMd chunk count: %u\n", ppmd_count); - fprintf(stderr, " LZMA chunk count: %u\n\n", lzma_count); + if (bzip2_count > 0 || bsc_count > 0 || ppmd_count > 0 || lzma_count > 0) { + fprintf(stderr, "Adaptive mode stats:\n"); + fprintf(stderr, " BZIP2 chunk count: %u\n", bzip2_count); + fprintf(stderr, " LIBBSC chunk count: %u\n", bsc_count); + fprintf(stderr, " PPMd chunk count: %u\n", ppmd_count); + fprintf(stderr, " LZMA chunk count: %u\n\n", lzma_count); + } else { + fprintf(stderr, "\n"); + } } lzma_count = 0; bzip2_count = 0; diff --git a/libbsc_compress.c b/libbsc_compress.c index c012393..485ded6 100644 --- a/libbsc_compress.c +++ b/libbsc_compress.c @@ -96,8 +96,8 @@ libbsc_init(void **data, int *level, int nthreads, uint64_t chunksize, int rv; if (chunksize > BSC_MAX_CHUNK) { - fprintf(stderr, "Max allowed chunk size for LIBBSC is: %ld \n", - BSC_MAX_CHUNK); + fprintf(stderr, "Max allowed chunk size for LIBBSC is: %s \n", + bytes_to_size(BSC_MAX_CHUNK)); return (1); } bscdat = slab_alloc(NULL, sizeof (struct libbsc_params)); diff --git a/main.c b/main.c index 0c3117d..25f9f11 100644 --- a/main.c +++ b/main.c @@ -200,13 +200,17 @@ show_compression_stats(uint64_t chunksize) fprintf(stderr, "\nCompression Statistics\n"); fprintf(stderr, "======================\n"); fprintf(stderr, "Total chunks : %u\n", chunk_num); - fprintf(stderr, "Best compressed chunk : %s(%.2f%%)\n", - bytes_to_size(smallest_chunk), (double)smallest_chunk/(double)chunksize*100); - fprintf(stderr, "Worst compressed chunk : %s(%.2f%%)\n", - bytes_to_size(largest_chunk), (double)largest_chunk/(double)chunksize*100); - avg_chunk /= chunk_num; - fprintf(stderr, "Avg compressed chunk : %s(%.2f%%)\n\n", - bytes_to_size(avg_chunk), (double)avg_chunk/(double)chunksize*100); + if (chunk_num == 0) { + fprintf(stderr, "No statistics to display.\n"); + } else { + fprintf(stderr, "Best compressed chunk : %s(%.2f%%)\n", + bytes_to_size(smallest_chunk), (double)smallest_chunk/(double)chunksize*100); + fprintf(stderr, "Worst compressed chunk : %s(%.2f%%)\n", + bytes_to_size(largest_chunk), (double)largest_chunk/(double)chunksize*100); + avg_chunk /= chunk_num; + fprintf(stderr, "Avg compressed chunk : %s(%.2f%%)\n\n", + bytes_to_size(avg_chunk), (double)avg_chunk/(double)chunksize*100); + } } void