All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] checkpatch: A few corrections and updates
@ 2013-12-26 19:20 Joe Perches
  2013-12-26 19:20 ` [PATCH 1/5] checkpatch: Add tests for function pointer style misuses Joe Perches
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Joe Perches @ 2013-12-26 19:20 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Josh Triplett, Manfred Spraul, Andy Whitcroft, linux-kernel

Joe Perches (5):
  checkpatch: Add tests for function pointer style misuses
  checkpatch: Add a --fix-inplace option
  checkpatch: Improve space before tab --fix option
  checkpatch: check for if's with unnecessary parentheses
  checkpatch: Update the FSF/GPL address check

 scripts/checkpatch.pl | 100 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 92 insertions(+), 8 deletions(-)

-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 12+ messages in thread
* + checkpatch-add-tests-for-function-pointer-style-misuses.patch added to -mm tree
@ 2013-12-26 22:16 akpm
  0 siblings, 0 replies; 12+ messages in thread
From: akpm @ 2013-12-26 22:16 UTC (permalink / raw)
  To: mm-commits, manfred, josh, apw, joe

Subject: + checkpatch-add-tests-for-function-pointer-style-misuses.patch added to -mm tree
To: joe@perches.com,apw@canonical.com,josh@joshtriplett.org,manfred@colorfullife.com
From: akpm@linux-foundation.org
Date: Thu, 26 Dec 2013 14:16:10 -0800


The patch titled
     Subject: checkpatch: add tests for function pointer style misuses
has been added to the -mm tree.  Its filename is
     checkpatch-add-tests-for-function-pointer-style-misuses.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/checkpatch-add-tests-for-function-pointer-style-misuses.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/checkpatch-add-tests-for-function-pointer-style-misuses.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Joe Perches <joe@perches.com>
Subject: checkpatch: add tests for function pointer style misuses

Kernel style uses function pointers in this form:
	"type (*funcptr)(args...)"

Emit warnings when this function pointer form isn't used.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 scripts/checkpatch.pl |   59 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff -puN scripts/checkpatch.pl~checkpatch-add-tests-for-function-pointer-style-misuses scripts/checkpatch.pl
--- a/scripts/checkpatch.pl~checkpatch-add-tests-for-function-pointer-style-misuses
+++ a/scripts/checkpatch.pl
@@ -2798,6 +2798,65 @@ sub process {
 			}
 		}
 
+# Function pointer declarations
+# check spacing between type, funcptr, and args
+# canonical declaration is "type (*funcptr)(args...)"
+#
+# the $Declare variable will capture all spaces after the type
+# so check it for multiple spaces
+		if ($line =~ /^.\s*($Declare)\((\s*)\*(\s*)$Ident(\s*)\)(\s*)\(/) {
+			my $declare = $1;
+			my $pre_pointer_space = $2;
+			my $post_pointer_space = $3;
+			my $funcname = $4;
+			my $post_funcname_space = $5;
+			my $pre_args_space = $6;
+
+			if ($declare !~ /\s$/) {
+				WARN("SPACING",
+				     "missing space after return type\n" . $herecurr);
+			}
+
+# unnecessary space "type  (*funcptr)(args...)"
+			elsif ($declare =~ /\s{2,}$/) {
+				WARN("SPACING",
+				     "Multiple spaces after return type\n" . $herecurr);
+			}
+
+# unnecessary space "type ( *funcptr)(args...)"
+			if (defined $pre_pointer_space &&
+			    $pre_pointer_space =~ /^\s/) {
+				WARN("SPACING",
+				     "Unnecessary space after function pointer open parenthesis\n" . $herecurr);
+			}
+
+# unnecessary space "type (* funcptr)(args...)"
+			if (defined $post_pointer_space &&
+			    $post_pointer_space =~ /^\s/) {
+				WARN("SPACING",
+				     "Unnecessary space before function pointer name\n" . $herecurr);
+			}
+
+# unnecessary space "type (*funcptr )(args...)"
+			if (defined $post_funcname_space &&
+			    $post_funcname_space =~ /^\s/) {
+				WARN("SPACING",
+				     "Unnecessary space after function pointer name\n" . $herecurr);
+			}
+
+# unnecessary space "type (*funcptr) (args...)"
+			if (defined $pre_args_space &&
+			    $pre_args_space =~ /^\s/) {
+				WARN("SPACING",
+				     "Unnecessary space before function pointer name\n" . $herecurr);
+			}
+
+			if (show_type("SPACING") && $fix) {
+				$fixed[$linenr - 1] =~
+				    s/^(.\s*$Declare)\(\s*\*\s*($Ident)\s*\)\s*\(/rtrim($1) . " " . "\(\*$2\)\("/ex;
+			}
+		}
+
 # check for spacing round square brackets; allowed:
 #  1. with a type on the left -- int [] a;
 #  2. at the beginning of a line for slice initialisers -- [0...10] = 5,
_

Patches currently in -mm which might be from joe@perches.com are

lib-parserc-add-match_wildcard-function.patch
lib-parserc-put-export_symbols-in-the-conventional-place.patch
dynamic_debug-add-wildcard-support-to-filter-files-functions-modules.patch
dynamic-debug-howtotxt-update-since-new-wildcard-support.patch
printk-cache-mark-printk_once-test-variable-__read_mostly.patch
printk-cache-mark-printk_once-test-variable-__read_mostly-fix.patch
vsprintf-add-%pad-extension-for-dma_addr_t-use.patch
get_maintainer-add-commit-author-information-to-rolestats.patch
test-add-minimal-module-for-verification-testing.patch
test-check-copy_to-from_user-boundary-validation.patch
test-check-copy_to-from_user-boundary-validation-fix.patch
checkpatch-more-comprehensive-split-strings-warning.patch
checkpatch-warn-only-on-space-before-semicolon-at-end-of-line.patch
checkpatch-add-warning-of-future-__gfp_nofail-use.patch
checkpatch-attempt-to-find-missing-switch-case-break.patch
checkpatch-add-tests-for-function-pointer-style-misuses.patch
checkpatch-add-a-fix-inplace-option.patch
checkpatch-improve-space-before-tab-fix-option.patch
checkpatch-check-for-ifs-with-unnecessary-parentheses.patch
checkpatch-update-the-fsf-gpl-address-check.patch
linux-next.patch
softirq-use-ffs-in-__do_softirq.patch
softirq-convert-printks-to-pr_level.patch
softirq-use-const-char-const-for-softirq_to_name-whitespace-neatening.patch
checkpatchpl-check-for-function-declarations-without-arguments.patch


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

end of thread, other threads:[~2013-12-27  1:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-26 19:20 [PATCH 0/5] checkpatch: A few corrections and updates Joe Perches
2013-12-26 19:20 ` [PATCH 1/5] checkpatch: Add tests for function pointer style misuses Joe Perches
2013-12-26 20:07   ` Josh Triplett
2013-12-27  0:58     ` Josh Triplett
2013-12-27  1:25       ` Joe Perches
2013-12-26 19:20 ` [PATCH 2/5] checkpatch: Add a --fix-inplace option Joe Perches
2013-12-26 20:08   ` Josh Triplett
2013-12-26 19:20 ` [PATCH 3/5] checkpatch: Improve space before tab --fix option Joe Perches
2013-12-26 19:20 ` [PATCH 4/5] checkpatch: check for if's with unnecessary parentheses Joe Perches
2013-12-26 20:09   ` Josh Triplett
2013-12-26 19:20 ` [PATCH 5/5] checkpatch: Update the FSF/GPL address check Joe Perches
  -- strict thread matches above, loose matches on Subject: below --
2013-12-26 22:16 + checkpatch-add-tests-for-function-pointer-style-misuses.patch added to -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.