1
0
Fork 0
Commit Graph

284 Commits (23f780c90496eb1cc158e862e7035c8468dfa052)

Author SHA1 Message Date
Joe Perches 23f780c904 checkpatch: improve "no space after cast" test
Some false positives exist on this test.

For instance:
	*va_arg(args, signed char *) = val.s;
or
	memset(foo, 0, sizeof(struct bar *) * baz));

Ignore lines that have an arithmetic operator or assignment
after what appears to be a cast to a pointer "(foo *)".

Add $Arithmetic convenience variable.

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>
2013-07-03 16:07:45 -07:00
Joe Perches 179f8f40fc checkpatch: add a --strict test for comparison to true/false
Comparing to true or false is error prone.

Add tests for the various forms of (foo == true) && (false != bar)
that are only reported with --strict.

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>
2013-07-03 16:07:45 -07:00
Joe Perches 77b9a53a62 checkpatch: don't warn on blank lines before/after braces as often
Check to make sure the blank lines aren't comment lines like:

  bool foo(bool bar)
  {
	/* Don't warn on a leading comment */
	return !bar;
	/* Don't warn on a trailing comment either */
  }

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>
2013-07-03 16:07:44 -07:00
Joe Perches c4a62ef910 checkpatch: add a placeholder to check blank lines before declarations
Figure out first how to determine if this is in a struct declaration or in
a function body before enabling this.

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>
2013-07-03 16:07:44 -07:00
Joe Perches 3cc4b1c3f0 checkpatch: reduce false positive rate of "complex macros"
Allow "#define foo struct.member" without bleating a warning.

This also allows "#define foo bar.baz->qux" and so on.

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>
2013-07-03 16:07:44 -07:00
Joe Perches 9d7a34a513 checkpatch: warn on comparisons to get_jiffies_64()
Comparing get_jiffies_64() is almost always wrong and time_before64 and
time_after64 should be used instead.

Warn on any comparison to get_jiffies_64().

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>
2013-07-03 16:07:44 -07:00
Joe Perches 36ec19390e checkpatch: warn on comparisons to jiffies
Comparing jiffies is almost always wrong and time_before and time_after
should be used instead.

Warn on any comparison to jiffies.

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>
2013-07-03 16:07:44 -07:00
Joe Perches a605e32ebd checkpatch: warn when networking block comment lines don't start with *
Some block comments in network are written as:

	/* block comment line 1
	   block comment line 2
	 */

Emit a warning on the "block comment line 2" because it should be

	/* block comment line 1
	 * block comment line 2
	 */

This warning is only emitted on the second line of a block comment.

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>
2013-07-03 16:07:44 -07:00
Joe Perches fdb4bcd610 checkpatch: improve network block comment test and message
Show the first line of the comment after a line with just /* to better
show where the defective comment style is in the file.

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>
2013-07-03 16:07:44 -07:00
Joe Perches 807bd26c4c checkpatch: remove quote from CamelCase test
Commit be987d9f80 ("checkpatch: improve CamelCase test for Page") added
it but it shouldn't be there.  Must have been my fault.

Make sure that the tested variable doesn't contain a constant.

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>
2013-07-03 16:07:44 -07:00
Joe Perches a640d25cea checkpatch: add --strict preference for p = kmalloc(sizeof(*p)...
Add another test for memory allocation style to follow
Documentation/CodingStyle:

		Chapter 14: Allocating memory

The preferred form for passing a size of a struct is the following:

	p = kmalloc(sizeof(*p), ...);

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>
2013-07-03 16:07:44 -07:00
Joe Perches 95e2c6023b checkpatch: warn when using gcc's binary constant ("0b") extension
The gcc extension for binary constants that start with 0b is only
supported with gcc version 4.3 or higher.

The kernel can still be compiled with earlier versions of gcc, so have
checkpatch emit a warning for these constants.

Restructure checkpatch's constant finding code a bit to support finding
these binary constants.

Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-07-03 16:07:44 -07:00
Joe Perches be79794bc1 checkpatch: change CamelCase test and make it --strict
Do not bleat a message on nominally acceptable CamelCase uses that are
separated by an _ like drm_core_has_MTRR.

CamelCase tests are also a bit noisy against certain types of code
acceptable to some kernel developers.

Make the test applicable only with --strict.

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>
2013-07-03 16:07:43 -07:00
Mugunthan V N 8543ae1296 checkpatch: add Suggested-by as a standard signature
As people started using Suggested-by as standard signature, adding
"Suggested-by" to the standard signature so that checkpatch won't
generate warning when Suggested-by is used in patch signature

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Andy Whitcroft <apw@canonical.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>
2013-04-29 18:28:20 -07:00
Matthijs Kooijman 74c8f4336d checkpatch: only warn for empty lines before closing braces by themselves
This check was intended to catch extra newlines at the end of a function
definition, but it would trigger on any closing brace, including those
of inline functions and macro definitions, triggering false positives.
Now, only closing braces on a line by themselves trigger this check.

Tested with:

$ cat test.h
/* test.h - Test file */

