What happens if you do: ((u64)CEC_TIM_START_BIT_TOTAL +
I think that forces everything else in the expression to be evaluated
as u64.
Well, in this case the operator precedence takes place and the
expression len * 10 * CEC_TIM_DATA_BIT_TOTAL is computed first. So the
issue remains the same.
I can switch the expressions as follows:
(u64)len * 10 * CEC_TIM_DATA_BIT_TOTAL + CEC_TIM_START_BIT_TOTAL
What about:
10ULL * len * ...
and avoid the cast in the middle.
What do you think?
My problem is that (u64)len suggests that there is some problem with len
specifically, which isn't true.
It definitely needs a comment that this fixes a bogus Coverity report.
I actually added the following line to the message changelog:
Addresses-Coverity-ID: 1454996 ("Unintentional integer overflow")
That needs to be in the source, otherwise someone will remove the
cast (or ULL) at some time in the future since it isn't clear why
it is done. And nobody reads commit logs from X years back :-)