Attention is currently required from: Máté Kukri.
Nico Huber has posted comments on this change by Máté Kukri. ( https://review.coreboot.org/c/coreboot/+/81529?usp=email )
Change subject: mb/dell/optiplex_9020: Implement late HWM initialization ......................................................................
Patch Set 11:
(1 comment)
File src/mainboard/dell/optiplex_9020/mainboard.c:
https://review.coreboot.org/c/coreboot/+/81529/comment/dfc61416_515212fb?usp... : PS11, Line 310: / rapl_power_unit Coverity reported this a while ago, wasn't sure what's right to do so didn't fix it, forgot about it ._. and now noticed again.
There's actually a potential divide-by-zero on all paths: 1. When it's `0` from the beginning (the `if` doesn't trigger) 2. When the MSR value is `> 7`, storing the result in the `uint8_t` makes it `0`.
Hmmm, and now I realize that it's actually not that complicated, but please check my reasoning: 1. Can be avoided by making it simply `rapl_power_unit = 1 << rapl_power_unit;`, no `if`. Also seems more cannonical. 2. Never use fixed-width types unless you have to. Using `unsigned int` everywhere inside this function would avoid potential overflows.