Attention is currently required from: Miklós Márton, Angel Pons, Anastasia Klimchuk. Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/56637 )
Change subject: ni845x_spi: Fix signed - unsigned comparisons ......................................................................
Patch Set 1:
(1 comment)
File ni845x_spi.c:
https://review.coreboot.org/c/flashrom/+/56637/comment/72c152ff_c72a42b9 PS1, Line 556: CS_number = CS_str[0] - '0';
Is underflow behavior defined for `unsigned char`?
The operands are first promoted to `int`, so technically this is a conversion issue of the negative result. Which is defined as follows:
"[...] if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type."
With a footnote:
"The rules describe arithmetic on the mathematical value, not the value of a given type of expression."
If it was a computation on `unsigned` types, this would apply:
"A computation involving unsigned operands can never overflow, because a result that cannot be represented by the resulting unsigned integer type is reduced modulo the number that is one greater than the largest value that can be represented by the resulting type."