Skip to content

Commit 70c5eb8

Browse files
committed
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild misc updates from Michal Marek: "The non-critical part of kbuild for v4.6-rc1: - coccinelle cleanup and a new patch - make tags rule for kprobe helpers - make rpm fix to avoid spurious grub2 entries - make rpm support for %postun script (Fedora only at the moment)" * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: kbuild/mkspec: clean boot loader configuration on rpm removal kbuild/mkspec: fix grub2 installkernel issue Coccinelle: Add api/setup_timer.cocci coccinelle: bugon: reduce rule applicability Coccinelle: pm_runtime: reduce rule applicability Coccinelle: array_size: reduce rule applicability Coccinelle: reduce rule applicability scripts/tags.sh: add regex to map kprobe helpers scripts/coccinelle: modernize &
2 parents 3a1ef0e + 6ef41e2 commit 70c5eb8

File tree

8 files changed

+215
-9
lines changed

8 files changed

+215
-9
lines changed

scripts/coccinelle/api/pm_runtime.cocci

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ret = pm_runtime_api(...);
7878
// For org and report mode
7979
//----------------------------------------------------------
8080

81-
@r depends on runtime_bad_err_handle exists@
81+
@r depends on runtime_bad_err_handle && (org || report) exists@
8282
position p1, p2;
8383
identifier pm_runtime_api;
8484
expression ret;
+199
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
/// Use setup_timer function instead of initializing timer with the function
2+
/// and data fields
3+
// Confidence: High
4+
// Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2
5+
// Options: --no-includes --include-headers
6+
// Keywords: init_timer, setup_timer
7+
8+
virtual patch
9+
virtual context
10+
virtual org
11+
virtual report
12+
13+
@match_immediate_function_data_after_init_timer
14+
depends on patch && !context && !org && !report@
15+
expression e, func, da;
16+
@@
17+
18+
-init_timer (&e);
19+
+setup_timer (&e, func, da);
20+
21+
(
22+
-e.function = func;
23+
-e.data = da;
24+
|
25+
-e.data = da;
26+
-e.function = func;
27+
)
28+
29+
@match_function_and_data_after_init_timer
30+
depends on patch && !context && !org && !report@
31+
expression e1, e2, e3, e4, e5, a, b;
32+
@@
33+
34+
-init_timer (&e1);
35+
+setup_timer (&e1, a, b);
36+
37+
... when != a = e2
38+
when != b = e3
39+
(
40+
-e1.function = a;
41+
... when != b = e4
42+
-e1.data = b;
43+
|
44+
-e1.data = b;
45+
... when != a = e5
46+
-e1.function = a;
47+
)
48+
49+
@r1 exists@
50+
identifier f;
51+
position p;
52+
@@
53+
54+
f(...) { ... when any
55+
init_timer@p(...)
56+
... when any
57+
}
58+
59+
@r2 exists@
60+
identifier g != r1.f;
61+
struct timer_list t;
62+
expression e8;
63+
@@
64+
65+
g(...) { ... when any
66+
t.data = e8
67+
... when any
68+
}
69+
70+
// It is dangerous to use setup_timer if data field is initialized
71+
// in another function.
72+
73+
@script:python depends on r2@
74+
p << r1.p;
75+
@@
76+
77+
cocci.include_match(False)
78+
79+
@r3 depends on patch && !context && !org && !report@
80+
expression e6, e7, c;
81+
position r1.p;
82+
@@
83+
84+
-init_timer@p (&e6);
85+
+setup_timer (&e6, c, 0UL);
86+
... when != c = e7
87+
-e6.function = c;
88+
89+
// ----------------------------------------------------------------------------
90+
91+
@match_immediate_function_data_after_init_timer_context
92+
depends on !patch && (context || org || report)@
93+
expression da, e, func;
94+
position j0, j1, j2;
95+
@@
96+
97+
* init_timer@j0 (&e);
98+
(
99+
100+
101+
|
102+
103+
104+
)
105+
106+
@match_function_and_data_after_init_timer_context
107+
depends on !patch &&
108+
!match_immediate_function_data_after_init_timer_context &&
109+
(context || org || report)@
110+
expression a, b, e1, e2, e3, e4, e5;
111+
position j0, j1, j2;
112+
@@
113+
114+
* init_timer@j0 (&e1);
115+
... when != a = e2
116+
when != b = e3
117+
(
118+
119+
... when != b = e4
120+
121+
|
122+
123+
... when != a = e5
124+
125+
)
126+
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;
132+
position r1.p;
133+
position j0, j1;
134+
@@
135+
136+
* init_timer@j0@p (&e6);
137+
... when != c = e7
138+
139+
140+
// ----------------------------------------------------------------------------
141+
142+
@script:python match_immediate_function_data_after_init_timer_org
143+
depends on 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;
147+
@@
148+
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], "")
153+
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;
158+
@@
159+
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], "")
164+
165+
@script:python r3_org depends on org@
166+
j0 << r3_context.j0;
167+
j1 << r3_context.j1;
168+
@@
169+
170+
msg = "Use setup_timer function."
171+
coccilib.org.print_todo(j0[0], msg)
172+
coccilib.org.print_link(j1[0], "")
173+
174+
// ----------------------------------------------------------------------------
175+
176+
@script:python match_immediate_function_data_after_init_timer_report
177+
depends on report@
178+
j0 << match_immediate_function_data_after_init_timer_context.j0;
179+
j1 << match_immediate_function_data_after_init_timer_context.j1;
180+
@@
181+
182+
msg = "Use setup_timer function for function on line %s." % (j1[0].line)
183+
coccilib.report.print_report(j0[0], msg)
184+
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;
188+
@@
189+
190+
msg = "Use setup_timer function for function on line %s." % (j1[0].line)
191+
coccilib.report.print_report(j0[0], msg)
192+
193+
@script:python r3_report depends on report@
194+
j0 << r3_context.j0;
195+
j1 << r3_context.j1;
196+
@@
197+
198+
msg = "Use setup_timer function for function on line %s." % (j1[0].line)
199+
coccilib.report.print_report(j0[0], msg)

