On 8/21/24 10:34 PM, Peter Wang (王信友) wrote:
For example, consider the following complex conditional expression: if (a == b && c > d || e < f && g != h)
Hi Peter, As you may know, the above is not allowed in Linux kernel code. I'm not sure this has been written down anywhere formally. The C compilers supported by the Linux kernel emit a warning about expressions like the above and Linux kernel code should be warning-free. I agree with you that code readability is important. However, I think that it's important for Linux kernel developers to make themselves familiar with expressions like (a & b && ...) since this style is common in the Linux kernel. Do you agree that the data below shows that not surrounding binary and expressions with parentheses is common in Linux kernel code? $ git grep -nHE 'if.*&&[^()&]*&[^&]|if.*[^&]&[^&()]*&&' | wc -l 2548 Thanks, Bart.