aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
Commit message (Collapse)AuthorAgeFilesLines
* Update email addresses.Dave Jones2008-10-201-1/+1
| | | | | | | | | | | | Update assorted email addresses and related info to point to a single current, valid address. additionally - trivial CREDITS entry updates. (Not that this file means much any more) - remove arjans dead redhat.com address from powernow driver Signed-off-by: Dave Jones <davej@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* checkpatch: version: 0.24Andy Whitcroft2008-10-161-1/+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>
* checkpatch: allow for comments either side of a brace on caseAndy Whitcroft2008-10-161-1/+1
| | | | | | | | | When specifying case we may have comments and/or braces at the end without actually having a 'statement'. Allow for these to occur in any order. 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>
* checkpatch: suspect indent handle macro continuationAndy Whitcroft2008-10-161-1/+4
| | | | | | | | | When ignoring a macro in the middle of a conditional, we need to ignore the macro start and any continuation lines. 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>
* checkpatch: trailing statements ensure we report the end of the lineAndy Whitcroft2008-10-161-1/+10
| | | | | | | | | | | | | | | | | | | | | When reporting some complex trailing statements we report only the starting line of the error, that tends to imply the shown line is in error and confuse the reader. As we do know where the actual error is report that line too with an appropriate gap marker where applicable. #ERROR: trailing statements should be on next line #1: FILE: Z202.c:1: + for (pbh = page_buffers(bh->b_page); pbh != bh; + pbh = pbh->b_this_page, key++); #ERROR: trailing statements should be on next line #4: FILE: Z202.c:4: + for (pbh = page_buffers(bh->b_page); [...] + pbh = pbh->b_this_page, key++); 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>
* checkpatch: DEFINE_ macros are real definitions for exportsAndy Whitcroft2008-10-161-7/+8
| | | | | | | | | | When we want to confirm an export is directly after its definition we need to allow for DEFINE_ style macros. Add these to the execeptions. Refactor the exceptions. 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>
* checkpatch: complex macros checks miss square bracketsAndy Whitcroft2008-10-161-3/+4
| | | | | | | | | We are missing 'simple' values which include square brackets. Refactor to ensure we handle nesting correctly and detect these simple forms. 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>
* checkpatch: suspect code indent must stop at #else/#elifAndy Whitcroft2008-10-161-0/+6
| | | | | | | | | | When we hit and #else or #elif we know we are meeting an alternative piece of code. All bets are off on indent if we did not see the open of the control so stop checking. 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>
* checkpatch: pull out known acceptable typedefsAndy Whitcroft2008-10-161-1/+7
| | | | | | | | | | Within the type checker we have a number of common kernel types which must be implemented as typedefs. Pull those out so that we can use the same expressions to trigger exclusions. 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>
* checkpatch: accept any sized le/be typeAndy Whitcroft2008-10-161-1/+1
| | | | | | | | | We are likely going to have 24 bit types. Expand the type matcher to match any size. 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>
* checkpatch: macros which define structure members are not complexAndy Whitcroft2008-10-161-0/+1
| | | | | | | | | | | | | We often see macros which define structure members, these are not complex and necessarily do not have braces or brackets. For example: #define _PLIST_HEAD_INIT(head) \ .prio_list = LIST_HEAD_INIT((head).prio_list), \ .node_list = LIST_HEAD_INIT((head).node_list) 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>
* checkpatch: handle do without braces if we have enough contextAndy Whitcroft2008-10-161-3/+24
| | | | | | | | | | If we have sufficient context detect and handle do without braces ({). Else these incorrectly trigger a trailing statements error for the associated while. 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>
* checkpatch: labels are not possible typesAndy Whitcroft2008-10-161-1/+1
| | | | | | | | A label is not a candidate for a possible type. Exclude them. 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>
* checkpatch: do is not a possible typeAndy Whitcroft2008-10-161-6/+18
| | | | | | | | | | | | | | | A do without braces '{' may trigger a false possible type 'do' and then this may be interpreted as an external definition of foo(): do foo(); while (bar); Add do to the type exclusions. Fix up tests so we can check for them. 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>
* checkpatch: version: 0.23Andy Whitcroft2008-10-161-1/+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>
* checkpatch: ensure we only apply checks to the lines within hunksAndy Whitcroft2008-10-161-2/+3
| | | | | | | | | | We should only apply source checks to lines within hunks. Checks which are anchored in the context may falsly trigger in the commentory. Ensure they only match within valid hunk lines. 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>
* checkpatch: suspect indent count condition lines correctlyAndy Whitcroft2008-10-161-1/+2
| | | | | | | | | Correct calculation of the number of lines of condition where we have suspect indent. 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>
* checkpatch: check line endings in text format filesAndy Whitcroft2008-10-161-3/+4
| | | | | | | | | | Firmware may be included in the kernel as .ihex files. These are inherantly text, but not source. The line ending checks are applicable to these kinds of file, allow just these checks to apply to all files. 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>
* checkpatch: handle comment/quote nesting correctlyAndy Whitcroft2008-10-161-1/+1
| | | | | | | | | | Ensure that a close comment cannot incorrectly trigger in the middle of a string. Reported by Jaswinder Singh. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Cc: Jaswinder Singh <jaswinder@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* checkpatch: suppress errors triggered by short patchAndy Whitcroft2008-10-161-0/+1
| | | | | | | | | | | | | | | | | | When the last hunk of a patch is short it will trigger errors from checkpatch: Use of uninitialized value in pattern match (m//) at /usr/local/bin/checkpatch.pl line 394. Use of uninitialized value in concatenation (.) or string at /usr/local/bin/checkpatch.pl line 397. Use of uninitialized value in pattern match (m//) Avoid touching beyond the last line. Reported by Julien Brunel. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Cc: Julien Brunel <brunel@diku.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* checkpatch: case/default checks should only check changed linesAndy Whitcroft2008-10-161-8/+9
| | | | | | | | | We should only be checking changes lines for the trailing statement check on case/default statements. 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>
* checkpatch: version: 0.22Andy Whitcroft2008-10-161-1/+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>
* checkpatch: perform indent checks on perlAndy Whitcroft2008-10-161-2/+5
| | | | | | | | | So that we eat our own dog food ensure the indent checks apply to perl too. 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>
* checkpatch: report the correct lines for single statement blocksAndy Whitcroft2008-10-161-3/+3
| | | | | | | | | Report the correct lines for single statement blocks. Currently we are reporting the right number of lines, but not skipping the negative lines. 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>
* checkpatch: %Lx tests should hand %% as a literalAndy Whitcroft2008-10-161-0/+1
| | | | | | | | | | | | Ensure that we handle literal %'s correctly when adjacent to a %Lx. %Lx bad %%Lx good %%%Lx bad 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>
* checkpatch: suspect indent -- skip over preprocessor, label and blank linesAndy Whitcroft2008-10-161-10/+15
| | | | | | | | | | We should skip over and check the lines which follow preprocessor statements, labels, and blank lines. These all have legitimate reasons to be indented differently. 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>
* checkpatch: report the real first line of all suspect indentsAndy Whitcroft2008-10-161-55/+86
| | | | | | | | | | | | We are currently only reporting syspect indents if the conditional is modified but the indent missmatch could be generated by the body changing, make sure we catch both. Also only report the first line of the body, and more importantly make sure we report the raw copy of the line. Finally report the indent levels to make it easier to understand what is wrong. 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>
* checkpatch: report any absolute references to kernel source filesAndy Whitcroft2008-10-161-0/+41
| | | | | | | | | | Absolute references to kernel source files are generally only useful locally to the originator of the patch. Check for any such references and report them. 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>
* checkpatch: reduce warnings for #include of asm/foo.h to check from arch/bar.cAndy Whitcroft2008-10-161-4/+9
| | | | | | | | | | It is much more likely that an architecture file will want to directly include asm header files. Reduce this WARNING to a CHECK when the referencing file is in the arch directory. 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>
* checkpatch: include/asm checks should be anchoredAndy Whitcroft2008-10-161-1/+1
| | | | | | | | | It is possible to have other include/asm paths within the tree which are not subject to the do not edit checks. Ignore those. 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>
* checkpatch: fix up comment checks search to scan the entire blockAndy Whitcroft2008-10-161-3/+8
| | | | | | | | | | We are not counting the lines in the block correctly which causes the comment scan to stop prematurly and thus miss comments which end at the end of the block. 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>
* checkpatch: complex macros -- fix up extension handlingAndy Whitcroft2008-10-161-2/+2
| | | | | | | | Only pull in new extension lines where the current contents ends with a \. 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>
* checkpatch: ____cacheline_aligned et al are modifiersAndy Whitcroft2008-10-161-1/+4
| | | | | | | | Add the cacheline alignment modifiers to the attribute lists. 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>
* checkpatch: add tests for the attribute matcherAndy Whitcroft2008-10-161-0/+10
| | | | | | | | | Add support for direct testing of the attribute matcher, add basic tests for 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>
* checkpatch: switch indent allow plain returnAndy Whitcroft2008-10-161-1/+5
| | | | | | | | | | | | | | | It is a common and sane idiom to allow a single return on the end of a case statement: switch (...) { case foo: return bar; } Add an exception for this. 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>
* checkpatch: conditional indent -- labels have different indent rulesAndy Whitcroft2008-10-161-3/+8
| | | | | | | | | | Labels have different indent rules and must be ignored when checking the conditional indent levels. Also correct identify labels in single statement conditionals. 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>
* checkpatch: values: double ampersand may be unaryAndy Whitcroft2008-10-161-2/+2
| | | | | | | | | It is possible to use double ampersand (&&) in unary context where it means the address of a goto label. Handle spacing for 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>
* checkpatch: square brackets -- exemption for array slices in bracesAndy Whitcroft2008-10-161-2/+4
| | | | | | | | | It is wholy reasonable to have square brackets representing array slices in braces on the same line. These should be spaced. 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>
* checkpatch: version 0.21Andy Whitcroft2008-07-241-1/+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>
* checkpatch: types cannot start mid word for pointer testsAndy Whitcroft2008-07-241-2/+2
| | | | | | | | | | | When checking spacing for pointer checks the type cannot start in the middle of a word, ie. this is not 'int * bar': x = fooint * bar; 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>
* checkpatch: complex macros need to ignore commentsAndy Whitcroft2008-07-241-0/+1
| | | | | | | | | | | Ensure we ignore comments in complex macro detection else we incorrectly report this: #define PFM_GROUP_PERM_ANY -1 /* any user/group */ 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>
* checkpatch: variants -- move the main unary/binary operators to use variantsAndy Whitcroft2008-07-241-18/+18
| | | | | | | | | Now that we have a variants system, move to using that to carry the unary/binary designation for +, -, &, and *. 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>
* checkpatch: add checks for question mark and colon spacingAndy Whitcroft2008-07-241-9/+72
| | | | | | | | | | | | | | | Add checks for the question mark colon operator spacing, and also check the other uses of colon. Colon means a number of things: - it introduces the else part of the ?: operator, - it terminates a goto label, - it terminates the case value, - it separates the identifier from the bit size on bit fields, and - it is used to introduce option types in asm(). 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>
* checkpatch: possible modifiers -- handle multiple modifiers and trailingAndy Whitcroft2008-07-241-3/+5
| | | | | | | | | | | | | | Add support for multiple modifiers such as: int __one __two foo; Also handle trailing known modifiers when defecting modifiers: int __one foo __read_mostly; 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>
* checkpatch: possible types -- known modifiers cannot be typesAndy Whitcroft2008-07-241-1/+1
| | | | | | | | Ensure we do not inadvertantly load known modifiers up as possible types. 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>
* checkpatch: handle return types of pointers to functionsAndy Whitcroft2008-07-241-1/+1
| | | | | | | | | | | Make sure we correctly mark the return type of the pointer to a function declaration. const void *(*sb_tag)(struct sysfs_tag_info *info); 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>
* checkpatch: macro complexity checks are meaningless in linker scriptsAndy Whitcroft2008-07-241-1/+2
| | | | | | | | | Exclude vmlinux.lds.h from the macro complexity checks. They will never apply sanely here. 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>
* checkpatch: possible modifiers are not being correctly matchedAndy Whitcroft2008-07-241-4/+3
| | | | | | | | | | | | | Although we are finding the added modifier in the declaration below we are not correctly matching it as a type. Fix the declaration. static void __ref *vmem_alloc_pages(unsigned int order) { } 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>
* checkpatch: improve type matcher debugAndy Whitcroft2008-07-241-4/+7
| | | | | | | | | Improve type matcher debug so we can see what it does match. As part of this move us to to using the common debug framework. 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>
* checkpatch: allow for type modifiers on multiple declarationsAndy Whitcroft2008-07-241-0/+4
| | | | | | | | | | | | Allow for type modifiers mid declaration on multiple declarations: struct mxser_mstatus ms, __user *msu = argp; Reported by Jiri Slaby. 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>