linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] checkpatch: Miscellaneous cleanups
@ 2015-02-02  4:27 Joe Perches
  2015-02-02  4:27 ` [PATCH 1/5] checkpatch: Improve seq_print->seq_puts suggestion Joe Perches
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Joe Perches @ 2015-02-02  4:27 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Andy Whitcroft, linux-kernel

Heba Aamer (1):
  checkpatch: Improve seq_print->seq_puts suggestion

Joe Perches (4):
  checkpatch: Improve "no space necessary after cast" test
  checkpatch: Neaten printk_ratelimited message position
  checkpatch: Add --strict test for spaces around arithmetic
  checkpatch: Make sure a commit reference description uses parentheses

 scripts/checkpatch.pl | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

-- 
2.1.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] checkpatch: Improve seq_print->seq_puts suggestion
  2015-02-02  4:27 [PATCH 0/5] checkpatch: Miscellaneous cleanups Joe Perches
@ 2015-02-02  4:27 ` Joe Perches
  2015-02-02  4:27 ` [PATCH 2/5] checkpatch: Improve "no space necessary after cast" test Joe Perches
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2015-02-02  4:27 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: Heba Aamer, linux-kernel

From: Heba Aamer <heba93aamer@gmail.com>

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>
---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 059c032..7f1804e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4854,7 +4854,8 @@ sub process {
 # check for seq_printf uses that could be seq_puts
 		if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) {
 			my $fmt = get_quoted_string($line, $rawline);
-			if ($fmt ne "" && $fmt !~ /[^\\]\%/) {
+			$fmt =~ s/%%//g;
+			if ($fmt !~ /%/) {
 				if (WARN("PREFER_SEQ_PUTS",
 					 "Prefer seq_puts to seq_printf\n" . $herecurr) &&
 				    $fix) {
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] checkpatch: Improve "no space necessary after cast" test
  2015-02-02  4:27 [PATCH 0/5] checkpatch: Miscellaneous cleanups Joe Perches
  2015-02-02  4:27 ` [PATCH 1/5] checkpatch: Improve seq_print->seq_puts suggestion Joe Perches
@ 2015-02-02  4:27 ` Joe Perches
  2015-02-02  4:27 ` [PATCH 3/5] checkpatch: Neaten printk_ratelimited message position Joe Perches
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2015-02-02  4:27 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: linux-kernel

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>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7f1804e..a9baaab 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2541,7 +2541,7 @@ sub process {
 			}
 		}
 
