Skip to content

Commit 2ce079f

Browse files
committed
Merge tag 'kbuild-misc-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild misc updates from Masahiro Yamada: - Clean up and fix RPM package build - Fix a warning in DEB package build - Improve coccicheck script - Improve some semantic patches * tag 'kbuild-misc-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: docs: dev-tools: coccinelle: delete out of date wiki reference coccinelle: orplus: reorganize to improve performance coccinelle: use exists to improve efficiency builddeb: Pass the kernel:debarch substvar to dpkg-genchanges Coccinelle: use false positive annotation coccinelle: fix verbose message about .cocci file being run coccinelle: grep Options and Requires fields more precisely Coccinelle: make DEBUG_FILE option more useful coccinelle: api: detect identical chip data arrays coccinelle: Improve setup_timer.cocci matching Coccinelle: setup_timer: improve messages from setup_timer kbuild: rpm-pkg: do not force -jN in submake kbuild: rpm-pkg: keep spec file until make mrproper kbuild: rpm-pkg: fix jobserver unavailable warning kbuild: rpm-pkg: replace $RPM_BUILD_ROOT with %{buildroot} kbuild: rpm-pkg: fix build error when CONFIG_MODULES is disabled kbuild: rpm-pkg: refactor mkspec with here doc kbuild: rpm-pkg: clean up mkspec kbuild: rpm-pkg: install vmlinux.bz2 unconditionally kbuild: rpm-pkg: remove ppc64 specific image handling
2 parents 09bd7c7 + e9e716f commit 2ce079f

12 files changed

Lines changed: 457 additions & 219 deletions

File tree

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ modules.builtin
5555
/System.map
5656
/Module.markers
5757

