Skip to content

Commit 321d03c

Browse files
committed
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull misc kbuild changes from Michal Marek: "Here is the non-critical part of kbuild: - One bogus coccinelle check removed, one check fixed not to suggest the obsolete PTR_RET macro - scripts/tags.sh does not index the generated *.mod.c files - new objdiff tool to list differences between two versions of an object file - A fix for scripts/bootgraph.pl" * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: scripts/coccinelle: Use PTR_ERR_OR_ZERO scripts/bootgraph.pl: Add graphic header scripts: objdiff: detect object code changes between two commits Coccicheck: Remove memcpy to struct assignment test scripts/tags.sh: Ignore *.mod.c
2 parents fd1232b + f23a9fa commit 321d03c

File tree

6 files changed

+196
-120
lines changed

6 files changed

+196
-120
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve
428428

429429
# Files to ignore in find ... statements
430430

431-
RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
432-
-o -name .pc -o -name .hg -o -name .git \) -prune -o
431+
export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
432+
-name CVS -o -name .pc -o -name .hg -o -name .git \) \
433+
-prune -o
433434
export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
434435
--exclude CVS --exclude .pc --exclude .hg --exclude .git
435436

@@ -1103,7 +1104,7 @@ CLEAN_DIRS += $(MODVERDIR)
11031104

11041105
# Directories & files removed with 'make mrproper'
11051106
MRPROPER_DIRS += include/config usr/include include/generated \
1106-
arch/*/include/generated
1107+
arch/*/include/generated .tmp_objdiff
11071108
MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
11081109
Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
11091110
signing_key.priv signing_key.x509 x509.genkey \

scripts/bootgraph.pl

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,31 @@
3838
#
3939

4040
use strict;
41+
use Getopt::Long;
42+
my $header = 0;
43+
44+
sub help {
45+
my $text = << "EOM";
46+
Usage:
47+
1) dmesg | perl scripts/bootgraph.pl [OPTION] > output.svg
48+
2) perl scripts/bootgraph.pl -h
49+
50+
Options:
51+
-header Insert kernel version and date
52+
EOM
53+
my $std=shift;
54+
if ($std == 1) {
55+
print STDERR $text;
56+
} else {
57+
print $text;
58+
}
59+
exit;
60+
}
61+
62+
GetOptions(
63+
'h|help' =>\&help,
64+
'header' =>\$header
65+
);
4166

4267
my %start;
4368
my %end;
@@ -49,6 +74,11 @@
4974
my %pids;
5075
my %pidctr;
5176

77+
my $headerstep = 20;
78+
my $xheader = 15;
79+
my $yheader = 25;
80+
my $cyheader = 0;
81+
5282
while (<>) {
5383
my $line = $_;
5484
if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_\.]+)\+/) {
@@ -112,15 +142,23 @@
112142
print STDERR <<END;
113143
No data found in the dmesg. Make sure that 'printk.time=1' and
114144
'initcall_debug' are passed on the kernel command line.
115-
Usage:
116-
dmesg | perl scripts/bootgraph.pl > output.svg
117145
END
146+
help(1);
118147
exit 1;
119148
}
120149

121150
print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
122151
print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
123152

153+
154+
if ($header) {
155+
my $version = `uname -a`;
156+
my $date = `date`;
157+
print "<text transform=\"translate($xheader,$yheader)\">Kernel version: $version</text>\n";
158+
$cyheader = $yheader+$headerstep;
159+
print "<text transform=\"translate($xheader,$cyheader)\">Date: $date</text>\n";
160+
}
161+
124162
my @styles;
125163

126164
$styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";

scripts/coccinelle/api/ptr_ret.cocci

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// URL: http://coccinelle.lip6.fr/
88
// Options: --no-includes --include-headers
99
//
10-
// Keywords: ERR_PTR, PTR_ERR, PTR_RET, PTR_ERR_OR_ZERO
10+
// Keywords: ERR_PTR, PTR_ERR, PTR_ERR_OR_ZERO
1111
// Version min: 2.6.39
1212
//
1313

@@ -62,35 +62,35 @@ position p3;
6262
p << r1.p1;
6363
@@
6464
65-
coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
65+
coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
6666
6767
6868
@script:python depends on org@
6969
p << r2.p2;
7070
@@
7171
72-
coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
72+
coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
7373
7474
@script:python depends on org@
7575
p << r3.p3;
7676
@@
7777
78-
coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
78+
coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
7979
8080
@script:python depends on report@
8181
p << r1.p1;
8282
@@
8383
84-
coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
84+
coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
8585
8686
@script:python depends on report@
8787
p << r2.p2;
8888
@@
8989
90-
coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
90+
coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
9191
9292
@script:python depends on report@
9393
p << r3.p3;
9494
@@
9595
96-
coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
96+
coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")

