Commit graph

475 commits

Author SHA1 Message Date
Ingo Molnar 9b9412dc70 Merge branch 'for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu
Pull RCU changes from Paul E. McKenney:

  - The combination of tree geometry-initialization simplifications
    and OS-jitter-reduction changes to expedited grace periods.
    These two are stacked due to the large number of conflicts
    that would otherwise result.

    [ With one addition, a temporary commit to silence a lockdep false
      positive. Additional changes to the expedited grace-period
      primitives (queued for 4.4) remove the cause of this false
      positive, and therefore include a revert of this temporary commit. ]

  - Documentation updates.

  - Torture-test updates.

  - Miscellaneous fixes.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-08-12 12:12:12 +02:00
Paul E. McKenney 3ad81779ad scripts: Make checkpatch.pl warn on expedited RCU grace periods
The synchronize_rcu_expedited() and synchronize_sched_expedited()
expedited-grace-period primitives induce OS jitter, which can degrade
real-time response.  This commit therefore adds a checkpatch.pl warning
on any patch adding them.

Note that this patch does not warn on synchronize_srcu_expedited()
because it does not induce OS jitter, courtesy of its otherwise
much-maligned read-side memory barriers.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
2015-07-22 15:27:42 -07:00
Joe Perches b4749e96a4 checkpatch: fix long line messages about patch context
Changes in ("checkpatch: categorize some long line length checks")
now erroneously reports long line defects in patch context.

Fix it.

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-07-17 16:39:53 -07:00
Joe Perches 3c816e490c checkpatch: emit "NOTE: <types>" message only once after multiple files
Make this message similar to the "false positives" message and emit it
only once when scanning multiple files instead of after each file scanned.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:42 -07:00
Joe Perches e518e9a59e checkpatch: emit an error when there's a diff in a changelog
People often put diff snippets in changelogs.  This causes problems
when one tries to apply a file containing both the changelog and the
diff because patch(1) tries to apply the diff which it found in the
changelog.

Warn once when what seems to be a diff snippet in the changelog exists.

Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:42 -07:00
Bjorn Andersson 5a6d20ce19 checkpatch: validate MODULE_LICENSE content
There is a well defined list of expected values for MODULE_LICENSE so warn
the user upon usage of unknown values.

Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:42 -07:00
Mateusz Kulikowski 10895d2c82 checkpatch: add multi-line handling for PREFER_ETHER_ADDR_COPY
Handle multi-line memcpy() properly.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Acked-by: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:42 -07:00
Mateusz Kulikowski 8617cd09bc checkpatch: suggest using eth_zero_addr() and eth_broadcast_addr()
Suggest using eth_zero_addr() or eth_broadcast_addr() instead of memset().

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Acked-by: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:42 -07:00
Mateusz Kulikowski 9e20a8535f checkpatch: fix processing of MEMSET issues
Remove 's' modifier to avoid reporting the same warning several times.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Acked-by: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:42 -07:00
Mateusz Kulikowski b6117d175b checkpatch: suggest using ether_addr_equal*()
Check if memcmp() is used to compare ethernet addresses and suggest using
ether_addr_equal() or ether_addr_equal_unaligned()

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Acked-by: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:42 -07:00
Joe Perches 06330fc40e checkpatch: avoid NOT_UNIFIED_DIFF errors on cover-letter.patch files
Make an exception for the "Does not appear to be a unified-diff" error
when scanning what appears to be git generated cover letters.

Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:42 -07:00
Maxim Uvarov f1a6367855 checkpatch: remove local from codespell path
local is typically used for manually installed apps.
For apps installed from distro the right path is /usr/share.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Acked-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Joe Perches 34d8815f95 checkpatch: add --showfile to allow input via pipe to show filenames
Using "git diff | ./scripts/checkpatch -" does not have an
easy mechanism to see the files and lines actually modified.

Add --showfile to see the file and line specified in the diff.

When --showfile is used without --terse, the second line of each
message output is redundant, so it is removed.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Petr Mladek <pmladek@suse.cz>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Joe Perches 5723029711 checkpatch: colorize output to terminal
Add optional colors to make seeing message types a bit easier.

Add --color command line switch, default:on

Error is RED, warning is YELLOW, check is GREEN.  The message type, if
shown, is BLUE.

Signed-off-by: Joe Perches <joe@perches.com>
Tested-by: Petr Mladek <pmladek@suse.cz>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Joe Perches d8469f1620 checkpatch: improve output with multiple command-line files
If there are multiple patches/files on the command line,
use a prefix before the patch/file message output like:
        --------------
        patch/filename
        --------------
