bcachefs: bch2_hprint(): don't print decimal if conversion was exact
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 28 Dec 2021 21:01:25 +0000 (16:01 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:20 +0000 (17:09 -0400)
There's places where we parse these numbers, and our parsing doesn't
cope with decimals currently - this is a hack to get the device_add path
working again where for the device blocksize there doesn't ever need to
be a decimal.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/util.c

index 8211c9a1b6cb761120d5d42e58108a43ad53c260..e7675b4597db2cce34e66df86adeba31fe02554c 100644 (file)
@@ -114,7 +114,7 @@ void bch2_hprint(struct printbuf *buf, s64 v)
         * 103 is magic: t is in the range [-1023, 1023] and we want
         * to turn it into [-9, 9]
         */
-       if (u && v < 100 && v > -100)
+       if (u && t && v < 100 && v > -100)
                pr_buf(buf, ".%i", t / 103);
        if (u)
                pr_buf(buf, "%c", si_units[u]);