]> git.baikalelectronics.ru Git - uboot.git/commit
display_options: print_size: Fix order overflow
authorPali Rohár <pali@kernel.org>
Mon, 12 Sep 2022 19:02:27 +0000 (21:02 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 23 Sep 2022 19:13:18 +0000 (15:13 -0400)
commit6ef7ca3ce4736fa4eb487c053efbc76d590eea49
tree8ff2702026d701888ebc9145c4e567ff8ad31412
parent4e542484531786bada565aec2d18c9c5fbe44b58
display_options: print_size: Fix order overflow

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 <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
lib/display_options.c
test/lib/test_print.c