Fix buffer usage printing in dlogutil 48/269648/2
authorMateusz Majewski <m.majewski2@samsung.com>
Wed, 19 Jan 2022 13:13:50 +0000 (14:13 +0100)
committerMateusz Majewski <m.majewski2@samsung.com>
Thu, 20 Jan 2022 13:06:49 +0000 (14:06 +0100)
Without converting to unsigned long long, the calculation would overflow
when the buffer usage would get higher than around 42 MB. This doesn't
really happen, since the buffer capacity currently is not even close to
that value. However, there's no reason not to fix this.

Change-Id: Ib1a440b08ac01a1996f1542719070271d0936f79

src/logutil/logutil.c

index 53e16e0..9ecf681 100644 (file)
@@ -82,7 +82,7 @@ static int print_buffer_capacity(dlogutil_state_s *state, log_id_t buffer)
        if (r != 0)
                return r;
 
-       printf("%s: %u KiB, of which %u used (%u%%)\n", name, BtoKiB(capacity), BtoKiB(usage), 100 * usage / capacity);
+       printf("%s: %u KiB, of which %u used (%llu%%)\n", name, BtoKiB(capacity), BtoKiB(usage), 100LLU * usage / capacity);
        return 0;
 }