diff options
author | Andrea Adami <andrea.adami@gmail.com> | 2018-01-29 23:07:12 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2018-01-30 09:24:22 +0100 |
commit | c75d1044ea8a04e6808e20814a92beb8657c8f95 (patch) | |
tree | 7f8fcbc52aa96e940f9773bb8357dab71aa8d9c5 /tests/ubi-tests/helpers.c | |
parent | 61afcc6f46368caf4b8eb64612decebb05fadba7 (diff) |
ubi-utils: ubiformat.c: convert to integer arithmetic
Do not cast percent to double, it is just used as upper limit.
Avoid floating point to fix compilation for aarch64 against klibc:
error: '-mgeneral-regs-only' is incompatible with floating-point code
| int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
| ^~~~~~~
Notes:
* The checks in the code above this line ensure that si->good_cnt is not 0.
* The code assumes si->good_cnt * 100 will not overflow, then we can use
(si->ok_cnt * 100) safely because the former is bigger.
* The truncated result does not affect the logic:
i.e. a value of 49.9 is truncated to 49 and is still <50.
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/ubi-tests/helpers.c')
0 files changed, 0 insertions, 0 deletions