From 4edc7e32affd40ceb06ba58ff55e4664396b24c7 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Fri, 8 Jun 2012 01:48:55 +0200 Subject: scripts/config: add option to not upper-case symbols Currently, scripts/config mangles the config option symbols to always be upper-case. While the Linux kernel almost exclusively uses upper-case symbols, there are still a few symbols with lower-case which this script can not handle: $ grep -r -E '^[[:space:]]*config[[:space:]]+[^[:space:]]*[[:lower:]][^[:space:]=.]*$' . |wc -l 173 (that's roughly 1.3% of the symbols in 3.5-rc1) Eg.: ./arch/arm/Kconfig:config VFPv3 ./arch/powerpc/platforms/Kconfig.cputype:config 40x ./arch/x86/Kconfig:config SCx200HR_TIMER ./drivers/video/console/Kconfig:config FONT_8x8 ./drivers/video/Kconfig:config NTSC_640x480 Also, other projects that use kconfig may allow for lower- or mixed-case symbols, and may find easier to reuse this script than implement each their own (potentially flawed) logic. For such a use-case, see: http://marc.info/?l=linux-kbuild&m=133409932115848&w=2 This patch adds a new option to keep the given case, and keep the current default to upper-case the symbols. Signed-off-by: "Yann E. MORIN" Signed-off-by: Michal Marek --- scripts/config | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/config b/scripts/config index ed6653ef9702..c5639fe5bba8 100755 --- a/scripts/config +++ b/scripts/config @@ -26,10 +26,14 @@ commands: commands can be repeated multiple times options: - --file .config file to change (default .config) + --file config-file .config file to change (default .config) + --keep-case|-k Keep next symbols' case (dont' upper-case it) config doesn't check the validity of the .config file. This is done at next - make time. +make time. + +By default, config will upper-case the given symbol. Use --keep-case to keep +the case of all following symbols unchanged. EOL exit 1 } @@ -44,7 +48,9 @@ checkarg() { ARG="${ARG/CONFIG_/}" ;; esac - ARG="`echo $ARG | tr a-z A-Z`" + if [ "$MUNGE_CASE" = "yes" ] ; then + ARG="`echo $ARG | tr a-z A-Z`" + fi } set_var() { @@ -75,10 +81,16 @@ if [ "$1" = "" ] ; then usage fi +MUNGE_CASE=yes while [ "$1" != "" ] ; do CMD="$1" shift case "$CMD" in + --keep-case|-k) + MUNGE_CASE=no + shift + continue + ;; --refresh) ;; --*-after) -- cgit v1.2.3 From f5ef2f7bf2e389f5c94d69e09268356f4c2b8220 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Fri, 8 Jun 2012 01:48:56 +0200 Subject: scripts/config: allow alternate prefix to config option symbol While the Linux kernel uses 'CONFIG_' as a prefix to the config options symbols, many projects that use kconfig may use different prefixes, or even none at all. If the CONFIG_ environment variable is set, use it as the prefix (empty is a valid prefix). Otherwise, use the default prefix 'CONFIG_'. This matches the support for alternate prefixes in scripts/kconfig/lkc.h, which uses the same logic (albeit with a C define instead of an environment variable). Signed-off-by: "Yann E. MORIN" Signed-off-by: Michal Marek --- scripts/config | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/config b/scripts/config index c5639fe5bba8..9723c7de07cc 100755 --- a/scripts/config +++ b/scripts/config @@ -1,6 +1,9 @@ #!/bin/bash # Manipulate options in a .config file from the command line +# If no prefix forced, use the default CONFIG_ +CONFIG_="${CONFIG_-CONFIG_}" + usage() { cat >&2 < Date: Fri, 8 Jun 2012 01:48:57 +0200 Subject: scripts/config: add option to undef a symbol It is currently possible to enable, disable or modularise a symbol. Also, an undefined symbol is reported as such. Add a new command to undefine a symbol, by removing the corresponding line from the .config file. Signed-off-by: "Yann E. MORIN" Signed-off-by: Michal Marek --- scripts/config | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'scripts') diff --git a/scripts/config b/scripts/config index 9723c7de07cc..f65a44a7886a 100755 --- a/scripts/config +++ b/scripts/config @@ -17,6 +17,7 @@ commands: Set option to "string" --set-val option value Set option to value + --undefine|-u option Undefine option --state|-s option Print state of option (n,y,m,undef) --enable-after|-E beforeopt option @@ -73,6 +74,12 @@ set_var() { fi } +undef_var() { + local name=$1 + + sed -ri "/^($name=|# $name is not set)/d" "$FN" +} + if [ "$1" = "--file" ]; then FN="$2" if [ "$FN" = "" ] ; then @@ -134,6 +141,9 @@ while [ "$1" != "" ] ; do set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1" shift ;; + --undefine|-u) + undef_var "${CONFIG_}$ARG" + ;; --state|-s) if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then -- cgit v1.2.3 From 6607ddadf93d19c7f64139f1475c342152f39fe5 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Fri, 8 Jun 2012 00:21:15 +0200 Subject: deb-pkg: Install linux-firmware-image in versioned dir That way they don't file conflict with official firmware package: trying to overwrite '/lib/firmware/qlogic/1040.bin', which is also in package firmware-qlogic 0.35 .. Reported-by: Michael Prokop Signed-off-by: maximilian attems Signed-off-by: Michal Marek --- scripts/package/builddeb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/package/builddeb b/scripts/package/builddeb index c95fdda58414..6505ecd3050e 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -92,7 +92,7 @@ rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" mkdir -m 755 -p "$tmpdir/DEBIAN" mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" mkdir -m 755 -p "$fwdir/DEBIAN" -mkdir -p "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename" +mkdir -p "$fwdir/lib/firmware/$version/" "$fwdir/usr/share/doc/$fwpackagename" mkdir -m 755 -p "$libc_headers_dir/DEBIAN" mkdir -p "$libc_headers_dir/usr/share/doc/$libc_headers_packagename" mkdir -m 755 -p "$kernel_headers_dir/DEBIAN" @@ -267,7 +267,8 @@ EOF # Do we have firmware? Move it out of the way and build it into a package. if [ -e "$tmpdir/lib/firmware" ]; then - mv "$tmpdir/lib/firmware" "$fwdir/lib/" + mv "$tmpdir/lib/firmware"/* "$fwdir/lib/firmware/$version/" + rmdir "$tmpdir/lib/firmware" cat <> debian/control -- cgit v1.2.3 From 5f011d715984543f47ca5bf1967857a9f36f7264 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Fri, 8 Jun 2012 11:36:26 +0200 Subject: deb-pkg: Add all Makefiles to header package I discovered that make deb-pkg does not add Makefile_32.cpu from arch/x86 directory when doing i386 kernel build and package build. Fix it by greedily adding all Makefiles. Reported-by: Witold Baryluk Signed-off-by: maximilian attems Signed-off-by: Michal Marek --- scripts/package/builddeb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 6505ecd3050e..acb86507828a 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -243,7 +243,7 @@ EOF fi # Build header package -(cd $srctree; find . -name Makefile -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles") +(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles") (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles") (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") destdir=$kernel_headers_dir/usr/src/linux-headers-$version -- cgit v1.2.3 From f1f455047940e59b3aea102e17ae4c0f9286aa76 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 1 Jul 2012 13:17:07 +0200 Subject: scripts/coccinelle: Find threaded IRQs requests which are missing IRQF_ONESHOT Since commit 1c6c69525b ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail. This semantic patch will help to statically identify (and fix) such cases. Signed-off-by: Lars-Peter Clausen Signed-off-by: Julia Lawall Signed-off-by: Michal Marek --- scripts/coccinelle/misc/irqf_oneshot.cocci | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 scripts/coccinelle/misc/irqf_oneshot.cocci (limited to 'scripts') diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci b/scripts/coccinelle/misc/irqf_oneshot.cocci new file mode 100644 index 000000000000..6cfde94be0ef --- /dev/null +++ b/scripts/coccinelle/misc/irqf_oneshot.cocci @@ -0,0 +1,65 @@ +/// Make sure threaded IRQs without a primary handler are always request with +/// IRQF_ONESHOT +/// +// +// Confidence: Good +// Comments: +// Options: --no-includes + +virtual patch +virtual context +virtual org +virtual report + +@r1@ +expression irq; +expression thread_fn; +expression flags; +position p; +@@ +request_threaded_irq@p(irq, NULL, thread_fn, +( +flags | IRQF_ONESHOT +| +IRQF_ONESHOT +) +, ...) + +@depends on patch@ +expression irq; +expression thread_fn; +expression flags; +position p != r1.p; +@@ +request_threaded_irq@p(irq, NULL, thread_fn, +( +-0 ++IRQF_ONESHOT +| +-flags ++flags | IRQF_ONESHOT +) +, ...) + +@depends on context@ +position p != r1.p; +@@ +*request_threaded_irq@p(...) + +@match depends on report || org@ +expression irq; +position p != r1.p; +@@ +request_threaded_irq@p(irq, NULL, ...) + +@script:python depends on org@ +p << match.p; +@@ +msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT" +coccilib.org.print_todo(p[0],msg) + +@script:python depends on report@ +p << match.p; +@@ +msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT" +coccilib.report.print_report(p[0],msg) -- cgit v1.2.3 From 6fcd5f2c006496fbbb43175f2f6775f2d38bf459 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 9 Jul 2012 22:40:51 +0200 Subject: scripts/coccinelle: list iterator variable semantic patch If list_for_each_entry, etc complete a traversal of the list, the iterator variable ends up pointing to an address at an offset from the list head, and not a meaningful structure. Thus this value should not be used after the end of the iterator. Signed-off-by: Julia Lawall Signed-off-by: Michal Marek --- scripts/coccinelle/iterators/use_after_iter.cocci | 147 ++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 scripts/coccinelle/iterators/use_after_iter.cocci (limited to 'scripts') diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/coccinelle/iterators/use_after_iter.cocci new file mode 100644 index 000000000000..06284c57a951 --- /dev/null +++ b/scripts/coccinelle/iterators/use_after_iter.cocci @@ -0,0 +1,147 @@ +/// If list_for_each_entry, etc complete a traversal of the list, the iterator +/// variable ends up pointing to an address at an offset from the list head, +/// and not a meaningful structure. Thus this value should not be used after +/// the end of the iterator. +//#False positives arise when there is a goto in the iterator and the +//#reported reference is at the label of this goto. Some flag tests +//#may also cause a report to be a false positive. +/// +// Confidence: Moderate +// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. +// Copyright: (C) 2012 Gilles Muller, INRIA/LIP6. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: -no_includes -include_headers + +virtual context +virtual org +virtual report + +@r exists@ +identifier c,member; +expression E,x; +iterator name list_for_each_entry; +iterator name list_for_each_entry_reverse; +iterator name list_for_each_entry_continue; +iterator name list_for_each_entry_continue_reverse; +iterator name list_for_each_entry_from; +iterator name list_for_each_entry_safe; +iterator name list_for_each_entry_safe_continue; +iterator name list_for_each_entry_safe_from; +iterator name list_for_each_entry_safe_reverse; +iterator name hlist_for_each_entry; +iterator name hlist_for_each_entry_continue; +iterator name hlist_for_each_entry_from; +iterator name hlist_for_each_entry_safe; +statement S; +position p1,p2; +@@ + +( +list_for_each_entry@p1(c,...,member) { ... when != break; + when forall + when strict +} +| +list_for_each_entry_reverse@p1(c,...,member) { ... when != break; + when forall + when strict +} +| +list_for_each_entry_continue@p1(c,...,member) { ... when != break; + when forall + when strict +} +| +list_for_each_entry_continue_reverse@p1(c,...,member) { ... when != break; + when forall + when strict +} +| +list_for_each_entry_from@p1(c,...,member) { ... when != break; + when forall + when strict +} +| +list_for_each_entry_safe@p1(c,...,member) { ... when != break; + when forall + when strict +} +| +list_for_each_entry_safe_continue@p1(c,...,member) { ... when != break; + when forall + when strict +} +| +list_for_each_entry_safe_from@p1(c,...,member) { ... when != break; + when forall + when strict +} +| +list_for_each_entry_safe_reverse@p1(c,...,member) { ... when != break; + when forall + when strict +} +) +... +( +list_for_each_entry(c,...) S +| +list_for_each_entry_reverse(c,...) S +| +list_for_each_entry_continue(c,...) S +| +list_for_each_entry_continue_reverse(c,...) S +| +list_for_each_entry_from(c,...) S +| +list_for_each_entry_safe(c,...) S +| +list_for_each_entry_safe(x,c,...) S +| +list_for_each_entry_safe_continue(c,...) S +| +list_for_each_entry_safe_continue(x,c,...) S +| +list_for_each_entry_safe_from(c,...) S +| +list_for_each_entry_safe_from(x,c,...) S +| +list_for_each_entry_safe_reverse(c,...) S +| +list_for_each_entry_safe_reverse(x,c,...) S +| +hlist_for_each_entry(c,...) S +| +hlist_for_each_entry_continue(c,...) S +| +hlist_for_each_entry_from(c,...) S +| +hlist_for_each_entry_safe(c,...) S +| +list_remove_head(x,c,...) +| +sizeof(<+...c...+>) +| +&c->member +| +c = E +| +*c@p2 +) + +@script:python depends on org@ +p1 << r.p1; +p2 << r.p2; +@@ + +cocci.print_main("invalid iterator index reference",p2) +cocci.print_secs("iterator",p1) + +@script:python depends on report@ +p1 << r.p1; +p2 << r.p2; +@@ + +msg = "ERROR: invalid reference to the index variable of the iterator on line %s" % (p1[0].line) +coccilib.report.print_report(p2[0], msg) -- cgit v1.2.3 From 1fa850596dcbc1b147948c832eb770d96c78024e Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Mon, 18 Jun 2012 11:50:51 +0900 Subject: scripts/tags.sh: Teach [ce]tags about libtraceeevent error codes As we use a macro trick to sync each error codes with its description string, teach [ce]tags to process them properly. Suggested-by: Steven Rostedt Cc: Frederic Weisbecker Link: http://lkml.kernel.org/n/tip-qt5fv4pzigr2nnl27ydimg4h@git.kernel.org Signed-off-by: Namhyung Kim Acked-by: Steven Rostedt Signed-off-by: Michal Marek --- scripts/tags.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/tags.sh b/scripts/tags.sh index cf7b12fee573..cff8faad73d1 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -153,7 +153,8 @@ exuberant() --regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ --regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ - --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' + --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ + --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \ @@ -195,7 +196,8 @@ emacs() --regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ --regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ --regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ - --regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' + --regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ + --regex='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' -- cgit v1.2.3