1 /// Use setup_timer function instead of initializing timer with the function
4 // Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2
5 // Options: --no-includes --include-headers
6 // Keywords: init_timer, setup_timer
13 @match_immediate_function_data_after_init_timer
14 depends on patch && !context && !org && !report@
15 expression e, func, da;
19 +setup_timer (&e, func, da);
29 @match_function_and_data_after_init_timer
30 depends on patch && !context && !org && !report@
31 expression e1, e2, e3, e4, e5, a, b;
35 +setup_timer (&e1, a, b);
70 // It is dangerous to use setup_timer if data field is initialized
71 // in another function.
73 @script:python depends on r2@
77 cocci.include_match(False)
79 @r3 depends on patch && !context && !org && !report@
85 +setup_timer (&e6, c, 0UL);
89 // ----------------------------------------------------------------------------
91 @match_immediate_function_data_after_init_timer_context
92 depends on !patch && (context || org || report)@
93 expression da, e, func;
99 * e@j1.function = func;
103 * e@j2.function = func;
106 @match_function_and_data_after_init_timer_context
108 !match_immediate_function_data_after_init_timer_context &&
109 (context || org || report)@
110 expression a, b, e1, e2, e3, e4, e5;
114 * init_timer@j0 (&e1);
118 * e1@j1.function = a;
124 * e1@j2.function = a;
127 @r3_context depends on !patch &&
128 !match_immediate_function_data_after_init_timer_context &&
129 !match_function_and_data_after_init_timer_context &&
130 (context || org || report)@
131 expression c, e6, e7;
136 * init_timer@j0@p (&e6);
138 * e6@j1.function = c;
140 // ----------------------------------------------------------------------------
142 @script:python match_immediate_function_data_after_init_timer_org
144 j0 << match_immediate_function_data_after_init_timer_context.j0;
145 j1 << match_immediate_function_data_after_init_timer_context.j1;
146 j2 << match_immediate_function_data_after_init_timer_context.j2;
149 msg = "Use setup_timer function."
150 coccilib.org.print_todo(j0[0], msg)
151 coccilib.org.print_link(j1[0], "")
152 coccilib.org.print_link(j2[0], "")
154 @script:python match_function_and_data_after_init_timer_org depends on org@
155 j0 << match_function_and_data_after_init_timer_context.j0;
156 j1 << match_function_and_data_after_init_timer_context.j1;
157 j2 << match_function_and_data_after_init_timer_context.j2;
160 msg = "Use setup_timer function."
161 coccilib.org.print_todo(j0[0], msg)
162 coccilib.org.print_link(j1[0], "")
163 coccilib.org.print_link(j2[0], "")
165 @script:python r3_org depends on org@
170 msg = "Use setup_timer function."
171 coccilib.org.print_todo(j0[0], msg)
172 coccilib.org.print_link(j1[0], "")
174 // ----------------------------------------------------------------------------
176 @script:python match_immediate_function_data_after_init_timer_report
178 j0 << match_immediate_function_data_after_init_timer_context.j0;
179 j1 << match_immediate_function_data_after_init_timer_context.j1;
182 msg = "Use setup_timer function for function on line %s." % (j1[0].line)
183 coccilib.report.print_report(j0[0], msg)
185 @script:python match_function_and_data_after_init_timer_report depends on report@
186 j0 << match_function_and_data_after_init_timer_context.j0;
187 j1 << match_function_and_data_after_init_timer_context.j1;
190 msg = "Use setup_timer function for function on line %s." % (j1[0].line)
191 coccilib.report.print_report(j0[0], msg)
193 @script:python r3_report depends on report@
198 msg = "Use setup_timer function for function on line %s." % (j1[0].line)
199 coccilib.report.print_report(j0[0], msg)