systemd/coccinelle/bool-cast.cocci
Zbigniew Jędrzejewski-Szmek 5d904a6aaa tree-wide: drop !! casts to booleans
They are not needed, because anything that is non-zero is converted
to true.

C11:
> 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the
> value compares equal to 0; otherwise, the result is 1.

https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
2018-06-13 10:52:40 +02:00

13 lines
98 B
Plaintext

@@
bool b;
expression y;
@@
- b = !!(y);
+ b = y;
@@
bool b;
expression y;
@@
- b = !!y;
+ b = y;