to make the identifying which messages go with which
file/patch a bit easier to parse.

Move the perl version and false positive messages after
all the files have been scanned so that they are emitted
only once.

Standardize the NOTE: <...> form to always emit a blank
line before the NOTE and always use print << "EOM" style.

Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Petr Mladek <pmladek@suse.cz>
Tested-by: Petr Mladek <pmladek@suse.cz>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Joe Perches 47e0c88b37 checkpatch: categorize some long line length checks
Many lines of code extend beyond the maximum line length.  Some of these
are possibly justified by use type.

For instance:

structure definitions where comments are added per member like:
struct foo {
	type member;		/* some long description */

And lines that don't fit the typical logging message style
where a string constant is used like:

        SOME_MACRO(args, "Some long string");

Categorize these long line types so that checkpatch can use a command-line
--ignore=<type> option to avoid emitting some long line warnings.

One of the existing checkpatch exclusions allowed kernel-doc argument
documentation to exceed 80 columns because old versions of kernel-doc
required single line documentation.  The requirement was removed in 2009
so remove that exclusion.

Add documentation to make the test a bit clearer.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Michael Shuey <shuey@purdue.edu>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Joe Perches 33acb54a43 checkpatch: use $String consistently
String detection where a source line with a string constant is converted
can either have an X or a space.

Some of the string detection regexes do not allow the space character, but
there is a handy $String variable that does.

Convert the remaining uses of string detection regexes to use the $String
variable to reduce possible false negatives.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Alex Dowad 485ff23ed2 checkpatch: make types found in a source file/patch local
checkpatch uses various cues in its input patches and files to discover
the names of user-defined types and modifiers.  It then uses that
information when processing expressions to discover potential style
issues.

Unfortunately, in rare cases, this means that checkpatch may give
different results if you run it on several input files in one execution,
or one by one!

The reason is that it may identify a type (or something that looks like a
type) in one file, and then carry this information over when processing a
different file.

For example, drivers/staging/media/bcm2048/radio-bcm2048.c contains this
line (in a macro):

	size value;

and drivers/staging/media/davinci_vpfe/vpfe_video.c has this line:

