From: Scott Baker Date: Sat, 5 Jun 2021 15:45:35 +0000 (-0700) Subject: human_size() should use size_t X-Git-Tag: v1.5.1~1^2~149^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5fc830795f2966d0198bf3b6523e86984fbf4fa;p=thirdparty%2Fzstd.git human_size() should use size_t --- diff --git a/programs/util.c b/programs/util.c index 6d04b8fb7..cdfda1ca0 100644 --- a/programs/util.c +++ b/programs/util.c @@ -121,7 +121,7 @@ int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg, * Functions ***************************************/ -char* humanSize(long size, char* str) { +char* humanSize(size_t size, char* str) { if (size > 1125899906842624L) { snprintf(str, 7, "%.1fP", (float)size / 1125899906842624L); } else if (size > 1099511627776L) { @@ -132,8 +132,8 @@ char* humanSize(long size, char* str) { snprintf(str, 7, "%.1fM", (float)size / 1048576L); } else if (size > 1024) { snprintf(str, 7, "%.1fK", (float)size / 1024); - } else if (size >= 0) { - snprintf(str, 7, "%dB", 0); + } else if (size <= 1024) { + snprintf(str, 7, "%luB", size); } else { str[0] = '\0'; } diff --git a/programs/util.h b/programs/util.h index aaaf2522c..8ac930d8c 100644 --- a/programs/util.h +++ b/programs/util.h @@ -122,7 +122,7 @@ int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg, const #define STRDUP(s) strdup(s) #endif -char* humanSize(long size, char* str); +char* humanSize(size_t size, char* str); /** * Calls platform's equivalent of stat() on filename and writes info to statbuf.