1 // Check if refcount_t type and API should be used
2 // instead of atomic_t type when dealing with refcounters
4 // Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
6 // Confidence: Moderate
7 // URL: http://coccinelle.lip6.fr/
8 // Options: --include-headers --very-quiet
15 identifier fname =~ ".*free.*";
16 identifier fname2 =~ ".*destroy.*";
17 identifier fname3 =~ ".*del.*";
18 identifier fname4 =~ ".*queue_work.*";
19 identifier fname5 =~ ".*schedule_work.*";
20 identifier fname6 =~ ".*call_rcu.*";
25 atomic_dec_and_test@p1(&(a)->x)
27 atomic_dec_and_lock@p1(&(a)->x, ...)
29 atomic_long_dec_and_lock@p1(&(a)->x, ...)
31 atomic_long_dec_and_test@p1(&(a)->x)
33 atomic64_dec_and_test@p1(&(a)->x)
35 local_dec_and_test@p1(&(a)->x)
53 @script:python depends on report@
57 msg = "atomic_dec_and_test variation before object free at line %s."
58 coccilib.report.print_report(p1[0], msg % (p2[0].line))
63 identifier fname =~ ".*free.*";
68 atomic_dec_and_test@p1(&(a)->x)
70 atomic_dec_and_lock@p1(&(a)->x, ...)
72 atomic_long_dec_and_lock@p1(&(a)->x, ...)
74 atomic_long_dec_and_test@p1(&(a)->x)
76 atomic64_dec_and_test@p1(&(a)->x)
78 local_dec_and_test@p1(&(a)->x)
86 @script:python depends on report@
90 msg = "atomic_dec_and_test variation before object free at line %s."
91 coccilib.report.print_report(p1[0], msg % (p2[0].line))
99 atomic_add_unless(&(a)->x,-1,1)@p1
101 atomic_long_add_unless(&(a)->x,-1,1)@p1
103 atomic64_add_unless(&(a)->x,-1,1)@p1
106 @script:python depends on report@
109 msg = "atomic_add_unless"
110 coccilib.report.print_report(p1[0], msg)
118 x = atomic_add_return@p1(-1, ...);
120 x = atomic_long_add_return@p1(-1, ...);
122 x = atomic64_add_return@p1(-1, ...);
125 @script:python depends on report@
128 msg = "x = atomic_add_return(-1, ...)"
129 coccilib.report.print_report(p1[0], msg)