	while (size * *nbuffers > vpfe_dev->video_limit)

If checkpatch processes these 2 files in a single command like:
	./scripts/checkpatch.pl -f $file1 $file2
the (spurious) "size" type detected in the first file will cause it to flag
the second file for improper use of the pointer dereference operator.

To fix this, store types and modifiers found in a file in separate arrays
from built-in ones, and reset the arrays of types and modifiers found in
files at the beginning of each new source file.

Signed-off-by: Alex Dowad <alexinbeijing@gmail.com>
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Joe Perches e6176fa472 checkpatch: add --strict warning for c99 fixed size typedefs : int<size>_t
Using declarations like u_int16_t in kernel code is not preferred.

Suggest the kernel sized types instead of the c99 types when not in the
uapi directory.

Add a $typeC99Typedefs variable for the types to check and neaten the
other typedef variables.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Joe Perches cb426e99ff checkpatch: check for uncommented waitqueue_active()
Linus sayeth:

: Pretty much every single time people use this "if
: (waitqueue_active())" model, it tends to be a bug, because it means
: that there is zero serialization with people who are just about to go
: to sleep. It's fundamentally racy against all the "wait_event()" loops
: that carefully do memory barriers between testing conditions and going
: to sleep, because the memory barriers now don't exist on the waking
: side.
:
: So I'm making a new rule: if you use waitqueue_active(), I want an
: explanation for why it's not racy with the waiter. A big comment about
: the memory ordering, or about higher-level locks that are held by the
: caller, or something.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-25 17:00:41 -07:00
Joe Perches 5129e87cb8 checkpatch: fix "GLOBAL_INITIALISERS" test
Commit d5e616fc1c ("checkpatch: add a few more --fix corrections")
broke the GLOBAL_INITIALISERS test with bad parentheses and optional
leading spaces.

Fix it.

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Bandan Das <bsd@makefile.in>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-10 16:43:43 -07:00
Joe Perches e0df7e1fae checkpatch: avoid "spaces required around that ':'" false positive
Since commit 1f65f947a6 ("checkpatch: add checks for question mark and
colon spacing") back in 2008, checkpatch has reported false positive for
asm volatile uses of "::" checkpatch thinks colons should always have
spaces around it.

Add an exception for colons with colons on either side for this valid asm
volatile (and c++) use.

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Yehuda Yitschak <yehuday@marvell.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:59 -04:00
Joe Perches 323b267faf checkpatch: fix --fix use with a patch of multiple files
If a patch touches multiple files, the --fix and --fix-inplace option
doesn't keep the proper line count and makes the new patch file not able
to be applied via bad offset line numbers when lines are added or deleted
by the --fix option.

Dunno how that extra backslash snuck in there.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:58 -04:00
Andy Lutomirski 91c9afaf97 checkpatch.pl: new instances of ENOSYS are errors
ENOSYS means that a nonexistent system call was called.  We have a
bad habit of using it for things like invalid operations on
otherwise valid syscalls.  We should avoid this in new code.

Pervasive incorrect usage of ENOSYS came up at the kernel summit ABI
review discussion.  Let's see if checkpatch can help.

I'll submit a separate patch for include/uapi/asm-generic/errno.h.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:58 -04:00
Joe Perches c17893c740 checkpatch: add a test for const with __read_mostly uses
const objects shouldn't be __read_mostly.  They are read-only.

Marking these objects as __read_mostly causes section conflicts with LTO
linking.

So add a test to try to avoid this issue.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:58 -04:00
Sam Bobroff d7fe8065ad checkpatch: improve operator spacing check
Code such as:
       x = timercmp(&now, &end, <);
Will currently trigger a checkpatch error. e.g.

ERROR: spaces required around that '<'

This is because the "Ignore operators passed as parameters" check looks
only for a comma following the operator.  Improve the check by also
looking for a close parenthesis.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:58 -04:00
Joe Perches b598b67060 checkpatch: add 'Prefer ARRAY_SIZE" test
Add a test for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo).

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:58 -04:00
Joe Perches 6d07d01b62 checkpatch: add uart_ops to normally const structs
Add another struct to the list of normally const struct types

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:58 -04:00
Joe Perches 29a3c46673 checkpatch: add #define foo "string" long line exception
There are #defines with long string constants like:
	#define foo "some really long string > 80 columns"
Add a long line exception for them.

Miscellanea:

Use the $String variable for slightly better readability

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Madalin-Cristian Bucur <madalin.bucur@freescale.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:57 -04:00
Joe Perches 2a076f40d8 checkpatch, SubmittingPatches: suggest line wrapping commit messages at 75 columns
Commit messages lines are sometimes overly long.

Suggest line wrapping at 75 columns so the default git commit log
indentation of 4 plus the commit message text still fits on an 80 column
screen.

Add a checkpatch test for long commit messages lines too.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Ian Morris <ipm@chirality.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:57 -04:00
Fabian Frederick 0e212e0a72 checkpatch: don't ask for asm/file.h to linux/file.h unconditionally
Currently checkpatch warns when asm/file.h is included and linux/file.h
exists.  That conversion can be made when linux/file.h includes asm/file.h
which is not always the case.(See signal.h)

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Cc: Andy Whitcroft <apw@canonical.com>
Acked-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:57 -04:00
Joe Perches ab7e23f344 checkpatch: add test for repeated const uses
Using 'const <type> const *' is generally meant to be written 'const
<type> * const'.

Add a test for the miswritten form.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:57 -04:00
Joe Perches f34e4a4f97 checkpatch: improve return negative errno check
Add a few conditions to the test to find
	return (ERRNO);

Make the output message a bit less cryptic too.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:57 -04:00
Joe Perches b392c64f59 checkpatch: match more world writable permissions
Currently checkpatch will fuss if one uses world writable settings in
debugfs files and DEVICE_ATTR uses by testing S_IWUGO but not testing
S_IWOTH, S_IRWXUGO or S_IALLUGO.

Extend the check to catch all cases exporting world writable permissions
including octal values.

[akpm@linux-foundation.org: remove stray $]
Signed-off-by: Joe Perches <joe@perches.com>
Original-patch-by: Nicholas Mc Guire <hofrat@osadl.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:57 -04:00
Joe Perches ebfd7d6237 checkpatch: add optional --codespell dictionary to find more typos
If a codespell dictionary exists, use it if desired.  default is off,
maybe it could be turned on later.

codespell's dictionary format allows multiple possible corrections, ignore
that for now and only use the first suggestion.

Also add \b to spelling test so that consecutive misspelled words
are found properly.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Masanari Iida <standby24x7@gmail.com>
Cc: Lucas De Marchi <lucas.de.marchi@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:57 -04:00
Joe Perches 66d7a382cb checkpatch: add spell checking of email subject line
Only commit log and patch additions are checked for typos and spelling
errors currently.  Add a check of the email subject line too.

Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
Tested-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:56 -04:00
Joe Perches 6ab3a9701e checkpatch: improve "no space is necessary after a cast" test
The "no space is necessary after a cast" sizeof exclusion doesn't work
properly.

The test reports a false positive for code like:

