summaryrefslogtreecommitdiff
path: root/scripts/checkpatch.pl
AgeCommit message (Collapse)Author
2009-10-29checkpatch: version 0.30Andy Whitcroft
Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-10-29checkpatch: fix false EXPORT_SYMBOL warningAndy Whitcroft
Ingo reported that the following lines triggered a false warning, static struct lock_class_key rcu_lock_key; struct lockdep_map rcu_lock_map = STATIC_LOCKDEP_MAP_INIT("rcu_read_lock", &rcu_lock_key); EXPORT_SYMBOL_GPL(rcu_lock_map); from kernel/rcutree.c , and the false warning looked like this, WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable +EXPORT_SYMBOL_GPL(rcu_lock_map); We actually should be checking the statement before the EXPORT_* for a mention of the exported object, and complain where it is not there. [akpm@linux-foundation.org: coding-style fixes] Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reported-by: Daniel Walker <dwalker@fifo99.com> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-10-29checkpatch: fix __attribute__ matchingAndy Whitcroft
In the following code, union thread_union init_thread_union __attribute__((__section__(".data.init_task"))) = { INIT_THREAD_INFO(init_task) }; There is a non-conforming declaration. It should really be like the following, union thread_union init_thread_union __attribute__((__section__(".data.init_task"))) = { INIT_THREAD_INFO(init_task) }; However, checkpatch doesn't catch this right now because it doesn't correctly evaluate the "__attribute__". It is not at all clear that we care what preceeds an assignment style attribute when we find the open brace. Relax the test so we do not need to check the __attribute__. Reported-by: Daniel Walker <dwalker@fifo99.com> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-10-29checkpatch: fix false errors due to macro concatenationAndy Whitcroft
The macro concatenation (##) sequence can cause false errors when checking macro's. Checkpatch doesn't currently know about the operator. For example this line, + entry = (struct ftrace_raw_##call *)raw_data; \ is correct but it produces the following error, ERROR: need consistent spacing around '*' (ctx:WxB) + entry = (struct ftrace_raw_##call *)raw_data;\ ^ The line above doesn't have any spacing problems, and if you remove the macro concatenation sequence checkpatch doesn't give any errors. Extend identifier handling to include ## concatenation within the definition of an identifier. Reported-by: Daniel Walker <dwalker@fifo99.com> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-10-29checkpatch: update copyright datesAndy Whitcroft
Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-10-29checkpatch: correctly stop scanning at the bottom of a hunkAndy Whitcroft
We are allowing context scanning checks to apply against the first line of context outside at the end of the hunk. This can lead to false matches to patch names leading to various perl warnings. Correctly stop at the bottom of the hunk. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-10-29checkpatch: possible types -- prevent illegal modifiers being addedAndy Whitcroft
Prevent known non types being detected as modifiers. Ensure we do not look at any type which starts with a keyword. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-22checkpatch: add some common Blackfin checksMike Frysinger
Add checks for Blackfin-specific issues that seem to crop up from time to time. In particular, we have helper macros to break a 32bit address into the hi/lo parts, and we want to make sure people use the csync/ssync variant that includes fun anomaly workarounds. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Bryan Wu <cooloney@kernel.org> Cc: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-22checkpatch: version 0.29Andy Whitcroft
Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-22checkpatch: limit sN/uN matches to actual bit sizesAndy Whitcroft
Limit our type matcher to the s/u/le/be etc sizes that actually exist to prevent miss categorising s2 as a type. Fix up the spelling of the error also. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-22checkpatch: format strings should not have brackets in macrosAndy Whitcroft
We should not recommend braces for the following: #define pr_fmt(fmt) "%s: " fmt, __func__ allow things with double quotes round them to avoid this check. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-22checkpatch: make -f alias --file, add --help, more verbose help messageHannes Eder
Impact: - More verbose help/usage message. - Make the option -f an alias for --file. - On -h, --help, and --version display help message and exit(0). - With no FILE(s) given, exit(1) with "no input files". - On invalid options display help/usage and exit(1). Based on a patch by Pavel Machek. Signed-off-by: Hannes Eder <hannes@hanneseder.net> Acked-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-22checkpatch: indent checks -- stop when we run out of continuation linesAndy Whitcroft
Ensure we terminate when there are no futher continuation lines when trying to determine relative indent of conditionals and their blocks. Reported-by: John Daiker <daikerjohn@gmail.com> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-22checkpatch: handle C99 comments correctly (performance issue)Daniel Walker
This fixes the sanitation process in checkpatch.pl so that it blocks out the text after a C99 style comment the same way it does with block style comments. This prevents the text from getting processed as regular code. Signed-off-by: Daniel Walker <dwalker@fifo99.com> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-22checkpatch: possible types -- else cannot start a typeAndy Whitcroft
An else cannot start a type, it would have to be within a block after the else. This can trigger false modifier matching. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-27checkpatch: version 0.28Andy Whitcroft
Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-27checkpatch: add __ref as a sparse modifierAndy Whitcroft
Add __ref as a sparse modifier. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-27checkpatch: extend attribute testing to all modifiersAndy Whitcroft
We should allow testing of all modifiers not just attributes. Extend testing and test for all the know modifiers. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-27checkpatch: a modifier is not an identifier at the end of a typeAndy Whitcroft
We must make sure we do not misrecognise a modifier as an Identifier when trying to match types. Prevent us matching this: void * __ref Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-27checkpatch: pointer type star may have modifiers followingAndy Whitcroft
We may have any modifier following a pointer type star. Handle this: void * __user * __user foo; Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-27checkpatch: correctly handle type spacing in the face of modifiersAndy Whitcroft
We need to handle interspersed modifiers in the middle of pointer types, for example: void * __user * __user bar; Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-27checkpatch: do not warn about -p0 patches when checking filesAndy Whitcroft
We are triggering the -p0 check for our own diffs generated using --file command line option. Suppress this check for files. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-27checkpatch: make in_atomic ok in the coreAndy Whitcroft
We say that in_atomic() is ok in the core kernel, but then always report it regardless of where in the kernel it is. Keep quiet if it is used in kernel/*. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-15checkpatch: version: 0.27Andy Whitcroft
Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-15checkpatch: struct seq_operations should normally be constAndy Whitcroft
In the general use case struct seq_operations should be a const object. Check for and warn where it is not. Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-15checkpatch: if should not continue a preceeding braceAndy Whitcroft
We should not be continuing a braced section with an if, for example: if (...) { } if (...) { } Detect this and suggest adding a newline. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-15checkpatch: allow parentheses on return handle array valuesAndy Whitcroft
When we allow return to have surrounding parentheses when containing comparison operators we are not correctly handling the case where the values contain array sufffixes. Squash them. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-15checkpatch: type/cast spacing should not check prefix spacingAndy Whitcroft
We should not be complaining about the prefix spacing for types and casts. We are triggering here because the check for spacing between '*'s is overly loose. Tighten this up. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-15checkpatch: handle missing #if open in contextAndy Whitcroft
If the #if opening statement is not in the context then the context stack can be empty. Handle this by ensuring there is always a blank entry in the stack. Signed-off-by: Andy Whitcroft <apw@canonical.com> Tested-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: version: 0.26Andy Whitcroft
Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: fix the perlcritic errorsAndy Whitcroft
Clean up checkpatch using perlcritic. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: struct file_operations should normally be constAndy Whitcroft
In the general use case struct file_operations should be a const object. Check for and warn where it is not. As suggested by Steven and Ingo. Acked-by: Steven Rostedt <rostedt@goodmis.org> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: ensure we actually detect if assignments split across linesAndy Whitcroft
When checking for assignments within if conditionals we check the whole of the condition, but the match is performed using a line constrained regular expression. This means we can miss split conditionals or those on the second line. Allow the check to span lines. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: do not report nr_static as a static declarationAndy Whitcroft
Ensure we do not report identifiers containing the word static as static declarations. For example this should not be reported as an unecessary assignement of 0: long nr_static = 0; Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: track #ifdef/#else/#endif when tracking blocksAndy Whitcroft
When picking up a complete statement or block for analysis we cannot simply track open/close/etc parenthesis we must take into account preprocessor section boundaries. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: fix continuation detection when handling spacing on operatorsAndy Whitcroft
We are miscategorising a continuation fragment following an operator which may lead to us thinking that there is a space after it when there is not. Fix this up. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: loosen spacing on typedef function checksAndy Whitcroft
Loosen spacing checks to correctly detect this valid use of a typedef: typedef struct rcu_data *(*get_data_func)(int); Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: try to catch missing VMLINUX_SYMBOL() in vmlinux.lds.hMike Frysinger
Seems like every other release we have someone who updates vmlinux.lds.h and adds C-visible symbols without VMLINUX_SYMBOL() around them. So start checking the file and reject assignments which have plain symbols on either side. [apw@canonical.com: soften the check, add tests] Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: allow parentheses on return for comparisonsAndy Whitcroft
It seems to be a common idiom to include braces on conditionals in all contexts including return. Allow this exception to the return is not a function checks. Reported by Kay Sievers. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: Add warning for p0-patchesWolfram Sang
Some people work internally with -p0-patches which has the danger that one forgets to convert them to -p1 before mainlining. Bitten myself and seen p0-patches in mailing lists occasionally, this patch adds a warning to checkpatch.pl in case a patch is -p0. If you really want, you can fool this check to generate false positives, this is why it just spits a warning. Making the check 100% proof is trickier than it looks, so let's start with a version which catches the cases of real use. [apw@canonical.com: update message language, handle null prefix, add tests] Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: update copyrightsAndy Whitcroft
Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: version: 0.25Andy Whitcroft
Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: dissallow spaces between stars in pointer typesAndy Whitcroft
Disallow spaces within multiple pointer stars (*) in both casts and definitions. Both of these would now be reported: (char * *) char * *foo; Also now consistently detects and reports the attributes within these structures making the error report itself clearer. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: comment ends inside strings is most likely not an open commentAndy Whitcroft
When we are detecting whether a comment is open when we start a hunk we check for the first comment edge in the hunk and assume its inverse. However if the hunk contains something like below, then we will assume that a comment was open. Update this heuristic to see if the comment edge is obviously within double quotes and ignore it if so: foo(" */); Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: detect multiple bitfield declarationsAndy Whitcroft
Detect the colons (:) which make up secondary bitfield declarations and apply binary colon checks. For example the following is common idiom: int foo:1, bar:1; Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: __weak is an official attributeAndy Whitcroft
Add __weak as an official attribute. This tends to be used in a location where the automated attribute detector misses it. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: structure member assignments are not complexAndy Whitcroft
Ensure we do not trigger the complex macros checks on structure member assignment, for example: #define foo .bar = 10 Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: widen implied comment detection to allow multiple starsAndy Whitcroft
Some people use double star '**' as a comment continuation, and start comments with complete lines of stars. Widen the implied comment detection to pick these up. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: comment detection may miss an implied comment on the last hunkAndy Whitcroft
When detecting implied comments from leading stars we may incorrectly think we have detected an edge one way or the other when we have not if we drop off the end of the last hunk. Fix this up. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-06checkpatch: add checks for in_atomic()Andy Whitcroft
in_atomic() is not for driver use so report any such use as an ERROR. Also in_atomic() is often used to determine if we may sleep, but it is not reliable in this use model therefore strongly discourage its use. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>