
13 Feb
2022
13 Feb
'22
10:33 p.m.
On Sun, 13 Feb 2022 22:23:10 +0100 Pali Rohár pali@kernel.org wrote:
In that case the whole ternary operator can be dropped, i.e. instead of ((hdr->ext > 1) ? (hdr->ext * 0x20) : 0) you can have ((hdr->ext - 1) * 0x20) if I interpret this correctly.
No, it cannot be dropped, with correction it is:
((hdr->ext > 1) ? ((hdr->ext - 1) * 0x20) : 0)
When hdr->ext is zero, result must be also 0, not (uint8_t)-1 * 0x20.
Oh, so hdr->ext can be zero. OK.
So you can drop at least the "> 1": hdr->ext ? ((hdr->ext - 1) * 0x20) : 0 but that is almost as horrible as with "> 1", so you can keep it if you want :)
Marek