]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
human_size() should use size_t
authorScott Baker <scott@perturb.org>
Sat, 5 Jun 2021 15:45:35 +0000 (08:45 -0700)
committerW. Felix Handte <w@felixhandte.com>
Thu, 10 Jun 2021 16:53:07 +0000 (12:53 -0400)
programs/util.c
programs/util.h

index 6d04b8fb77e846627a475f122f1ea5f56177cc04..cdfda1ca0b02c8996fbcd501ede029d19daeb830 100644 (file)
@@ -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';
        }
index aaaf2522ca398cdbb856f9e939123a8c7466aea3..8ac930d8cb7b0bad4f536864a92a6b2c1d95ccc6 100644 (file)
@@ -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.