Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

coccinelle: misc: add excluded_middle.cocci script

Check for !A || A && B condition. It's equivalent to !A || B.

Signed-off-by: Denis Efremov <efremov@linux.com>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

authored by

Denis Efremov and committed by
Julia Lawall
b76f0ea0 a19d1358

+39
+39
scripts/coccinelle/misc/excluded_middle.cocci
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /// 3 + /// Condition !A || A && B is equivalent to !A || B. 4 + /// 5 + // Confidence: High 6 + // Copyright: (C) 2020 Denis Efremov ISPRAS 7 + // Options: --no-includes --include-headers 8 + 9 + virtual patch 10 + virtual context 11 + virtual org 12 + virtual report 13 + 14 + @r depends on !patch@ 15 + expression A, B; 16 + position p; 17 + @@ 18 + 19 + * !A || (A &&@p B) 20 + 21 + @depends on patch@ 22 + expression A, B; 23 + @@ 24 + 25 + !A || 26 + - (A && B) 27 + + B 28 + 29 + @script:python depends on report@ 30 + p << r.p; 31 + @@ 32 + 33 + coccilib.report.print_report(p[0], "WARNING !A || A && B is equivalent to !A || B") 34 + 35 + @script:python depends on org@ 36 + p << r.p; 37 + @@ 38 + 39 + coccilib.org.print_todo(p[0], "WARNING !A || A && B is equivalent to !A || B")