On Monday 12 September 2022 07:34:43 Simon Glass wrote: > Hi Pali, > > On Sun, 11 Sept 2022 at 03:38, Pali Rohár <p...@kernel.org> wrote: > > > > Function print_size() round size to the nearst value with one decimal > > fraction number. But in special cases also unit order may overflow. > > > > For example value 1073689396 is printed as "1024 MiB" and value 1073741824 > > as "1 GiB". > > > > Fix this issue by detecting order overflow and increasing unit order. > > With this change also value 1073689396 is printed as "1 GiB". > > > > Signed-off-by: Pali Rohár <p...@kernel.org> > > --- > > lib/display_options.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/lib/display_options.c b/lib/display_options.c > > index 360b01bcf5ff..c281c1d2c10d 100644 > > --- a/lib/display_options.c > > +++ b/lib/display_options.c > > @@ -126,6 +126,12 @@ void print_size(uint64_t size, const char *s) > > if (m >= 10) { > > m -= 10; > > n += 1; > > + > > + if (n == 1024 && i > 0) { > > + n = 1; > > + m = 0; > > + c = names[i - 1]; > > + } > > } > > } > > > > -- > > 2.20.1 > > > > Please add a test case for this to test/lib/test_print.c > > Regards, > Simon
Ok, I will look at it.