aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build12
-rw-r--r--scripts/bootgraph.pl42
-rw-r--r--scripts/coccinelle/api/ptr_ret.cocci14
-rw-r--r--scripts/coccinelle/misc/memcpy-assign.cocci103
-rwxr-xr-xscripts/mkcompile_h2
-rwxr-xr-xscripts/objdiff141
-rwxr-xr-xscripts/tags.sh9
7 files changed, 204 insertions, 119 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 9f0ee22b914f..003bc263105a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -65,12 +65,22 @@ warning- := $(empty)
65warning-1 := -Wextra -Wunused -Wno-unused-parameter 65warning-1 := -Wextra -Wunused -Wno-unused-parameter
66warning-1 += -Wmissing-declarations 66warning-1 += -Wmissing-declarations
67warning-1 += -Wmissing-format-attribute 67warning-1 += -Wmissing-format-attribute
68warning-1 += -Wmissing-prototypes 68warning-1 += $(call cc-option, -Wmissing-prototypes)
69warning-1 += -Wold-style-definition 69warning-1 += -Wold-style-definition
70warning-1 += $(call cc-option, -Wmissing-include-dirs) 70warning-1 += $(call cc-option, -Wmissing-include-dirs)
71warning-1 += $(call cc-option, -Wunused-but-set-variable) 71warning-1 += $(call cc-option, -Wunused-but-set-variable)
72warning-1 += $(call cc-disable-warning, missing-field-initializers) 72warning-1 += $(call cc-disable-warning, missing-field-initializers)
73 73
74# Clang
75warning-1 += $(call cc-disable-warning, initializer-overrides)
76warning-1 += $(call cc-disable-warning, unused-value)
77warning-1 += $(call cc-disable-warning, format)
78warning-1 += $(call cc-disable-warning, unknown-warning-option)
79warning-1 += $(call cc-disable-warning, sign-compare)
80warning-1 += $(call cc-disable-warning, format-zero-length)
81warning-1 += $(call cc-disable-warning, uninitialized)
82warning-1 += $(call cc-option, -fcatch-undefined-behavior)
83
74warning-2 := -Waggregate-return 84warning-2 := -Waggregate-return
75warning-2 += -Wcast-align 85warning-2 += -Wcast-align
76warning-2 += -Wdisabled-optimization 86warning-2 += -Wdisabled-optimization
diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl
index b78fca994a15..9ca667bcaee9 100644
--- a/scripts/bootgraph.pl
+++ b/scripts/bootgraph.pl
@@ -38,6 +38,31 @@
38# 38#
39 39
40use strict; 40use strict;
41use Getopt::Long;
42my $header = 0;
43
44sub help {
45 my $text = << "EOM";
46Usage:
471) dmesg | perl scripts/bootgraph.pl [OPTION] > output.svg
482) perl scripts/bootgraph.pl -h
49
50Options:
51 -header Insert kernel version and date
52EOM
53 my $std=shift;
54 if ($std == 1) {
55 print STDERR $text;
56 } else {
57 print $text;
58 }
59 exit;
60}
61
62GetOptions(
63 'h|help' =>\&help,
64 'header' =>\$header
65);
41 66
42my %start; 67my %start;
43my %end; 68my %end;
@@ -49,6 +74,11 @@ my $count = 0;
49my %pids; 74my %pids;
50my %pidctr; 75my %pidctr;
51 76
77my $headerstep = 20;
78my $xheader = 15;
79my $yheader = 25;
80my $cyheader = 0;
81
52while (<>) { 82while (<>) {
53 my $line = $_; 83 my $line = $_;
54 if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_\.]+)\+/) { 84 if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_\.]+)\+/) {
@@ -112,15 +142,23 @@ if ($count == 0) {
112 print STDERR <<END; 142 print STDERR <<END;
113No data found in the dmesg. Make sure that 'printk.time=1' and 143No data found in the dmesg. Make sure that 'printk.time=1' and
114'initcall_debug' are passed on the kernel command line. 144'initcall_debug' are passed on the kernel command line.
115Usage:
116 dmesg | perl scripts/bootgraph.pl > output.svg
117END 145END
146 help(1);
118 exit 1; 147 exit 1;
119} 148}
120 149
121print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; 150print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
122print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; 151print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
123 152
153
154if ($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
124my @styles; 162my @styles;
125 163
126$styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; 164$styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
index e18f8402e37c..dd58dab5d411 100644
--- a/scripts/coccinelle/api/ptr_ret.cocci
+++ b/scripts/coccinelle/api/ptr_ret.cocci
@@ -7,7 +7,7 @@
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Options: --no-includes --include-headers 8// Options: --no-includes --include-headers
9// 9//
10// Keywords: ERR_PTR, PTR_ERR, PTR_RET, PTR_ERR_OR_ZERO 10// Keywords: ERR_PTR, PTR_ERR, PTR_ERR_OR_ZERO
11// Version min: 2.6.39 11// Version min: 2.6.39
12// 12//
13 13
@@ -62,35 +62,35 @@ position p3;
62p << r1.p1; 62p << r1.p1;
63@@ 63@@
64 64
65coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") 65coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
66 66
67 67
68@script:python depends on org@ 68@script:python depends on org@
69p << r2.p2; 69p << r2.p2;
70@@ 70@@
71 71
72coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") 72coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
73 73
74@script:python depends on org@ 74@script:python depends on org@
75p << r3.p3; 75p << r3.p3;
76@@ 76@@
77 77
78coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") 78coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
79 79
80@script:python depends on report@ 80@script:python depends on report@
81p << r1.p1; 81p << r1.p1;
82@@ 82@@
83 83
84coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") 84coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
85 85
86@script:python depends on report@ 86@script:python depends on report@
87p << r2.p2; 87p << r2.p2;
88@@ 88@@
89 89
90coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") 90coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
91 91
92@script:python depends on report@ 92@script:python depends on report@
93p << r3.p3; 93p << r3.p3;
94@@ 94@@
95 95
96coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") 96coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
diff --git a/scripts/coccinelle/misc/memcpy-assign.cocci b/scripts/coccinelle/misc/memcpy-assign.cocci
deleted file mode 100644
index afd058be497f..000000000000
--- a/scripts/coccinelle/misc/memcpy-assign.cocci
+++ /dev/null
@@ -1,103 +0,0 @@
1//
2// Replace memcpy with struct assignment.
3//
4// Confidence: High
5// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2.
6// URL: http://coccinelle.lip6.fr/
7// Comments:
8// Options: --no-includes --include-headers
9
10virtual patch
11virtual report
12virtual context
13virtual org
14
15@r1 depends on !patch@
16identifier struct_name;
17struct struct_name to;
18struct struct_name from;
19struct struct_name *top;
20struct struct_name *fromp;
21position p;
22@@
23memcpy@p(\(&(to)\|top\), \(&(from)\|fromp\), \(sizeof(to)\|sizeof(from)\|sizeof(struct struct_name)\|sizeof(*top)\|sizeof(*fromp)\))
24
25@script:python depends on report@
26p << r1.p;
27@@
28coccilib.report.print_report(p[0],"Replace memcpy with struct assignment")
29
30@depends on context@
31position r1.p;
32@@
33*memcpy@p(...);
34
35@script:python depends on org@
36p << r1.p;
37@@
38cocci.print_main("Replace memcpy with struct assignment",p)
39
40@depends on patch@
41identifier struct_name;
42struct struct_name to;
43struct struct_name from;
44@@
45(
46-memcpy(&(to), &(from), sizeof(to));
47+to = from;
48|
49-memcpy(&(to), &(from), sizeof(from));
50+to = from;
51|
52-memcpy(&(to), &(from), sizeof(struct struct_name));
53+to = from;
54)
55
56@depends on patch@
57identifier struct_name;
58struct struct_name to;
59struct struct_name *from;
60@@
61(
62-memcpy(&(to), from, sizeof(to));
63+to = *from;
64|
65-memcpy(&(to), from, sizeof(*from));
66+to = *from;
67|
68-memcpy(&(to), from, sizeof(struct struct_name));
69+to = *from;
70)
71
72@depends on patch@
73identifier struct_name;
74struct struct_name *to;
75struct struct_name from;
76@@
77(
78-memcpy(to, &(from), sizeof(*to));
79+ *to = from;
80|
81-memcpy(to, &(from), sizeof(from));
82+ *to = from;
83|
84-memcpy(to, &(from), sizeof(struct struct_name));
85+ *to = from;
86)
87
88@depends on patch@
89identifier struct_name;
90struct struct_name *to;
91struct struct_name *from;
92@@
93(
94-memcpy(to, from, sizeof(*to));
95+ *to = *from;
96|
97-memcpy(to, from, sizeof(*from));
98+ *to = *from;
99|
100-memcpy(to, from, sizeof(struct struct_name));
101+ *to = *from;
102)
103
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index f221ddf69080..cfb8440cc0b2 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -76,7 +76,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
76 echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" 76 echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
77 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" 77 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
78 78
79 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" 79 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version '`\"
80) > .tmpcompile 80) > .tmpcompile
81 81
82# Only replace the real compile.h if the new one is different, 82# Only replace the real compile.h if the new one is different,
diff --git a/scripts/objdiff b/scripts/objdiff
new file mode 100755
index 000000000000..b3e4f10bfc3e
--- /dev/null
+++ b/scripts/objdiff
@@ -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 <jason@lakedaemon.net>
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
28GIT_DIR="`git rev-parse --git-dir`"
29
30if [ -d "$GIT_DIR" ]; then
31 TMPD="${GIT_DIR%git}tmp_objdiff"
32
33 [ -d "$TMPD" ] || mkdir "$TMPD"
34else
35 echo "ERROR: git directory not found."
36 exit 1
37fi
38
39usage() {
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
47dorecord() {
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
72dodiff() {
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
105doclean() {
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
124case "$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 ;;
141esac
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 58c455929091..f2c5b006a3d7 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -11,11 +11,10 @@ if [ "$KBUILD_VERBOSE" = "1" ]; then
11 set -x 11 set -x
12fi 12fi
13 13
14# This is a duplicate of RCS_FIND_IGNORE without escaped '()' 14# RCS_FIND_IGNORE has escaped ()s -- remove them.
15ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \ 15ignore="$(echo "$RCS_FIND_IGNORE" | sed 's|\\||g' )"
16 -name CVS -o -name .pc -o -name .hg -o \ 16# tags and cscope files should also ignore MODVERSION *.mod.c files
17 -name .git ) \ 17ignore="$ignore ( -name *.mod.c ) -prune -o"
18 -prune -o"
19 18
20# Do not use full path if we do not use O=.. builds 19# Do not use full path if we do not use O=.. builds
21# Use make O=. {tags|cscope} 20# Use make O=. {tags|cscope}