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

Coccinelle: doubletest: reduce side effect false positives

Ensure that the cited expression is not a function call or an
assignment to reduce the chance of false positives.

Slightly modify the warning message to indicate another source
of false positves.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

authored by

Julia Lawall and committed by
Masahiro Yamada
09d4d964 d6c6ab93

+26 -8
+26 -8
scripts/coccinelle/tests/doubletest.cocci
··· 1 1 /// Find &&/|| operations that include the same argument more than once 2 - //# A common source of false positives is when the argument performs a side 3 - //# effect. 2 + //# A common source of false positives is when the expression, or 3 + //# another expresssion in the same && or || operation, performs a 4 + //# side effect. 4 5 /// 5 6 // Confidence: Moderate 6 7 // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. ··· 21 20 @@ 22 21 23 22 ( 24 - * E@p 25 - || ... || E 23 + E@p || ... || E 26 24 | 27 - * E@p 28 - && ... && E 25 + E@p && ... && E 29 26 ) 30 27 31 - @script:python depends on org@ 28 + @bad@ 29 + expression r.E,e1,e2,fn; 30 + position r.p; 31 + assignment operator op; 32 + @@ 33 + 34 + ( 35 + E@p 36 + & 37 + <+... \(fn(...)\|e1 op e2\|e1++\|e1--\|++e1\|--e1\) ...+> 38 + ) 39 + 40 + @depends on context && !bad@ 41 + expression r.E; 42 + position r.p; 43 + @@ 44 + 45 + *E@p 46 + 47 + @script:python depends on org && !bad@ 32 48 p << r.p; 33 49 @@ 34 50 35 51 cocci.print_main("duplicated argument to && or ||",p) 36 52 37 - @script:python depends on report@ 53 + @script:python depends on report && !bad@ 38 54 p << r.p; 39 55 @@ 40 56