-		if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;\({\[\<\>])/ &&
+		if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;:\?\(\{\}\[\<\>]|&&|\|\||\\$)/ &&
 		    (!defined($1) || $1 !~ /sizeof\s*/)) {
 			if (CHK("SPACING",
 				"No space is necessary after a cast\n" . $herecurr) &&
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] checkpatch: Neaten printk_ratelimited message position
  2015-02-02  4:27 [PATCH 0/5] checkpatch: Miscellaneous cleanups Joe Perches
  2015-02-02  4:27 ` [PATCH 1/5] checkpatch: Improve seq_print->seq_puts suggestion Joe Perches
  2015-02-02  4:27 ` [PATCH 2/5] checkpatch: Improve "no space necessary after cast" test Joe Perches
@ 2015-02-02  4:27 ` Joe Perches
  2015-02-02  4:27 ` [PATCH 4/5] checkpatch: Add --strict test for spaces around arithmetic Joe Perches
  2015-02-02  4:27 ` [PATCH 5/5] checkpatch: Make sure a commit reference description uses parentheses Joe Perches
  4 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2015-02-02  4:27 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: linux-kernel

Just neatening...

Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a9baaab..bf23264 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3243,7 +3243,7 @@ sub process {
 # check for uses of printk_ratelimit
 		if ($line =~ /\bprintk_ratelimit\s*\(/) {
 			WARN("PRINTK_RATELIMITED",
-"Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
+			     "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
 		}
 
 # printk should use KERN_* levels.  Note that follow on printk's on the
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] checkpatch: Add --strict test for spaces around arithmetic
  2015-02-02  4:27 [PATCH 0/5] checkpatch: Miscellaneous cleanups Joe Perches
                   ` (2 preceding siblings ...)
  2015-02-02  4:27 ` [PATCH 3/5] checkpatch: Neaten printk_ratelimited message position Joe Perches
@ 2015-02-02  4:27 ` Joe Perches
  2015-02-02  4:27 ` [PATCH 5/5] checkpatch: Make sure a commit reference description uses parentheses Joe Perches
  4 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2015-02-02  4:27 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: linux-kernel

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>
---
 scripts/checkpatch.pl | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bf23264..32bd31c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3689,7 +3689,22 @@ sub process {
 					 $op eq '*' or $op eq '/' or
 					 $op eq '%')
 				{
-					if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
+					if ($check) {
+						if (defined $fix_elements[$n + 2] && $ctx !~ /[EW]x[EW]/) {
+							if (CHK("SPACING",
+								"spaces preferred around that '$op' $at\n" . $hereptr)) {
+								$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
+								$fix_elements[$n + 2] =~ s/^\s+//;
+								$line_fixed = 1;
+							}
+						} elsif (!defined $fix_elements[$n + 2] && $ctx !~ /Wx[OE]/) {
+							if (CHK("SPACING",
+								"space preferred before that '$op' $at\n" . $hereptr)) {
+								$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]);
+								$line_fixed = 1;
+							}
+						}
+					} elsif ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
 						if (ERROR("SPACING",
 							  "need consistent spacing around '$op' $at\n" . $hereptr)) {
 							$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] checkpatch: Make sure a commit reference description uses parentheses
  2015-02-02  4:27 [PATCH 0/5] checkpatch: Miscellaneous cleanups Joe Perches
                   ` (3 preceding siblings ...)
  2015-02-02  4:27 ` [PATCH 4/5] checkpatch: Add --strict test for spaces around arithmetic Joe Perches
@ 2015-02-02  4:27 ` Joe Perches
  4 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2015-02-02  4:27 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: linux-kernel

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>
---
 scripts/checkpatch.pl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 32bd31c..3642b0d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2191,6 +2191,7 @@ sub process {
 			my $case = 1;
 			my $space = 1;
 			my $hasdesc = 0;
+			my $hasparens = 0;
 			my $id = '0123456789ab';
 			my $orig_desc = "commit description";
 			my $description = "";
@@ -2201,10 +2202,12 @@ sub process {
 			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
 			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
 				$orig_desc = $1;
+				$hasparens = 1;
 			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
 				 defined $rawlines[$linenr] &&
 				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
 				$orig_desc = $1;
+				$hasparens = 1;
 			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
 				 defined $rawlines[$linenr] &&
 				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
@@ -2212,12 +2215,13 @@ sub process {
 				$orig_desc = $1;
 				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
 				$orig_desc .= " " . $1;
+				$hasparens = 1;
 			}
 
 			($id, $description) = git_commit_info($orig_commit,
 							      $id, $orig_desc);
 
-			if ($short || $long || $space || $case || ($orig_desc ne $description)) {
+			if ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) {
 				ERROR("GIT_COMMIT_ID",
 				      "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
 			}
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-02  4:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02  4:27 [PATCH 0/5] checkpatch: Miscellaneous cleanups Joe Perches
2015-02-02  4:27 ` [PATCH 1/5] checkpatch: Improve seq_print->seq_puts suggestion Joe Perches
2015-02-02  4:27 ` [PATCH 2/5] checkpatch: Improve "no space necessary after cast" test Joe Perches
2015-02-02  4:27 ` [PATCH 3/5] checkpatch: Neaten printk_ratelimited message position Joe Perches
2015-02-02  4:27 ` [PATCH 4/5] checkpatch: Add --strict test for spaces around arithmetic Joe Perches
2015-02-02  4:27 ` [PATCH 5/5] checkpatch: Make sure a commit reference description uses parentheses Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).