scripts/coccinelle/iterators/use_after_iter.cocci

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ list_remove_head(x,c,...)
123123
|
124124
sizeof(<+...c...+>)
125125
|
126-
&c->member
126+
&c->member
127127
|
128128
c = E
129129
|

scripts/coccinelle/misc/array_size.cocci

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ T[] E;
5959
// For org and report mode
6060
//----------------------------------------------------------
6161

62-
@r@
62+
@r depends on (org || report)@
6363
type T;
6464
T[] E;
6565
position p;

scripts/coccinelle/misc/badty.cocci

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ T **x;
5050
// For org and report mode
5151
//----------------------------------------------------------
5252

53-
@r disable sizeof_type_expr@
53+
@r depends on (org || report) disable sizeof_type_expr@
5454
type T;
5555
T **x;
5656
position p;

scripts/coccinelle/misc/bugon.cocci

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ expression e;
4040
// For org and report mode
4141
//----------------------------------------------------------
4242

43-
@r@
43+
@r depends on (org || report)@
4444
expression e;
4545
position p;
4646
@@

scripts/package/mkspec

+9-4
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,16 @@ echo 'rm -rf $RPM_BUILD_ROOT'
131131
echo ""
132132
echo "%post"
133133
echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then"
134-
echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm"
135-
echo "cp /boot/System.map-$KERNELRELEASE /boot/System.map-$KERNELRELEASE-rpm"
134+
echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm"
135+
echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm"
136136
echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE"
137-
echo "/sbin/installkernel $KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm"
138-
echo "rm -f /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm"
137+
echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
138+
echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
139+
echo "fi"
140+
echo ""
141+
echo "%preun"
142+
echo "if [ -x /sbin/new-kernel-pkg ]; then"
143+
echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img"
139144
echo "fi"
140145
echo ""
141146
echo "%files"

scripts/tags.sh

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ regex_c=(
163163
'/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1_rcuidle/'
164164
'/^DEFINE_EVENT([^,)]*, *\([[:alnum:]_]*\).*/trace_\1/'
165165
'/^DEFINE_EVENT([^,)]*, *\([[:alnum:]_]*\).*/trace_\1_rcuidle/'
166+
'/^DEFINE_INSN_CACHE_OPS(\([[:alnum:]_]*\).*/get_\1_slot/'
167+
'/^DEFINE_INSN_CACHE_OPS(\([[:alnum:]_]*\).*/free_\1_slot/'
166168
'/^PAGEFLAG(\([[:alnum:]_]*\).*/Page\1/'
167169
'/^PAGEFLAG(\([[:alnum:]_]*\).*/SetPage\1/'
168170
'/^PAGEFLAG(\([[:alnum:]_]*\).*/ClearPage\1/'

0 commit comments

Comments
 (0)