Attention is currently required from: Krystian Hebel.
Hello build bot (Jenkins), Michał Żygowski,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/70106
to look at the new patch set (#2).
Change subject: commonlib/helpers.h: use unsigned literals in definitions ......................................................................
commonlib/helpers.h: use unsigned literals in definitions
This protects against some of unintentional integer promotions, e.g.:
uint16_t freq_mhz = 2148; // or bigger uint64_t freq = freq_mhz * MHz;
In this example, MHz used to be treated as int32_t, and because int32_t can represent every value that uin16_t can, multiplication was being performed with both arguments treated as int32_t. During assignment, result of multiplication is promoted to int64_t (because it can represent each value that int32_t can), and finally implicitly converted to uint64_t.
Promotions preserve the value, including the sign, so if result of multiplication is negative, the same negative number (but extended to 64 bits) is converted to unsigned number.
Signed-off-by: Krystian Hebel krystian.hebel@3mdeb.com Change-Id: Ie60a6ee82db80328e44639175272cc8097f36c3b Signed-off-by: Krystian Hebel krystian.hebel@3mdeb.com --- M src/commonlib/bsd/include/commonlib/bsd/helpers.h 1 file changed, 33 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/06/70106/2