diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.build | 4 | ||||
-rw-r--r-- | scripts/Makefile.lib | 2 | ||||
-rwxr-xr-x | scripts/bloat-o-meter | 7 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 24 | ||||
-rwxr-xr-x | scripts/coccicheck | 15 | ||||
-rw-r--r-- | scripts/coccinelle/api/setup_timer.cocci | 277 | ||||
-rwxr-xr-x | scripts/faddr2line | 21 | ||||
-rw-r--r-- | scripts/kconfig/symbol.c | 2 | ||||
-rwxr-xr-x | scripts/kernel-doc | 2 | ||||
-rw-r--r-- | scripts/package/Makefile | 7 |
10 files changed, 37 insertions, 324 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 65ea1e6aaaf6..cb8997ed0149 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -76,7 +76,7 @@ lib-target := $(obj)/lib.a obj-y += $(obj)/lib-ksyms.o endif -ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) +ifneq ($(strip $(obj-y) $(need-builtin)),) builtin-target := $(obj)/built-in.o endif @@ -566,7 +566,7 @@ targets := $(filter-out $(PHONY), $(targets)) PHONY += $(subdir-ym) $(subdir-ym): - $(Q)$(MAKE) $(build)=$@ + $(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1) # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 08eb40a7729f..1ca4dcd2d500 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -57,7 +57,7 @@ multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) subdir-obj-y := $(filter %/built-in.o, $(obj-y)) # Replace multi-part objects by their individual parts, look at local dir only -real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) +real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) # DTB diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index 6f099f915dcf..94b664817ad9 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter @@ -83,8 +83,11 @@ def print_result(symboltype, symbolformat, argc): for d, n in delta: if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)) - print("Total: Before=%d, After=%d, chg %+.2f%%" % \ - (otot, ntot, (ntot - otot)*100.0/otot)) + if otot: + percent = (ntot - otot) * 100.0 / otot + else: + percent = 0 + print("Total: Before=%d, After=%d, chg %+.2f%%" % (otot, ntot, percent)) if sys.argv[1] == "-c": print_result("Function", "tT", 3) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 95cda3ecc66b..31031f10fe56 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5753,7 +5753,7 @@ sub process { for (my $count = $linenr; $count <= $lc; $count++) { my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0)); $fmt =~ s/%%//g; - if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGNO]).)/) { + if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGNOx]).)/) { $bad_extension = $1; last; } @@ -6233,28 +6233,6 @@ sub process { } } -# whine about ACCESS_ONCE - if ($^V && $^V ge 5.10.0 && - $line =~ /\bACCESS_ONCE\s*$balanced_parens\s*(=(?!=))?\s*($FuncArg)?/) { - my $par = $1; - my $eq = $2; - my $fun = $3; - $par =~ s/^\(\s*(.*)\s*\)$/$1/; - if (defined($eq)) { - if (WARN("PREFER_WRITE_ONCE", - "Prefer WRITE_ONCE(<FOO>, <BAR>) over ACCESS_ONCE(<FOO>) = <BAR>\n" . $herecurr) && - $fix) { - $fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)\s*$eq\s*\Q$fun\E/WRITE_ONCE($par, $fun)/; - } - } else { - if (WARN("PREFER_READ_ONCE", - "Prefer READ_ONCE(<FOO>) over ACCESS_ONCE(<FOO>)\n" . $herecurr) && - $fix) { - $fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)/READ_ONCE($par)/; - } - } - } - # check for mutex_trylock_recursive usage if ($line =~ /mutex_trylock_recursive/) { ERROR("LOCKING", diff --git a/scripts/coccicheck b/scripts/coccicheck index d5f28d5044e7..ecfac64b39fe 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -30,12 +30,6 @@ else VERBOSE=0 fi -if [ -z "$J" ]; then - NPROC=$(getconf _NPROCESSORS_ONLN) -else - NPROC="$J" -fi - FLAGS="--very-quiet" # You can use SPFLAGS to append extra arguments to coccicheck or override any @@ -70,6 +64,9 @@ if [ "$C" = "1" -o "$C" = "2" ]; then # Take only the last argument, which is the C file to test shift $(( $# - 1 )) OPTIONS="$COCCIINCLUDE $1" + + # No need to parallelize Coccinelle since this mode takes one input file. + NPROC=1 else ONLINE=0 if [ "$KBUILD_EXTMOD" = "" ] ; then @@ -77,6 +74,12 @@ else else OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE" fi + + if [ -z "$J" ]; then + NPROC=$(getconf _NPROCESSORS_ONLN) + else + NPROC="$J" + fi fi if [ "$KBUILD_EXTMOD" != "" ] ; then diff --git a/scripts/coccinelle/api/setup_timer.cocci b/scripts/coccinelle/api/setup_timer.cocci deleted file mode 100644 index e4577089dcb9..000000000000 --- a/scripts/coccinelle/api/setup_timer.cocci +++ /dev/null @@ -1,277 +0,0 @@ -/// Use setup_timer function instead of initializing timer with the function -/// and data fields -// Confidence: High -// Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2 -// Copyright: (C) 2017 Kees Cook, Google. GPLv2 -// Options: --no-includes --include-headers -// Keywords: init_timer, setup_timer - -virtual patch -virtual context -virtual org -virtual report - -// Match the common cases first to avoid Coccinelle parsing loops with -// "... when" clauses. - -@match_immediate_function_data_after_init_timer -depends on patch && !context && !org && !report@ -expression e, func, da; -@@ - --init_timer -+setup_timer - ( \(&e\|e\) -+, func, da - ); -( --\(e.function\|e->function\) = func; --\(e.data\|e->data\) = da; -| --\(e.data\|e->data\) = da; --\(e.function\|e->function\) = func; -) - -@match_immediate_function_data_before_init_timer -depends on patch && !context && !org && !report@ -expression e, func, da; -@@ - -( --\(e.function\|e->function\) = func; --\(e.data\|e->data\) = da; -| --\(e.data\|e->data\) = da; --\(e.function\|e->function\) = func; -) --init_timer -+setup_timer - ( \(&e\|e\) -+, func, da - ); - -@match_function_and_data_after_init_timer -depends on patch && !context && !org && !report@ -expression e, e2, e3, e4, e5, func, da; -@@ - --init_timer -+setup_timer - ( \(&e\|e\) -+, func, da - ); - ... when != func = e2 - when != da = e3 -( --e.function = func; -... when != da = e4 --e.data = da; -| --e->function = func; -... when != da = e4 --e->data = da; -| --e.data = da; -... when != func = e5 --e.function = func; -| --e->data = da; -... when != func = e5 --e->function = func; -) - -@match_function_and_data_before_init_timer -depends on patch && !context && !org && !report@ -expression e, e2, e3, e4, e5, func, da; -@@ -( --e.function = func; -... when != da = e4 --e.data = da; -| --e->function = func; -... when != da = e4 --e->data = da; -| --e.data = da; -... when != func = e5 --e.function = func; -| --e->data = da; -... when != func = e5 --e->function = func; -) -... when != func = e2 - when != da = e3 --init_timer -+setup_timer - ( \(&e\|e\) -+, func, da - ); - -@r1 exists@ -expression t; -identifier f; -position p; -@@ - -f(...) { ... when any - init_timer@p(\(&t\|t\)) - ... when any -} - -@r2 exists@ -expression r1.t; -identifier g != r1.f; -expression e8; -@@ - -g(...) { ... when any - \(t.data\|t->data\) = e8 - ... when any -} - -// It is dangerous to use setup_timer if data field is initialized -// in another function. - -@script:python depends on r2@ -p << r1.p; -@@ - -cocci.include_match(False) - -@r3 depends on patch && !context && !org && !report@ -expression r1.t, func, e7; -position r1.p; -@@ - -( --init_timer@p(&t); -+setup_timer(&t, func, 0UL); -... when != func = e7 --t.function = func; -| --t.function = func; -... when != func = e7 --init_timer@p(&t); -+setup_timer(&t, func, 0UL); -| --init_timer@p(t); -+setup_timer(t, func, 0UL); -... when != func = e7 --t->function = func; -| --t->function = func; -... when != func = e7 --init_timer@p(t); -+setup_timer(t, func, 0UL); -) - -// ---------------------------------------------------------------------------- - -@match_immediate_function_data_after_init_timer_context -depends on !patch && (context || org || report)@ -expression da, e, func; -position j0, j1, j2; -@@ - -* init_timer@j0 (&e); -( -* e@j1.function = func; -* e@j2.data = da; -| -* e@j1.data = da; -* e@j2.function = func; -) - -@match_function_and_data_after_init_timer_context -depends on !patch && (context || org || report)@ -expression a, b, e1, e2, e3, e4, e5; -position j0 != match_immediate_function_data_after_init_timer_context.j0,j1,j2; -@@ - -* init_timer@j0 (&e1); -... when != a = e2 - when != b = e3 -( -* e1@j1.function = a; -... when != b = e4 -* e1@j2.data = b; -| -* e1@j1.data = b; -... when != a = e5 -* e1@j2.function = a; -) - -@r3_context depends on !patch && (context || org || report)@ -expression c, e6, e7; -position r1.p; -position j0 != - {match_immediate_function_data_after_init_timer_context.j0, - match_function_and_data_after_init_timer_context.j0}, j1; -@@ - -* init_timer@j0@p (&e6); -... when != c = e7 -* e6@j1.function = c; - -// ---------------------------------------------------------------------------- - -@script:python match_immediate_function_data_after_init_timer_org -depends on org@ -j0 << match_immediate_function_data_after_init_timer_context.j0; -j1 << match_immediate_function_data_after_init_timer_context.j1; -j2 << match_immediate_function_data_after_init_timer_context.j2; -@@ - -msg = "Use setup_timer function." -coccilib.org.print_todo(j0[0], msg) -coccilib.org.print_link(j1[0], "") -coccilib.org.print_link(j2[0], "") - -@script:python match_function_and_data_after_init_timer_org depends on org@ -j0 << match_function_and_data_after_init_timer_context.j0; -j1 << match_function_and_data_after_init_timer_context.j1; -j2 << match_function_and_data_after_init_timer_context.j2; -@@ - -msg = "Use setup_timer function." -coccilib.org.print_todo(j0[0], msg) -coccilib.org.print_link(j1[0], "") -coccilib.org.print_link(j2[0], "") - -@script:python r3_org depends on org@ -j0 << r3_context.j0; -j1 << r3_context.j1; -@@ - -msg = "Use setup_timer function." -coccilib.org.print_todo(j0[0], msg) -coccilib.org.print_link(j1[0], "") - -// ---------------------------------------------------------------------------- - -@script:python match_immediate_function_data_after_init_timer_report -depends on report@ -j0 << match_immediate_function_data_after_init_timer_context.j0; -j1 << match_immediate_function_data_after_init_timer_context.j1; -@@ - -msg = "Use setup_timer function for function on line %s." % (j1[0].line) -coccilib.report.print_report(j0[0], msg) - -@script:python match_function_and_data_after_init_timer_report depends on report@ -j0 << match_function_and_data_after_init_timer_context.j0; -j1 << match_function_and_data_after_init_timer_context.j1; -@@ - -msg = "Use setup_timer function for function on line %s." % (j1[0].line) -coccilib.report.print_report(j0[0], msg) - -@script:python r3_report depends on report@ -j0 << r3_context.j0; -j1 << r3_context.j1; -@@ - -msg = "Use setup_timer function for function on line %s." % (j1[0].line) -coccilib.report.print_report(j0[0], msg) diff --git a/scripts/faddr2line b/scripts/faddr2line index 1f5ce959f596..7721d5b2b0c0 100755 --- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -44,9 +44,16 @@ set -o errexit set -o nounset +READELF="${CROSS_COMPILE:-}readelf" +ADDR2LINE="${CROSS_COMPILE:-}addr2line" +SIZE="${CROSS_COMPILE:-}size" +NM="${CROSS_COMPILE:-}nm" + command -v awk >/dev/null 2>&1 || die "awk isn't installed" -command -v readelf >/dev/null 2>&1 || die "readelf isn't installed" -command -v addr2line >/dev/null 2>&1 || die "addr2line isn't installed" +command -v ${READELF} >/dev/null 2>&1 || die "readelf isn't installed" +command -v ${ADDR2LINE} >/dev/null 2>&1 || die "addr2line isn't installed" +command -v ${SIZE} >/dev/null 2>&1 || die "size isn't installed" +command -v ${NM} >/dev/null 2>&1 || die "nm isn't installed" usage() { echo "usage: faddr2line <object file> <func+offset> <func+offset>..." >&2 @@ -69,10 +76,10 @@ die() { find_dir_prefix() { local objfile=$1 - local start_kernel_addr=$(readelf -sW $objfile | awk '$8 == "start_kernel" {printf "0x%s", $2}') + local start_kernel_addr=$(${READELF} -sW $objfile | awk '$8 == "start_kernel" {printf "0x%s", $2}') [[ -z $start_kernel_addr ]] && return - local file_line=$(addr2line -e $objfile $start_kernel_addr) + local file_line=$(${ADDR2LINE} -e $objfile $start_kernel_addr) [[ -z $file_line ]] && return local prefix=${file_line%init/main.c:*} @@ -104,7 +111,7 @@ __faddr2line() { # Go through each of the object's symbols which match the func name. # In rare cases there might be duplicates. - file_end=$(size -Ax $objfile | awk '$1 == ".text" {print $2}') + file_end=$(${SIZE} -Ax $objfile | awk '$1 == ".text" {print $2}') while read symbol; do local fields=($symbol) local sym_base=0x${fields[0]} @@ -156,10 +163,10 @@ __faddr2line() { # pass real address to addr2line echo "$func+$offset/$sym_size:" - addr2line -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;" + ${ADDR2LINE} -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;" DONE=1 - done < <(nm -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }') + done < <(${NM} -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }') } [[ $# -lt 2 ]] && usage diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 20136ffefb23..3c8bd9bb4267 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1061,7 +1061,7 @@ struct symbol **sym_re_search(const char *pattern) } if (sym_match_arr) { qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp); - sym_arr = malloc((cnt+1) * sizeof(struct symbol)); + sym_arr = malloc((cnt+1) * sizeof(struct symbol *)); if (!sym_arr) goto sym_re_search_free; for (i = 0; i < cnt; i++) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index bd29a92b4b48..df0f045a9a89 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -3248,4 +3248,4 @@ if ($verbose && $warnings) { print STDERR "$warnings warnings\n"; } -exit($errors); +exit($output_mode eq "none" ? 0 : $errors); diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 9ed96aefc72d..c23534925b38 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -39,14 +39,13 @@ if test "$(objtree)" != "$(srctree)"; then \ false; \ fi ; \ $(srctree)/scripts/setlocalversion --save-scmversion; \ -ln -sf $(srctree) $(2); \ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \ - $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \ -rm -f $(2) $(objtree)/.scmversion + --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \ +rm -f $(objtree)/.scmversion # rpm-pkg # --------------------------------------------------------------------------- -rpm-pkg rpm: FORCE +rpm-pkg: FORCE $(MAKE) clean $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec $(call cmd,src_tar,$(KERNELPATH),kernel.spec) |