Linux Audio

Check our new training course

Loading...
v6.2
 1// SPDX-License-Identifier: GPL-2.0-only
 2/// Check for constants that are added but are used elsewhere as bitmasks
 3/// The results should be checked manually to ensure that the nonzero
 4/// bits in the two constants are actually disjoint.
 5///
 6// Confidence: Moderate
 7// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6.
 8// Copyright: (C) 2013 Gilles Muller, INRIA/LIP6.
 9// URL: https://coccinelle.gitlabpages.inria.fr/website
10// Comments:
11// Options: --no-includes --include-headers
12
13virtual org
14virtual report
15virtual context
16
17@r@
18constant c,c1;
19identifier i,i1;
20position p;
21@@
22
23(
24 c1 + c - 1
25|
26 c1@i1 +@p c@i
27)
28
29@s@
30constant r.c, r.c1;
31identifier i;
32expression e;
33@@
34
35(
36e | c@i
37|
38e & c@i
39|
40e |= c@i
41|
42e &= c@i
43|
44e | c1@i
45|
46e & c1@i
47|
48e |= c1@i
49|
50e &= c1@i
51)
52
53@depends on s@
54position r.p;
55constant c1,c2;
 
56@@
57
58* c1 +@p c2
 
 
 
 
59
60@script:python depends on s && org@
61p << r.p;
62@@
63
64cocci.print_main("sum of probable bitmasks, consider |",p)
65
66@script:python depends on s && report@
67p << r.p;
68@@
69
70msg = "WARNING: sum of probable bitmasks, consider |"
71coccilib.report.print_report(p[0],msg)
v4.10.11
 
 1/// Check for constants that are added but are used elsewhere as bitmasks
 2/// The results should be checked manually to ensure that the nonzero
 3/// bits in the two constants are actually disjoint.
 4///
 5// Confidence: Moderate
 6// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6.  GPLv2.
 7// Copyright: (C) 2013 Gilles Muller, INRIA/LIP6.  GPLv2.
 8// URL: http://coccinelle.lip6.fr/
 9// Comments:
10// Options: --no-includes --include-headers
11
12virtual org
13virtual report
14virtual context
15
16@r@
17constant c;
 
 
 
 
 
 
 
 
 
 
 
 
18identifier i;
19expression e;
20@@
21
22(
23e | c@i
24|
25e & c@i
26|
27e |= c@i
28|
29e &= c@i
 
 
 
 
 
 
 
 
30)
31
32@s@
33constant r.c,c1;
34identifier i1;
35position p;
36@@
37
38(
39 c1 + c - 1
40|
41*c1@i1 +@p c
42)
43
44@script:python depends on org@
45p << s.p;
46@@
47
48cocci.print_main("sum of probable bitmasks, consider |",p)
49
50@script:python depends on report@
51p << s.p;
52@@
53
54msg = "WARNING: sum of probable bitmasks, consider |"
55coccilib.report.print_report(p[0],msg)