1
0
Fork 0
Commit Graph

79 Commits (8ed22cad9ce16e3d8915ae75544a133c3050d96f)

Author SHA1 Message Date
Andy Whitcroft 8ed22cad9c checkpatch: pull out known acceptable typedefs
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>
2008-10-16 11:21:37 -07:00
Andy Whitcroft afbe8d283b checkpatch: accept any sized le/be type
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>
2008-10-16 11:21:37 -07:00
Andy Whitcroft b132e5d586 checkpatch: macros which define structure members are not complex
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>
2008-10-16 11:21:37 -07:00
Andy Whitcroft 170d3a2268 checkpatch: handle do without braces if we have enough context
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>
2008-10-16 11:21:37 -07:00
Andy Whitcroft a6a8406282 checkpatch: labels are not possible types
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>
2008-10-16 11:21:37 -07:00
Andy Whitcroft 0776e59460 checkpatch: do is not a possible type
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>
2008-10-16 11:21:36 -07:00
Andy Whitcroft 5fdd23acf9 checkpatch: version: 0.23
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>
2008-10-16 11:21:36 -07:00
Andy Whitcroft 306708547b checkpatch: ensure we only apply checks to the lines within hunks
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>
2008-10-16 11:21:36 -07:00
Andy Whitcroft 6f779c18ca checkpatch: suspect indent count condition lines correctly
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>
2008-10-16 11:21:36 -07:00
Andy Whitcroft 5368df20fb checkpatch: check line endings in text format files
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>
2008-10-16 11:21:36 -07:00
Andy Whitcroft 81bc0e0202 checkpatch: handle comment/quote nesting correctly
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>
2008-10-16 11:21:36 -07:00
Andy Whitcroft dea33496dd checkpatch: suppress errors triggered by short patch
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>
2008-10-16 11:21:36 -07:00
Andy Whitcroft a1080bf808 checkpatch: case/default checks should only check changed lines
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>
2008-10-16 11:21:36 -07:00
Andy Whitcroft dea79cd3df checkpatch: version: 0.22
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft b9ea10d691 checkpatch: perform indent checks on perl
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft f055663c58 checkpatch: report the correct lines for single statement blocks
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft 2a1bc5d5c5 checkpatch: %Lx tests should hand %% as a literal
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft 9bd49efe4e checkpatch: suspect indent -- skip over preprocessor, label and blank lines
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft 4d001e4d88 checkpatch: report the real first line of all suspect indents
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft 6ecd967444 checkpatch: report any absolute references to kernel source files
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft e09dec4831 checkpatch: reduce warnings for #include of asm/foo.h to check from arch/bar.c
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft c1ab33269a checkpatch: include/asm checks should be anchored
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft 01fa91471e checkpatch: fix up comment checks search to scan the entire block
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft 636d140a80 checkpatch: complex macros -- fix up extension handling
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft 24e1d81acd checkpatch: ____cacheline_aligned et al are modifiers
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft a1ef277e2c checkpatch: add tests for the attribute matcher
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>
2008-10-16 11:21:35 -07:00
Andy Whitcroft 1bdab9e588 checkpatch: switch indent allow plain return
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>
2008-10-16 11:21:34 -07:00
Andy Whitcroft 14b111c158 checkpatch: conditional indent -- labels have different indent rules
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>
2008-10-16 11:21:34 -07:00
Andy Whitcroft 0d413866c7 checkpatch: values: double ampersand may be unary
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>
2008-10-16 11:21:34 -07:00
Andy Whitcroft fe2a7dbc85 checkpatch: square brackets -- exemption for array slices in braces
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>
2008-10-16 11:21:34 -07:00
Andy Whitcroft 33cba06573 checkpatch: version 0.21
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>
2008-07-24 10:47:27 -07:00
Andy Whitcroft 234fff6515 checkpatch: types cannot start mid word for pointer tests
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft 292f1a9b34 checkpatch: complex macros need to ignore comments
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft 74048ed811 checkpatch: variants -- move the main unary/binary operators to use variants
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft 1f65f947a6 checkpatch: add checks for question mark and colon spacing
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft d250658658 checkpatch: possible modifiers -- handle multiple modifiers and trailing
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft 0221f55c14 checkpatch: possible types -- known modifiers cannot be types
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft 8ea3eb9a20 checkpatch: handle return types of pointers to functions
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft b8f96a31f3 checkpatch: macro complexity checks are meaningless in linker scripts
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft d2172eb5bd checkpatch: possible modifiers are not being correctly matched
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft 7429c6903e checkpatch: improve type matcher debug
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft 389a2fe57f checkpatch: allow for type modifiers on multiple declarations
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>
2008-07-24 10:47:26 -07:00
Wolfram Sang 3c232147a7 checkpatch: correct spelling in kfree checks
Correct spelling in the kfree reports.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
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>
2008-07-24 10:47:26 -07:00
Greg Kroah-Hartman 4c432a8f01 checkpatch: usb_free_urb() can take NULL
usb_free_urb() can take a NULL, so let's check and warn about that.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft f5fe35dd95 checkpatch: condition/loop indent checks
Check to see if the block/statement which a condition or loop introduces
is indented correctly.

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>
2008-07-24 10:47:26 -07:00
Andy Whitcroft 53210168fe checkpatch: toughen trailing if statement checks and extend them to while and for
Extend the trailing statement checks to report a trailing semi-colon ';'
as we really want it on the next line and indented so it is really really
obvious.  Also extend the tests to include while and for.

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>
2008-07-24 10:47:25 -07:00
Andy Whitcroft 8d31cfcecf checkpatch: check spacing for square brackets
Check on the spacing before square brackets.  We should only allow spaces
there if this is part of a type definition or an initialialiser.

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>
2008-07-24 10:47:25 -07:00
Andy Whitcroft e2a763c20b checkpatch: switch -- report trailing statements on case and default
Report trailing statements on case and default 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>
2008-07-24 10:47:25 -07:00
Andy Whitcroft f4c014c0de checkpatch: allow printk strings to exceed 80 characters to maintain their searchability
Allow printk strings to break the 80 character width limits, thus keeping
them complete and searchable.

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>
2008-07-24 10:47:25 -07:00
Andy Whitcroft 548596d523 checkpatch: trailing statement indent: fix end of statement location
Fix end of statement location.  Where the last line of the statement is
replaced we are miss reporting the newly added replacement an incorrectly
indented trailing statement for the negative context.  We are also
incorrectly reporting negative statements generally.

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>
2008-07-24 10:47:25 -07:00