58+
#
59+
# RPM spec file (make rpm-pkg)
60+
#
61+
/*.spec
62+
5863
#
5964
# Debian directory (make deb-pkg)
6065
#

‎Documentation/dev-tools/coccinelle.rst‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ of many distributions, e.g. :
3333
You can get the latest version released from the Coccinelle homepage at
3434
http://coccinelle.lip6.fr/
3535

36-
Information and tips about Coccinelle are also provided on the wiki
37-
pages at http://cocci.ekstranet.diku.dk/wiki/doku.php
38-
3936
Once you have it, run the following command::
4037

4138
./configure

‎scripts/coccicheck‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,8 @@ run_cmd_parmap() {
123123
if [ $VERBOSE -ne 0 ] ; then
124124
echo "Running ($NPROC in parallel): $@"
125125
fi
126-
if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
127-
if [ -f $DEBUG_FILE ]; then
128-
echo "Debug file $DEBUG_FILE exists, bailing"
129-
exit
130-
fi
131-
else
132-
DEBUG_FILE="/dev/null"
133-
fi
134-
$@ 2>$DEBUG_FILE
126+
echo $@ >>$DEBUG_FILE
127+
$@ 2>>$DEBUG_FILE
135128
if [[ $? -ne 0 ]]; then
136129
echo "coccicheck failed"
137130
exit $?
@@ -176,8 +169,8 @@ OPTIONS="$OPTIONS $SPFLAGS"
176169
coccinelle () {
177170
COCCI="$1"
178171

179-
OPT=`grep "Option" $COCCI | cut -d':' -f2`
180-
REQ=`grep "Requires" $COCCI | cut -d':' -f2 | sed "s| ||"`
172+
OPT=`grep "Options:" $COCCI | cut -d':' -f2`
173+
REQ=`grep "Requires:" $COCCI | cut -d':' -f2 | sed "s| ||"`
181174
REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh)
182175
if [ "$REQ_NUM" != "0" ] ; then
183176
if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then
@@ -194,7 +187,7 @@ coccinelle () {
194187

195188
if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then
196189

197-
FILE=`echo $COCCI | sed "s|$srctree/||"`
190+
FILE=${COCCI#$srctree/}
198191

199192
echo "Processing `basename $COCCI`"
200193
echo "with option(s) \"$OPT\""
@@ -247,6 +240,15 @@ coccinelle () {
247240

248241
}
249242

243+
if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
244+
if [ -f $DEBUG_FILE ]; then
245+
echo "Debug file $DEBUG_FILE exists, bailing"
246+
exit
247+
fi
248+
else
249+
DEBUG_FILE="/dev/null"
250+
fi
251+
250252
if [ "$COCCI" = "" ] ; then
251253
for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
252254
coccinelle $f
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/// Detect BQ27XXX_DATA structures with identical registers, dm registers or
2+
/// properties.
3+
//# Doesn't unfold macros used in register or property fields.
4+
//# Requires OCaml scripting
5+
///
6+
// Confidence: High
7+
// Copyright: (C) 2017 Julia Lawall, Inria/LIP6, GPLv2.
8+
// URL: http://coccinelle.lip6.fr/
9+
// Requires: 1.0.7
10+
// Keywords: BQ27XXX_DATA
11+
12+
virtual report
13+
14+
@initialize:ocaml@
15+
@@
16+
17+
let print_report p msg =
18+
let p = List.hd p in
19+
Printf.printf "%s:%d:%d-%d: %s" p.file p.line p.col p.col_end msg
20+
21+
@str depends on report@
22+
type t;
23+
identifier i,i1,i2;
24+
expression e1,e2;
25+
@@
26+
27+
t i[] = {
28+
...,
29+
[e1] = BQ27XXX_DATA(i1,...),
30+
...,
31+
[e2] = BQ27XXX_DATA(i2,...),
32+
...,
33+
};
34+
35+
@script:ocaml tocheck@
36+
i1 << str.i1;
37+
i2 << str.i2;
38+
i1regs; i2regs;
39+
i1dmregs; i2dmregs;
40+
i1props; i2props;
41+
@@
42+
43+
if not(i1 = i2)
44+
then
45+
begin
46+
i1regs := make_ident (i1 ^ "_regs");
47+
i2regs := make_ident (i2 ^ "_regs");
48+
i1dmregs := make_ident (i1 ^ "_dm_regs");
49+
i2dmregs := make_ident (i2 ^ "_dm_regs");
50+
i1props := make_ident (i1 ^ "_props");
51+
i2props := make_ident (i2 ^ "_props")
52+
end
53+
54+
(* ---------------------------------------------------------------- *)
55+
56+
@getregs1@
57+
typedef u8;
58+
identifier tocheck.i1regs;
59+
initializer list i1regs_vals;
60+
position p1;
61+
@@
62+
63+
u8 i1regs@p1[...] = { i1regs_vals, };
64+
65+
@getregs2@
66+
identifier tocheck.i2regs;
67+
initializer list i2regs_vals;
68+
position p2;
69+
@@
70+
71+
u8 i2regs@p2[...] = { i2regs_vals, };
72+
73+
@script:ocaml@
74+
(_,i1regs_vals) << getregs1.i1regs_vals;
75+
(_,i2regs_vals) << getregs2.i2regs_vals;
76+
i1regs << tocheck.i1regs;
77+
i2regs << tocheck.i2regs;
78+
p1 << getregs1.p1;
79+
p2 << getregs2.p2;
80+
@@
81+
82+
if i1regs < i2regs &&
83+
List.sort compare i1regs_vals = List.sort compare i2regs_vals
84+
then
85+
let msg =
86+
Printf.sprintf
87+
"WARNING %s and %s (line %d) are identical\n"
88+
i1regs i2regs (List.hd p2).line in
89+
print_report p1 msg
90+
91+
(* ---------------------------------------------------------------- *)
92+
93+
@getdmregs1@
94+
identifier tocheck.i1dmregs;
95+
initializer list i1dmregs_vals;
96+
position p1;
97+
@@
98+
99+
struct bq27xxx_dm_reg i1dmregs@p1[] = { i1dmregs_vals, };
100+
101+
@getdmregs2@
102+
identifier tocheck.i2dmregs;
103+
initializer list i2dmregs_vals;
104+
position p2;
105+
@@
106+
107+
struct bq27xxx_dm_reg i2dmregs@p2[] = { i2dmregs_vals, };
108+
109+
@script:ocaml@
110+
(_,i1dmregs_vals) << getdmregs1.i1dmregs_vals;
111+
(_,i2dmregs_vals) << getdmregs2.i2dmregs_vals;
112+
i1dmregs << tocheck.i1dmregs;
113+
i2dmregs << tocheck.i2dmregs;
114+
p1 << getdmregs1.p1;
115+
p2 << getdmregs2.p2;
116+
@@
117+
118+
if i1dmregs < i2dmregs &&
119+
List.sort compare i1dmregs_vals = List.sort compare i2dmregs_vals
120+
then
121+
let msg =
122+
Printf.sprintf
123+
"WARNING %s and %s (line %d) are identical\n"
124+
i1dmregs i2dmregs (List.hd p2).line in
125+
print_report p1 msg
126+
127+
(* ---------------------------------------------------------------- *)
128+
129+
@getprops1@
130+
identifier tocheck.i1props;
131+
initializer list[n1] i1props_vals;
132+
position p1;
133+
@@
134+
135+
enum power_supply_property i1props@p1[] = { i1props_vals, };
136+
137+
@getprops2@
138+
identifier tocheck.i2props;
139+
initializer list[n2] i2props_vals;
140+
position p2;
141+
@@
142+
143+
enum power_supply_property i2props@p2[] = { i2props_vals, };
144+
145+
@script:ocaml@
146+
(_,i1props_vals) << getprops1.i1props_vals;
147+
(_,i2props_vals) << getprops2.i2props_vals;
148+
i1props << tocheck.i1props;
149+
i2props << tocheck.i2props;
150+
p1 << getprops1.p1;
151+
p2 << getprops2.p2;
152+
@@
153+
154+
if i1props < i2props &&
155+
List.sort compare i1props_vals = List.sort compare i2props_vals
156+
then
157+
let msg =
158+
Printf.sprintf
159+
"WARNING %s and %s (line %d) are identical\n"
160+
i1props i2props (List.hd p2).line in
161+
print_report p1 msg

0 commit comments

Comments
 (0)