From d0a50f38e6d932af655a049cff9be1e21289a2d7 Mon Sep 17 00:00:00 2001 From: TheVice Date: Fri, 8 Mar 2024 05:04:34 +0200 Subject: [PATCH] [programs] added support for up-to-date compilers. [fileio.c] resolved issue with division double on U64 by casting result of U64 on U64 division. [fullbench.c|zlibh.c] resolved issues that happen when attempt to compile C code at up-to-date C++ compiler. --- programs/fileio.c | 4 ++-- programs/fullbench.c | 2 +- programs/zlibh.c | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 77cc91a..40d1c19 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -401,7 +401,7 @@ unsigned long long FIO_compressFilename(const char* output_filename, const char* break; } - DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%% ", (U32)(filesize>>20), (double)compressedfilesize/filesize*100); + DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%% ", (U32)(filesize>>20), (double)(compressedfilesize/filesize)*100); } /* Checksum */ @@ -418,7 +418,7 @@ unsigned long long FIO_compressFilename(const char* output_filename, const char* /* Status */ DISPLAYLEVEL(2, "\r%79s\r", ""); DISPLAYLEVEL(2,"Compressed %llu bytes into %llu bytes ==> %.2f%%\n", - (unsigned long long) filesize, (unsigned long long) compressedfilesize, (double)compressedfilesize/filesize*100); + (unsigned long long) filesize, (unsigned long long) compressedfilesize, (double)(compressedfilesize/filesize)*100); /* clean */ free(in_buff); diff --git a/programs/fullbench.c b/programs/fullbench.c index ac0b443..50edfb4 100644 --- a/programs/fullbench.c +++ b/programs/fullbench.c @@ -188,7 +188,7 @@ static int local_count8v2(void* dst, size_t dstSize, const void* src, size_t src memset(count, 0, sizeof(count)); while (ptr != end) { - register U64 bs = next; + U64 bs = next; next = *ptr++; count[ 0][(BYTE)bs] ++; diff --git a/programs/zlibh.c b/programs/zlibh.c index d97f6fb..d12d482 100644 --- a/programs/zlibh.c +++ b/programs/zlibh.c @@ -63,8 +63,10 @@ You can contact the author at : #endif #ifdef __GNUC__ // GCC +#ifndef __cplusplus # pragma GCC diagnostic ignored "-Wstrict-prototypes" #endif +#endif /* * Maximums for allocations and loops. It is not useful to change these -- @@ -532,7 +534,7 @@ static void feed_bltree(tree_desc * ltree_desc, tree_desc * bltree_desc) */ static unsigned bi_reverse(unsigned code, int len) { - register unsigned res = 0; + unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1;