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