	BUILD_BUG_ON(sizeof(struct batadv_bla_claim_dst) != 6);

Make it work, simplify the exclusions, and add some comments.

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:03:56 -04:00
Joe Perches 0f3c5aab5e checkpatch: add of_device_id to structs that should be const
Uses of struct of_device_id are most commonly const.

Suggest using it as such.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:40 -08:00
Joe Perches a2fe16b9d8 checkpatch: try to avoid poor patch subject lines
Naming the tool that found an issue in the subject line isn't very useful.
 Emit a warning when a common tool (currently checkpatch, sparse or
smatch) is in the subject line.

Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:40 -08:00
Joe Perches 19c146a64c checkpatch: make sure a commit reference description uses parentheses
The preferred style for a commit reference in a commit log is:

    commit <foo> ("<title line>")

A recent commit removed this check for parentheses.  Add it back.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:40 -08:00
Joe Perches d2e025f364 checkpatch: add --strict test for spaces around arithmetic
Some prefer code to have spaces around arithmetic so instead of:
        a = b*c+d;
suggest
        a = b * c + d;

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:40 -08:00
Joe Perches 101ee6802a checkpatch: neaten printk_ratelimited message position
Just neatening...

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:40 -08:00
Joe Perches 43f7fe52a8 checkpatch: improve "no space necessary after cast" test
Code like:
	if (a < sizeof(<type>) &&
and
	{ .len = sizeof(<type>) },

incorrectly emits that warning, so add more exceptions to avoid
the warning.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:40 -08:00
Heba Aamer caac1d5fdd checkpatch: improve seq_print->seq_puts suggestion
Improve the format specifier test by removing any %% before looking for
any remaining % format specifier.

Signed-off-by: Heba Aamer <heba93aamer@gmail.com>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:40 -08:00
Joe Perches f8e58219dc checkpatch: add ability to --fix unnecessary blank lines around braces
There's a --strict test for these blank lines.

Add the ability to automatically remove them with --fix.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:39 -08:00
Joe Perches 021158b4c7 checkpatch: add types for other OS typedefs
bsd and sysv use different typedefs for unsigned types.

These are in types.h but not in checkpatch, so add them to checkpatch's
ability to know types.

This can avoid false positives for code like:

void foo(void)
{
	int x;
	uint y;

	[...];
}

where checkpatch incorrectly emits a warning for "missing a blank line
after declarations".

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:39 -08:00
Joe Perches b671fde057 checkpatch: add ability to coalesce commit descriptions on multiple lines
If a git commit description is split on consecutive lines, coalesce it
before testing.

This allows:

  commit <foo> ("some long
  description")

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Paul Bolle <pebolle@tiscali.nl>
Tested-by: Paul Bolle <pebolle@tiscali.nl>

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:39 -08:00
Joe Perches acd9362c24 checkpatch: add likely/unlikely comparison misuse test
Add a test for probably likely/unlikely misuses where the comparison is
likely misplaced

	if (likely(foo) > 0)
vs
	if (likely(foo > 0))

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Christoph Jaeger <cj@linux.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:39 -08:00
Joe Perches 0d7835fcaa checkpatch: update git commit message
The git commit message can be confusing,

Try to clarify the message a bit to reduce the confusion when emitted.

Show the correct form using
	Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")'
and if the git commit sha1 is unique, show
the right sha1 to use with the actual title

Signed-off-by: Joe Perches <joe@perches.com>
Original-patch-by: Prarit Bhargava <prarit@redhat.com>
Tested-by: Chris Rorvick <chris@rorvick.com>
Acked-by: Prarit Bhargava <prarit@redhat.com>
Cc: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:39 -08:00
Joe Perches 1b36b201c0 checkpatch: Allow comments in macros tested for single statements
Convert all the comments to spaces before testing for single statement
macros.

Reported-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-13 21:21:39 -08:00