static inline int foo(void) { return 0; }

static inline int bar(void)
{
        return 1;

}

$ ./scripts/checkpatch.pl --strict -f test.h # Before this commit
CHECK: Blank lines aren't necessary before a close brace '}'
+
+static inline int foo(void) { return 0; }

CHECK: Blank lines aren't necessary before a close brace '}'
+
+}

total: 0 errors, 0 warnings, 2 checks, 9 lines checked

$ ./scripts/checkpatch.pl --strict -f test.h # After this commit
CHECK: Blank lines aren't necessary before a close brace '}'
+
+}

total: 0 errors, 0 warnings, 1 checks, 9 lines checked

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
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>
2013-04-29 18:28:20 -07:00
Joe Perches 5646bc71b3 checkpatch: warn on space before semicolon
Make space before semicolon a warning instead of a --strict CHK test.

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>
2013-04-29 18:28:20 -07:00
Joe Perches 04db4d25d9 checkpatch: complain about executable files
Complain about files with an executable bit set that are not in a scripts/
directory and are not type .pl, .py, .awk, or .sh

Based on an initial patch from Stephen.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-29 18:28:20 -07:00
Joe Perches a6962d7273 checkpatch: Prefer seq_puts to seq_printf
Add a check for seq_printf use with a constant format without additional
arguments.  Suggest seq_puts instead.

Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-29 18:28:19 -07:00
Joe Perches 972fdea2e6 checkpatch: add check for reuse of krealloc arg
On Thu, 2013-03-14 at 13:30 +0000, David Woodhouse wrote:
> If krealloc() returns NULL, it *doesn't* free the original. So any code
> of the form 'foo = krealloc(foo, …);' is almost certainly a bug.

So add a check for it to checkpatch.

Signed-off-by: Joe Perches <joe@perches.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-29 18:28:19 -07:00
Joe Perches e942e2c3f7 checkpatch: fix stringification macro defect
Fix checkpatch misreporting defect with stringification macros

ERROR: Macros with complex values should be enclosed in parenthesis
  #27: FILE: arch/arm/include/asm/kgdb.h:41:
  +#define ___to_string(X) #X

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Vincent Stehlé <v-stehle@ti.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-17 16:10:44 -07:00
Joe Perches be987d9f80 checkpatch: improve CamelCase test for Page
Add the ClearPage/SetPage/TestClearPage/TestSetPage variants to the not
reported Page CamelCase 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>
2013-02-27 19:10:08 -08:00
Bruce Allan 37581c28e9 checkpatch: fix USLEEP_RANGE test
Do not test udelay() for a value less than 10usec when passed a variable
instead of a hard-coded number; there is no way for checkpatch to know the
value of the variable.  As it is today, it will complain about variables
with alphanumeric characters plus '_', e.g.  foo_bar, but not variables
with other characters, eg.  foo->bar.

Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Cc: Andy Whitcroft <apw@canonical.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>
2013-02-21 17:22:26 -08:00
Joe Perches 5ce59ae0bc checkpatch: Add check for kcalloc argument order
kcalloc is sometimes misused with the first and second arguments switched.

Same issue with kmalloc_array too.

