From 1b2643f0d09381ad504123809ff587bf6ab0ec7d Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Thu, 21 Feb 2013 16:42:42 -0800 Subject: scripts/tags.sh: add ctags magic for declarations of popular kernel type - Add magic for declarations of variables of popular kernel type like spinlock_t, list_head, wait_queue_head_t and other. - Add a set of specially handled declaration extentions like __attribute, __aligned and other. - Simplify pci_bus_* magic Signed-off-by: Kirill V Tkhai Cc: Michal Marek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/tags.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/tags.sh b/scripts/tags.sh index 08f06c00745..65f9595acea 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -149,12 +149,17 @@ dogtags() exuberant() { all_target_sources | xargs $1 -a \ - -I __initdata,__exitdata,__acquires,__releases \ - -I __read_mostly,____cacheline_aligned \ + -I __initdata,__exitdata,__initconst,__devinitdata \ + -I __devinitconst,__cpuinitdata,__initdata_memblock \ + -I __refdata,__attribute \ + -I __acquires,__releases,__deprecated \ + -I __read_mostly,__aligned,____cacheline_aligned \ -I ____cacheline_aligned_in_smp \ -I ____cacheline_internodealigned_in_smp \ + -I __used,__packed,__packed2__,__must_check,__must_hold \ -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ + -I static,const \ --extra=+f --c-kinds=+px \ --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ @@ -182,8 +187,19 @@ exuberant() --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ - --regex-c='/PCI_OP_READ\(([a-z]*[a-z]).*[1-4]\)/pci_bus_read_config_\1/' \ - --regex-c='/PCI_OP_WRITE\(([a-z]*[a-z]).*[1-4]\)/pci_bus_write_config_\1/' + --regex-c='/PCI_OP_READ\((\w*).*[1-4]\)/pci_bus_read_config_\1/' \ + --regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \ + --regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/' \ + --regex-c='/DEFINE_(RAW_SPINLOCK|RWLOCK|SEQLOCK)\((\w*)/\2/v/' \ + --regex-c='/DECLARE_(RWSEM|COMPLETION)\((\w*)/\2/v/' \ + --regex-c='/DECLARE_BITMAP\((\w*)/\1/v/' \ + --regex-c='/(^|\s)(|L|H)LIST_HEAD\((\w*)/\3/v/' \ + --regex-c='/(^|\s)RADIX_TREE\((\w*)/\2/v/' \ + --regex-c='/DEFINE_PER_CPU\(([^,]*,\s*)(\w*).*\)/\2/v/' \ + --regex-c='/DEFINE_PER_CPU_SHARED_ALIGNED\(([^,]*,\s*)(\w*).*\)/\2/v/' \ + --regex-c='/DECLARE_WAIT_QUEUE_HEAD\((\w*)/\1/v/' \ + --regex-c='/DECLARE_(TASKLET|WORK|DELAYED_WORK)\((\w*)/\2/v/' \ + --regex-c='/DEFINE_PCI_DEVICE_TABLE\((\w*)/\1/v/' all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \ -- cgit v1.2.3 From 6be0710cfe7325be72c72cde702318b983b450a9 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 21 Feb 2013 16:43:12 -0800 Subject: get_maintainer.pl: find maintainers for removed files For removed files, get_maintainer.pl doesn't find any maintainers (besides the default linux-kernel@vger.kernel.org), as it only looks at the "+++" lines, which are "/dev/null" for removals. Fix this by extending the parsing to the "---" lines. E.g. for the two line test patch below the real score maintainers will now be found: --- a/arch/score/include/asm/dma-mapping.h +++ /dev/null Signed-off-by: Geert Uytterhoeven Cc: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 8b673dd4627..18d4ab55606 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -433,7 +433,7 @@ foreach my $file (@ARGV) { while (<$patch>) { my $patch_line = $_; - if (m/^\+\+\+\s+(\S+)/) { + if (m/^\+\+\+\s+(\S+)/ or m/^---\s+(\S+)/) { my $filename = $1; $filename =~ s@^[^/]*/@@; $filename =~ s@\n@@; -- cgit v1.2.3 From dc1393130b026908c54d4538abbb5c2badbfabbe Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 21 Feb 2013 16:44:13 -0800 Subject: checkpatch: prefer dev_( to dev_printk(KERN_ Add YA check to printk style. dev_ uses are functions and generate smaller object code than dev_printk(KERN_. Signed-off-by: Joe Perches Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2bb08a962ce..f9afd075e10 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2430,6 +2430,15 @@ sub process { "Prefer pr_warn(... to pr_warning(...\n" . $herecurr); } + if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) { + my $orig = $1; + my $level = lc($orig); + $level = "warn" if ($level eq "warning"); + $level = "dbg" if ($level eq "debug"); + WARN("PREFER_DEV_LEVEL", + "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr); + } + # function brace can't be on same line, except for #defines of do while, # or if closed on same line if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and -- cgit v1.2.3 From 56e77d709df72eefe50ce97a701bd2d5614d0009 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 21 Feb 2013 16:44:14 -0800 Subject: checkpatch: warn on unnecessary __dev section markings Get people to stop adding __devinit and __devexit section markings. Signed-off-by: Joe Perches Acked-by: Andy Whitcroft Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index f9afd075e10..3dcfbc9c6db 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1931,6 +1931,12 @@ sub process { "use the SSYNC() macro in asm/blackfin.h\n" . $herevet); } +# check for old HOTPLUG __dev section markings + if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) { + WARN("HOTPLUG_SECTION", + "Using $1 is unnecessary\n" . $herecurr); + } + # Check for potential 'bare' types my ($stat, $cond, $line_nr_next, $remain_next, $off_next, $realline_next); -- cgit v1.2.3 From e8eb3997ce2f5887472a674b32f295b0196ecf46 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 21 Feb 2013 16:44:17 -0800 Subject: checkpatch: don't emit the CamelCase warning for PageFoo I'm getting a ton of these: WARNING: Avoid CamelCase: #140: FILE: mm/migrate.c:1576: + if (PageTransHuge(page) && page_count(page) != 3) { So exclude anything which starts with "Page". Tested-by: Andrew Morton Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3dcfbc9c6db..2c50eb4c4e6 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2930,6 +2930,7 @@ sub process { my $var = $1; if ($var !~ /$Constant/ && $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && + $var !~ /^Page[A-Z]/ && !defined $camelcase{$var}) { $camelcase{$var} = 1; WARN("CAMELCASE", -- cgit v1.2.3 From 5ce59ae0bcc0f0ad249d21560c9bb5f6061e62a8 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 21 Feb 2013 16:44:18 -0800 Subject: checkpatch: Add check for kcalloc argument order kcalloc is sometimes misused with the first and second arguments switched. Same issue with kmalloc_array too. Bleat if sizeof is the first argument Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2c50eb4c4e6..7b40a3f729a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3476,6 +3476,12 @@ sub process { "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); } +# check for alloc argument mismatch + if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) { + WARN("ALLOC_ARRAY_ARGS", + "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr); + } + # check for multiple semicolons if ($line =~ /;\s*;\s*$/) { WARN("ONE_SEMICOLON", -- cgit v1.2.3 From 37581c28e9e77f44a3124ebab99b98643bda1aa2 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Thu, 21 Feb 2013 16:44:19 -0800 Subject: checkpatch: fix USLEEP_RANGE test Do not test udelay() for a value less than 10usec when passed a variable instead of a hard-coded number; there is no way for checkpatch to know the value of the variable. As it is today, it will complain about variables with alphanumeric characters plus '_', e.g. foo_bar, but not variables with other characters, eg. foo->bar. Signed-off-by: Bruce Allan Cc: Andy Whitcroft Cc: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7b40a3f729a..747bcd768da 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3253,9 +3253,9 @@ sub process { } # prefer usleep_range over udelay - if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) { + if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) { # ignore udelay's < 10, however - if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) { + if (! ($1 < 10) ) { CHK("USLEEP_RANGE", "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); } -- cgit v1.2.3