aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-05-17 00:32:07 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-05-22 08:48:44 +0530
commite83f4ca62f91aadf6c576f96a0ea1524edcc3851 (patch)
tree1a6e69e621b8180c17dd9b2b5d80fcc6b02e9a5f /src
parentfb4728bc317ff90f8cc11055194fb3e0e4d33ec7 (diff)
downloadnnn-e83f4ca62f91aadf6c576f96a0ea1524edcc3851.tar.gz
Refactor coolsize
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 97f2079..3486a83 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2027,7 +2027,7 @@ static char *coolsize(off_t size)
rem = i = 0;
- while (size > 1024) {
+ while (size >= 1024) {
rem = size & (0x3FF); /* 1024 - 1 = 0x3FF */
size >>= 10;
++i;
@@ -2070,9 +2070,9 @@ static char *coolsize(off_t size)
}
if (i > 0 && i < 6)
- snprintf(size_buf, 12, "%lu.%0*lu%c", (ulong)size, i, (ulong)rem, U[i]);
+ snprintf(size_buf, 12, "%u.%0*u%c", (uint)size, i & 0b11, (uint)rem, U[i]);
else
- snprintf(size_buf, 12, "%lu%c", (ulong)size, U[i]);
+ snprintf(size_buf, 12, "%u%c", (uint)size, U[i]);
return size_buf;
}