Bleat if sizeof is the first argument

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-21 17:22:26 -08:00
Joe Perches e8eb3997ce checkpatch: don't emit the CamelCase warning for PageFoo
I'm getting a ton of these:

  WARNING: Avoid CamelCase: <PageTransHuge>
  #140: FILE: mm/migrate.c:1576:
  +       if (PageTransHuge(page) && page_count(page) != 3) {

So exclude anything which starts with "Page".

Tested-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>
2013-02-21 17:22:26 -08:00
Joe Perches 56e77d709d checkpatch: warn on unnecessary __dev<foo> section markings
Get people to stop adding __devinit and __devexit section markings.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Andy Whitcroft <apw@canonical.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-21 17:22:26 -08:00
Joe Perches dc1393130b checkpatch: prefer dev_<level>( to dev_printk(KERN_<LEVEL>
Add YA check to printk style.

dev_<level> uses are functions and generate smaller
object code than dev_printk(KERN_<LEVEL>.

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>
2013-02-21 17:22:26 -08:00
Joe Perches 326b1ffc13 checkpatch: fix $Float creation of match variables
Commit 74349bcced ("checkpatch: add support for floating point
constants") added an unnecessary match variable that caused tests that
used a $Constant or $LvalOrFunc to have one too many matches.

This causes problems with usleep_range, min/max and other extended
tests.

Avoid using match variables in $Float.
Avoid using match variables in $Assignment too.

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>
2013-02-05 20:38:48 +11:00
Joe Perches 495e9d8460 checkpatch: warn on uapi #includes that #include <uapi/...
Avoid specifying internal uapi #include paths with uapi/...  as
userspace should not use and never see that.

Neaten message line wrapping above.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: David Howells <dhowells@redhat.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>
2012-12-20 17:40:20 -08:00
Joe Perches 323c1260ba checkpatch: warn on CamelCase variable names
Store the camelcase variables in a hash and only emit a warning on the
first use of each new variable.

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>
2012-12-17 17:15:19 -08:00
Joe Perches 74349bcced checkpatch: add support for floating point constants
Even though the kernel doesn't support using floating point constants,
add a regex for them.

Support forms like: 0x123p1, 123e-1, 1.23, 1.5e23f

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>
2012-12-17 17:15:19 -08:00
Joe Perches 6b7eaf6e14 checkpatch: find hex constants as a single IDENT
Hexadecimal values are current found in 2 parts.  A hex constant like
0x123456abcdef is found as 0 and then x123456abcdef and later coalesced.

Instead, reverse the order of the 2 searches in $Constant to find 0x
first, then 0 so that the entire hex constant is found all at once.

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>
2012-12-17 17:15:19 -08:00
Joe Perches d1e2ad07e7 checkpatch: add --strict test for switch/default missing break
switch default case is sometimes written as "default:;".  This can cause
new cases added below the default to be defective.

Suggest adding a break; after empty default cases to avoid fallthrough
defects.

Fixed indentation in the other semicolon test above it.

Suggested-by: Peter Senna Tschudin <peter.senna@gmail.com>
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>
2012-12-17 17:15:19 -08:00
Joe Perches 88982fea52 checkpatch: warn when declaring "struct spinlock foo;"
spinlock_t should always be used.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-12-17 17:15:19 -08:00
Joe Perches 0979ae6646 checkpatch: Add --strict messages for blank lines around braces
Blank lines around braces are not unnecessary.  Emit a message on the use
of these blank lines only when using --strict.

int foo(int bar)
{

	something or other....

}

is generally written in the kernel as:

int foo(int bar)
{
	something or other...
}

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>
2012-12-17 17:15:19 -08:00
Joe Perches 481eb486a8 checkpatch: extend line continuation test
Preprocessor directives and asm statements should be allowed to have a
line continuation.

Signed-off-by: Joe Perches <joe@perches.com>
Tested-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-12-17 17:15:19 -08:00
Joe Perches 6cd7f3869c checkpatch: allow control over line length warning, default remains 80
Some projects might want a longer line length so allow a command line
--max-line-length=n control over the long line warnings.  The default line
length is 80.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Constantine Shulyupin <const@makelinux.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>
2012-12-17 17:15:19 -08:00
Andy Whitcroft 03df4b51f3 checkpatch: consolidate if (foo) bar(foo) checks and add debugfs_remove
Consolidate the if (foo) bar(foo) detectors into a single check.  Add
debugfs_remove and family.

Based on a patch by Constantine Shulyupin.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Cc: Constantine Shulyupin <const@MakeLinux.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>
2012-12-17 17:15:19 -08:00
Tao Ma 78e3f1f01d checkpatch: remove reference to feature-removal-schedule.txt
In commit 9c0ece069b ("Get rid of Documentation/feature-removal.txt"),
Linus removes feature-removal-schedule.txt from Documentation, but there
is still some reference to this file.  So remove them.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Acked-by: Andy Whitcroft <apw@canonical.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>
2012-12-17 17:15:19 -08:00
Kees Cook 1ba8dfd17e checkpatch: warn about using CONFIG_EXPERIMENTAL
This config item has not carried much meaning for a while now and is
almost always enabled by default.  As agreed during the Linux kernel
summit, it is being removed.  This will discourage future addition of
CONFIG_EXPERIMENTAL while it is being phased out.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andy Whitcroft <apw@canonical.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>
2012-12-17 17:15:18 -08:00
Joe Perches 5023d3472d checkpatch: warn on unnecessary line continuations
When the previous line is not a line continuation and the current line has
a line continuation but is not a #define, emit a warning.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Peter Hurley <peter@hurleysoftware.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>
2012-12-17 17:15:18 -08:00
Joe Perches c24f9f195e checkpatch: improve network block comment style checking
Some comment styles in net and drivers/net are flagged inappropriately.

Avoid proclaiming inline comments like:
	int a = b;	/* some comment */
and block comments like:
	/*********************
	 * some comment
	 ********************/
are defective.

Tested with
$ cat drivers/net/t.c
/* foo */

/*
 * foo
 */

/* foo
 */

/* foo
 * bar */

/****************************
 * some long block comment
 ***************************/

struct foo {
	int bar;	/* another test */
};
$

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: David Miller <davem@davemloft.net>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-11-09 06:41:46 +01:00
Kees Cook a0a0a7a94c checkpatch: fix name of "MODULE_PARM_DESC"
Fix macro name in checkpatch: s/PARAM/PARM/.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-10-06 03:05:00 +09:00
Joe Perches 0588060074 checkpatch: check networking specific block comment style
In an effort to get fewer checkpatch reviewer corrections, add a
networking specific style test for the preferred networking comment style.

	/* The preferred style for block comments in
	 * drivers/net/... and net/... is like this
	 */

These tests are only used in net/ and drivers/net/

Tested with:

$ cat drivers/net/t.c

/* foo */

/*
 * foo
 */

/* foo
 */

/* foo
 * bar */
$ ./scripts/checkpatch.pl -f drivers/net/t.c
WARNING: networking block comments don't use an empty /* line, use /* Comment...
#4: FILE: net/t.c:4:
+
+/*

WARNING: networking block comments put the trailing */ on a separate line
#12: FILE: net/t.c:12:
+ * bar */

total: 0 errors, 2 warnings, 12 lines checked

Signed-off-by: Joe Perches <joe@perches.com>
Cc: "Allan, Bruce W" <bruce.w.allan@intel.com>
Cc: Andy Whitcroft <apw@canonical.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>
2012-10-06 03:04:59 +09:00
Joe Perches 8f26b8376f checkpatch: update suggested printk conversions
Direct conversion of printk(KERN_<LEVEL>...  to pr_<level> isn't the
preferred conversion when a struct net_device or struct device is
available.

Hint that using netdev_<level> or dev_<level> is preferred to using
pr_<level>.  Add netdev_dbg and dev_dbg variants too.

Miscellaneous whitespace neatening of a misplaced close brace.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
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>
2012-10-06 03:04:59 +09:00
Pasi Savanainen fa64205df9 checkpatch: check utf-8 content from a commit log when it's missing from charset
Check that a commit log doesn't contain UTF-8 when a mail header
explicitly defines a different charset, like

'Content-Type: text/plain; charset="us-ascii"'

Signed-off-by: Pasi Savanainen <pasi.savanainen@nixu.com>
Cc: 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>
2012-10-06 03:04:59 +09:00
Joe Perches ac8e97f8a7 checkpatch: add control statement test to SINGLE_STATEMENT_DO_WHILE_MACRO
Commit b13edf7ff2 ("checkpatch: add checks for do {} while (0) macro
misuses") added a test that is overly simplistic for single statement
macros.

Macros that start with control tests should be enclosed in a do {} while
(0) loop.

Add the necessary control tests to the check.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Andy Whitcroft <apw@canonical.com>
Tested-by: Franz Schrober <franzschrober@yahoo.de>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-21 16:45:02 -07:00
Joe Perches b13edf7ff2 checkpatch: add checks for do {} while (0) macro misuses
These types of macros should not be used for either a single statement
nor should the macro end with a semi-colon.

Add tests for these conditions.

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>
2012-07-30 17:25:17 -07:00
Joe Perches 66c80b6077 checkpatch: Add acheck for use of sizeof without parenthesis
Kernel style uses parenthesis around sizeof.

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>
2012-07-30 17:25:17 -07:00
Joe Perches 4a273195a5 checkpatch: check usleep_range() arguments
usleep_range() shouldn't use the same args for min and max.

Report it when it happens and when both args are decimal and min > max.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Yuval Mintz <yuvalmin@broadcom.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>
2012-07-30 17:25:17 -07:00
Joe Perches ce0338df3c checkpatch: test for non-standard signatures
Warn on non-standard signature styles.

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>
2012-07-30 17:25:17 -07:00