Skip to contentSkip to conversation

bcache: fix rounding in human readable output

PATCH New Juerd Waalboer 1 participant 1 message Nov 24, 2014 bcache (block layer cache)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcache: fix rounding in human readable output

Division by 100 caused results like 3.9k < 3.10k < 4.0k; fixed by increasing the denominator to 103, which is a better approximation of 1024 / 10 == 102.4

---
 drivers/md/bcache/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/util.c +1 -1
index db3ae4c..56e8a62 100644
@@ -88,7 +88,7 @@ ssize_t bch_hprint(char *buf, int64_t v)
 		return sprintf(buf, "%llu", v);
 
 	if (v < 100 && v > -100)
-		snprintf(dec, sizeof(dec), ".%i", t / 100);
+		snprintf(dec, sizeof(dec), ".%i", t / 103);
 
 	return sprintf(buf, "%lli%s%c", v, dec, units[u]);
 }
Signature · 1 line
2.1.3