mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull misc non-critical kbuild changes from Michal Marek: - Fix for make TAGS - Fix for make rpm - Some new coccinelle semantic patches * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: scripts/coccinelle: find constant additions that could be bit ors coccicheck: Allow to show the executed command line coccicheck: Allow the user to give a V= (verbose) argument scripts/coccinelle/misc/memcpy-assign.cocci: Replace memcpy with struct assignment kbuild: clear KBUILD_SRC when calling 'make' in RPM spec scripts/coccinelle/misc/semicolon.cocci: Add unneeded semicolon test scripts/tags.sh: Fix regex syntax for etags
This commit is contained in:
commit
ad60a93330
@ -87,6 +87,10 @@ As any static code analyzer, Coccinelle produces false
|
||||
positives. Thus, reports must be carefully checked, and patches
|
||||
reviewed.
|
||||
|
||||
To enable verbose messages set the V= variable, for example:
|
||||
|
||||
make coccicheck MODE=report V=1
|
||||
|
||||
|
||||
Using Coccinelle with a single semantic patch
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -2,6 +2,15 @@
|
||||
|
||||
SPATCH="`which ${SPATCH:=spatch}`"
|
||||
|
||||
# The verbosity may be set by the environmental parameter V=
|
||||
# as for example with 'make V=1 coccicheck'
|
||||
|
||||
if [ -n "$V" -a "$V" != "0" ]; then
|
||||
VERBOSE=1
|
||||
else
|
||||
VERBOSE=0
|
||||
fi
|
||||
|
||||
if [ "$C" = "1" -o "$C" = "2" ]; then
|
||||
ONLINE=1
|
||||
|
||||
@ -46,6 +55,14 @@ if [ "$ONLINE" = "0" ] ; then
|
||||
echo ''
|
||||
fi
|
||||
|
||||
run_cmd() {
|
||||
if [ $VERBOSE -ne 0 ] ; then
|
||||
echo "Running: $@"
|
||||
fi
|
||||
eval $@
|
||||
}
|
||||
|
||||
|
||||
coccinelle () {
|
||||
COCCI="$1"
|
||||
|
||||
@ -55,7 +72,7 @@ coccinelle () {
|
||||
#
|
||||
# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
|
||||
|
||||
if [ "$ONLINE" = "0" ] ; then
|
||||
if [ $VERBOSE -ne 0 ] ; then
|
||||
|
||||
FILE=`echo $COCCI | sed "s|$srctree/||"`
|
||||
|
||||
@ -91,15 +108,21 @@ coccinelle () {
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "chain" ] ; then
|
||||
$SPATCH -D patch $FLAGS -sp_file $COCCI $OPT $OPTIONS || \
|
||||
$SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \
|
||||
$SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \
|
||||
$SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1
|
||||
run_cmd $SPATCH -D patch \
|
||||
$FLAGS -sp_file $COCCI $OPT $OPTIONS || \
|
||||
run_cmd $SPATCH -D report \
|
||||
$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \
|
||||
run_cmd $SPATCH -D context \
|
||||
$FLAGS -sp_file $COCCI $OPT $OPTIONS || \
|
||||
run_cmd $SPATCH -D org \
|
||||
$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1
|
||||
elif [ "$MODE" = "rep+ctxt" ] ; then
|
||||
$SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \
|
||||
$SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
|
||||
run_cmd $SPATCH -D report \
|
||||
$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \
|
||||
run_cmd $SPATCH -D context \
|
||||
$FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
|
||||
else
|
||||
$SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
|
||||
run_cmd $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
103
scripts/coccinelle/misc/memcpy-assign.cocci
Normal file
103
scripts/coccinelle/misc/memcpy-assign.cocci
Normal file
@ -0,0 +1,103 @@
|
||||
//
|
||||
// Replace memcpy with struct assignment.
|
||||
//
|
||||
// Confidence: High
|
||||
// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2.
|
||||
// URL: http://coccinelle.lip6.fr/
|
||||
// Comments:
|
||||
// Options: --no-includes --include-headers
|
||||
|
||||
virtual patch
|
||||
virtual report
|
||||
virtual context
|
||||
virtual org
|
||||
|
||||
@r1 depends on !patch@
|
||||
identifier struct_name;
|
||||
struct struct_name to;
|
||||
struct struct_name from;
|
||||
struct struct_name *top;
|
||||
struct struct_name *fromp;
|
||||
position p;
|
||||
@@
|
||||
memcpy@p(\(&(to)\|top\), \(&(from)\|fromp\), \(sizeof(to)\|sizeof(from)\|sizeof(struct struct_name)\|sizeof(*top)\|sizeof(*fromp)\))
|
||||
|
||||
@script:python depends on report@
|
||||
p << r1.p;
|
||||
@@
|
||||
coccilib.report.print_report(p[0],"Replace memcpy with struct assignment")
|
||||
|
||||
@depends on context@
|
||||
position r1.p;
|
||||
@@
|
||||
*memcpy@p(...);
|
||||
|
||||
@script:python depends on org@
|
||||
p << r1.p;
|
||||
@@
|
||||
cocci.print_main("Replace memcpy with struct assignment",p)
|
||||
|
||||
@depends on patch@
|
||||
identifier struct_name;
|
||||
struct struct_name to;
|
||||
struct struct_name from;
|
||||
@@
|
||||
(
|
||||
-memcpy(&(to), &(from), sizeof(to));
|
||||
+to = from;
|
||||
|
|
||||
-memcpy(&(to), &(from), sizeof(from));
|
||||
+to = from;
|
||||
|
|
||||
-memcpy(&(to), &(from), sizeof(struct struct_name));
|
||||
+to = from;
|
||||
)
|
||||
|
||||
@depends on patch@
|
||||
identifier struct_name;
|
||||
struct struct_name to;
|
||||
struct struct_name *from;
|
||||
@@
|
||||
(
|
||||
-memcpy(&(to), from, sizeof(to));
|
||||
+to = *from;
|
||||
|
|
||||
-memcpy(&(to), from, sizeof(*from));
|
||||
+to = *from;
|
||||
|
|
||||
-memcpy(&(to), from, sizeof(struct struct_name));
|
||||
+to = *from;
|
||||
)
|
||||
|
||||
@depends on patch@
|
||||
identifier struct_name;
|
||||
struct struct_name *to;
|
||||
struct struct_name from;
|
||||
@@
|
||||
(
|
||||
-memcpy(to, &(from), sizeof(*to));
|
||||
+ *to = from;
|
||||
|
|
||||
-memcpy(to, &(from), sizeof(from));
|
||||
+ *to = from;
|
||||
|
|
||||
-memcpy(to, &(from), sizeof(struct struct_name));
|
||||
+ *to = from;
|
||||
)
|
||||
|
||||
@depends on patch@
|
||||
identifier struct_name;
|
||||
struct struct_name *to;
|
||||
struct struct_name *from;
|
||||
@@
|
||||
(
|
||||
-memcpy(to, from, sizeof(*to));
|
||||
+ *to = *from;
|
||||
|
|
||||
-memcpy(to, from, sizeof(*from));
|
||||
+ *to = *from;
|
||||
|
|
||||
-memcpy(to, from, sizeof(struct struct_name));
|
||||
+ *to = *from;
|
||||
)
|
||||
|
55
scripts/coccinelle/misc/orplus.cocci
Normal file
55
scripts/coccinelle/misc/orplus.cocci
Normal file
@ -0,0 +1,55 @@
|
||||
/// Check for constants that are added but are used elsewhere as bitmasks
|
||||
/// The results should be checked manually to ensure that the nonzero
|
||||
/// bits in the two constants are actually disjoint.
|
||||
///
|
||||
// Confidence: Moderate
|
||||
// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6. GPLv2.
|
||||
// Copyright: (C) 2013 Gilles Muller, INRIA/LIP6. GPLv2.
|
||||
// URL: http://coccinelle.lip6.fr/
|
||||
// Comments:
|
||||
// Options: -no_includes -include_headers
|
||||
|
||||
virtual org
|
||||
virtual report
|
||||
virtual context
|
||||
|
||||
@r@
|
||||
constant c;
|
||||
identifier i;
|
||||
expression e;
|
||||
@@
|
||||
|
||||
(
|
||||
e | c@i
|
||||
|
|
||||
e & c@i
|
||||
|
|
||||
e |= c@i
|
||||
|
|
||||
e &= c@i
|
||||
)
|
||||
|
||||
@s@
|
||||
constant r.c,c1;
|
||||
identifier i1;
|
||||
position p;
|
||||
@@
|
||||
|
||||
(
|
||||
c1 + c - 1
|
||||
|
|
||||
*c1@i1 +@p c
|
||||
)
|
||||
|
||||
@script:python depends on org@
|
||||
p << s.p;
|
||||
@@
|
||||
|
||||
cocci.print_main("sum of probable bitmasks, consider |",p)
|
||||
|
||||
@script:python depends on report@
|
||||
p << s.p;
|
||||
@@
|
||||
|
||||
msg = "WARNING: sum of probable bitmasks, consider |"
|
||||
coccilib.report.print_report(p[0],msg)
|
83
scripts/coccinelle/misc/semicolon.cocci
Normal file
83
scripts/coccinelle/misc/semicolon.cocci
Normal file
@ -0,0 +1,83 @@
|
||||
///
|
||||
/// Removes unneeded semicolon.
|
||||
///
|
||||
// Confidence: Moderate
|
||||
// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2.
|
||||
// URL: http://coccinelle.lip6.fr/
|
||||
// Comments: Some false positives on empty default cases in switch statements.
|
||||
// Options: --no-includes --include-headers
|
||||
|
||||
virtual patch
|
||||
virtual report
|
||||
virtual context
|
||||
virtual org
|
||||
|
||||
@r_default@
|
||||
position p;
|
||||
@@
|
||||
switch (...)
|
||||
{
|
||||
default: ...;@p
|
||||
}
|
||||
|
||||
@r_case@
|
||||
position p;
|
||||
@@
|
||||
(
|
||||
switch (...)
|
||||
{
|
||||
case ...:;@p
|
||||
}
|
||||
|
|
||||
switch (...)
|
||||
{
|
||||
case ...:...
|
||||
case ...:;@p
|
||||
}
|
||||
|
|
||||
switch (...)
|
||||
{
|
||||
case ...:...
|
||||
case ...:
|
||||
case ...:;@p
|
||||
}
|
||||
)
|
||||
|
||||
@r1@
|
||||
statement S;
|
||||
position p1;
|
||||
position p != {r_default.p, r_case.p};
|
||||
identifier label;
|
||||
@@
|
||||
(
|
||||
label:;
|
||||
|
|
||||
S@p1;@p
|
||||
)
|
||||
|
||||
@script:python@
|
||||
p << r1.p;
|
||||
p1 << r1.p1;
|
||||
@@
|
||||
if p[0].line != p1[0].line_end:
|
||||
cocci.include_match(False)
|
||||
|
||||
@depends on patch@
|
||||
position r1.p;
|
||||
@@
|
||||
-;@p
|
||||
|
||||
@script:python depends on report@
|
||||
p << r1.p;
|
||||
@@
|
||||
coccilib.report.print_report(p[0],"Unneeded semicolon")
|
||||
|
||||
@depends on context@
|
||||
position r1.p;
|
||||
@@
|
||||
*;@p
|
||||
|
||||
@script:python depends on org@
|
||||
p << r1.p;
|
||||
@@
|
||||
cocci.print_main("Unneeded semicolon",p)
|
@ -95,7 +95,7 @@ echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
|
||||
echo "%endif"
|
||||
echo "%endif"
|
||||
|
||||
echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_install'
|
||||
echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
|
||||
echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
|
||||
|
||||
echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
|
||||
|
@ -217,34 +217,34 @@ exuberant()
|
||||
emacs()
|
||||
{
|
||||
all_target_sources | xargs $1 -a \
|
||||
--regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/' \
|
||||
--regex='/^\(ENTRY\|_GLOBAL\)(\([^)]*\)).*/\2/' \
|
||||
--regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \
|
||||
--regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \
|
||||
--regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \
|
||||
--regex='/PAGEFLAG\(([^,)]*).*/Page\1/' \
|
||||
--regex='/PAGEFLAG\(([^,)]*).*/SetPage\1/' \
|
||||
--regex='/PAGEFLAG\(([^,)]*).*/ClearPage\1/' \
|
||||
--regex='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/' \
|
||||
--regex='/TESTPAGEFLAG\(([^,)]*).*/Page\1/' \
|
||||
--regex='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/' \
|
||||
--regex='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/' \
|
||||
--regex='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \
|
||||
--regex='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \
|
||||
--regex='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/' \
|
||||
--regex='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/' \
|
||||
--regex='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/' \
|
||||
--regex='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/' \
|
||||
--regex='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/' \
|
||||
--regex='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/' \
|
||||
--regex='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/' \
|
||||
--regex='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/' \
|
||||
--regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \
|
||||
--regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \
|
||||
--regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
|
||||
--regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
|
||||
--regex='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \
|
||||
--regex='/PCI_OP_READ\(([a-z]*[a-z]).*[1-4]\)/pci_bus_read_config_\1/' \
|
||||
--regex='/PCI_OP_WRITE\(([a-z]*[a-z]).*[1-4]\)/pci_bus_write_config_\1/'
|
||||
--regex='/PAGEFLAG(\([^,)]*\).*/Page\1/' \
|
||||
--regex='/PAGEFLAG(\([^,)]*\).*/SetPage\1/' \
|
||||
--regex='/PAGEFLAG(\([^,)]*\).*/ClearPage\1/' \
|
||||
--regex='/TESTSETFLAG(\([^,)]*\).*/TestSetPage\1/' \
|
||||
--regex='/TESTPAGEFLAG(\([^,)]*\).*/Page\1/' \
|
||||
--regex='/SETPAGEFLAG(\([^,)]*\).*/SetPage\1/' \
|
||||
--regex='/__SETPAGEFLAG(\([^,)]*\).*/__SetPage\1/' \
|
||||
--regex='/TESTCLEARFLAG(\([^,)]*\).*/TestClearPage\1/' \
|
||||
--regex='/__TESTCLEARFLAG(\([^,)]*\).*/TestClearPage\1/' \
|
||||
--regex='/CLEARPAGEFLAG(\([^,)]*\).*/ClearPage\1/' \
|
||||
--regex='/__CLEARPAGEFLAG(\([^,)]*\).*/__ClearPage\1/' \
|
||||
--regex='/__PAGEFLAG(\([^,)]*\).*/__SetPage\1/' \
|
||||
--regex='/__PAGEFLAG(\([^,)]*\).*/__ClearPage\1/' \
|
||||
--regex='/PAGEFLAG_FALSE(\([^,)]*\).*/Page\1/' \
|
||||
--regex='/TESTSCFLAG(\([^,)]*\).*/TestSetPage\1/' \
|
||||
--regex='/TESTSCFLAG(\([^,)]*\).*/TestClearPage\1/' \
|
||||
--regex='/SETPAGEFLAG_NOOP(\([^,)]*\).*/SetPage\1/' \
|
||||
--regex='/CLEARPAGEFLAG_NOOP(\([^,)]*\).*/ClearPage\1/' \
|
||||
--regex='/__CLEARPAGEFLAG_NOOP(\([^,)]*\).*/__ClearPage\1/' \
|
||||
--regex='/TESTCLEARFLAG_FALSE(\([^,)]*\).*/TestClearPage\1/' \
|
||||
--regex='/__TESTCLEARFLAG_FALSE(\([^,)]*\).*/__TestClearPage\1/' \
|
||||
--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' \
|
||||
--regex='/PCI_OP_READ(\([a-z]*[a-z]\).*[1-4])/pci_bus_read_config_\1/' \
|
||||
--regex='/PCI_OP_WRITE(\([a-z]*[a-z]\).*[1-4])/pci_bus_write_config_\1/'
|
||||
|
||||
all_kconfigs | xargs $1 -a \
|
||||
--regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
|
||||
|
Loading…
Reference in New Issue
Block a user