scripts/coccinelle/misc/memcpy-assign.cocci

Lines changed: 0 additions & 103 deletions
This file was deleted.

scripts/objdiff

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#!/bin/bash
2+
3+
# objdiff - a small script for validating that a commit or series of commits
4+
# didn't change object code.
5+
#
6+
# Copyright 2014, Jason Cooper <[email protected]>
7+
#
8+
# Licensed under the terms of the GNU GPL version 2
9+
10+
# usage example:
11+
#
12+
# $ git checkout COMMIT_A
13+
# $ <your fancy build command here>
14+
# $ ./scripts/objdiff record path/to/*.o
15+
#
16+
# $ git checkout COMMIT_B
17+
# $ <your fancy build command here>
18+
# $ ./scripts/objdiff record path/to/*.o
19+
#
20+
# $ ./scripts/objdiff diff COMMIT_A COMMIT_B
21+
# $
22+
23+
# And to clean up (everything is in .tmp_objdiff/*)
24+
# $ ./scripts/objdiff clean all
25+
#
26+
# Note: 'make mrproper' will also remove .tmp_objdiff
27+
28+
GIT_DIR="`git rev-parse --git-dir`"
29+
30+
if [ -d "$GIT_DIR" ]; then
31+
TMPD="${GIT_DIR%git}tmp_objdiff"
32+
33+
[ -d "$TMPD" ] || mkdir "$TMPD"
34+
else
35+
echo "ERROR: git directory not found."
36+
exit 1
37+
fi
38+
39+
usage() {
40+
echo "Usage: $0 <command> <args>"
41+
echo " record <list of object files>"
42+
echo " diff <commitA> <commitB>"
43+
echo " clean all | <commit>"
44+
exit 1
45+
}
46+
47+
dorecord() {
48+
[ $# -eq 0 ] && usage
49+
50+
FILES="$*"
51+
52+
CMT="`git rev-parse --short HEAD`"
53+
54+
OBJDUMP="${CROSS_COMPILE}objdump"
55+
OBJDIFFD="$TMPD/$CMT"
56+
57+
[ ! -d "$OBJDIFFD" ] && mkdir -p "$OBJDIFFD"
58+
59+
for f in $FILES; do
60+
dn="${f%/*}"
61+
bn="${f##*/}"
62+
63+
[ ! -d "$OBJDIFFD/$dn" ] && mkdir -p "$OBJDIFFD/$dn"
64+
65+
# remove addresses for a more clear diff
66+
# http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and
67+
$OBJDUMP -D "$f" | sed "s/^[[:space:]]\+[0-9a-f]\+//" \
68+
>"$OBJDIFFD/$dn/$bn"
69+
done
70+
}
71+
72+
dodiff() {
73+
[ $# -ne 2 ] && [ $# -ne 0 ] && usage
74+
75+
if [ $# -eq 0 ]; then
76+
SRC="`git rev-parse --short HEAD^`"
77+
DST="`git rev-parse --short HEAD`"
78+
else
79+
SRC="`git rev-parse --short $1`"
80+
DST="`git rev-parse --short $2`"
81+
fi
82+
83+
DIFF="`which colordiff`"
84+
85+
if [ ${#DIFF} -eq 0 ] || [ ! -x "$DIFF" ]; then
86+
DIFF="`which diff`"
87+
fi
88+
89+
SRCD="$TMPD/$SRC"
90+
DSTD="$TMPD/$DST"
91+
92+
if [ ! -d "$SRCD" ]; then
93+
echo "ERROR: $SRCD doesn't exist"
94+
exit 1
95+
fi
96+
97+
if [ ! -d "$DSTD" ]; then
98+
echo "ERROR: $DSTD doesn't exist"
99+
exit 1
100+
fi
101+
102+
$DIFF -Nurd $SRCD $DSTD
103+
}
104+
105+
doclean() {
106+
[ $# -eq 0 ] && usage
107+
[ $# -gt 1 ] && usage
108+
109+
if [ "x$1" = "xall" ]; then
110+
rm -rf $TMPD/*
111+
else
112+
CMT="`git rev-parse --short $1`"
113+
114+
if [ -d "$TMPD/$CMT" ]; then
115+
rm -rf $TMPD/$CMT
116+
else
117+
echo "$CMT not found"
118+
fi
119+
fi
120+
}
121+
122+
[ $# -eq 0 ] && usage
123+
124+
case "$1" in
125+
record)
126+
shift
127+
dorecord $*
128+
;;
129+
diff)
130+
shift
131+
dodiff $*
132+
;;
133+
clean)
134+
shift
135+
doclean $*
136+
;;
137+
*)
138+
echo "Unrecognized command '$1'"
139+
exit 1
140+
;;
141+
esac

0 commit comments

Comments
 (0)