diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-06-11 16:02:03 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-06-13 10:52:40 +0200 |
commit | 5d904a6aaaceae7fe2f11d6b848b0dd45e3fd1c4 (patch) | |
tree | b030bb7f74e44a28676f91d05faae95ed0c80a94 /coccinelle | |
parent | test-alloc-util: add a "test" for bool casts (diff) | |
download | systemd-5d904a6aaaceae7fe2f11d6b848b0dd45e3fd1c4.tar.xz systemd-5d904a6aaaceae7fe2f11d6b848b0dd45e3fd1c4.zip |
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
Diffstat (limited to 'coccinelle')
-rw-r--r-- | coccinelle/bool-cast.cocci | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/coccinelle/bool-cast.cocci b/coccinelle/bool-cast.cocci new file mode 100644 index 0000000000..051ccb9417 --- /dev/null +++ b/coccinelle/bool-cast.cocci @@ -0,0 +1,12 @@ +@@ +bool b; +expression y; +@@ +- b = !!(y); ++ b = y; +@@ +bool b; +expression y; +@@ +- b = !!y; ++ b = y; |