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:
(3 comments)
File ni845x_spi.c:
https://review.coreboot.org/c/flashrom/+/56637/comment/d140ebc5_d7f3f631 PS1, Line 188: strtol
Use `strtoul()` instead?
+1
https://review.coreboot.org/c/flashrom/+/56637/comment/0abca4ce_09d4ea0e PS1, Line 556: CS_number = CS_str[0] - '0';
This line converts string to number, but only two lines below the condition is checked whether the s […]
That's not a problem though, is it? These are just numbers in C. It might underflow, but that's still defined behavior and the `7 < CS_number` would catch it?
https://review.coreboot.org/c/flashrom/+/56637/comment/f92a4df8_ed289fae PS1, Line 556: CS_number = CS_str[0] - '0'; : free(CS_str); : if (strlen(CS_str) > 1 || 7 < CS_number) { : msg_perr("Only CS 0-7 supported\n"); : return 1; : }
The assignment to `CS_number` can underflow. I'd do the parsing as follows: […]
I would just use strtoul() TBH :)