Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1588429 > unrolled thread

[PATCH] checkpatch: Improve EMBEDDED_FUNCTION_NAME test

Started byJoe Perches <joe@perches.com>
First post2017-02-27 01:40 +0100
Last post2017-02-27 01:40 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] checkpatch: Improve EMBEDDED_FUNCTION_NAME test Joe Perches <joe@perches.com> - 2017-02-27 01:40 +0100

#1588429 — [PATCH] checkpatch: Improve EMBEDDED_FUNCTION_NAME test

FromJoe Perches <joe@perches.com>
Date2017-02-27 01:40 +0100
Subject[PATCH] checkpatch: Improve EMBEDDED_FUNCTION_NAME test
Message-ID<tfhw5-632-3@gated-at.bofh.it>
The existing behavior relies on patch context to identify
function declarations.  Add the ability to find function
declarations when there is an open brace in column 1.

This finds function declarations only in specific single
line forms where the function name is on a single line like:

int foo(args...)
{

and

int
foo(args...)
{

It does not recognize function declarations like:

int foo(int bar,
        int baz)
{

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index baa3c7be04ad..550924cc0a66 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3133,6 +3133,17 @@ sub process {
 # check we are in a valid C source file if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c)$/);
 
+# check if this appears to be the start function declaration, save the name
+		if ($sline =~ /^\+\{\s*$/ &&
+		    $prevline =~ /^\+(?:(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*)?($Ident)\(/) {
+			$context_function = $1;
+		}
+
+# check if this appears to be the end of function declaration
+		if ($sline =~ /^\+\}\s*$/) {
+			undef $context_function;
+		}
+
 # check indentation of any line with a bare else
 # (but not if it is a multiple line "if (foo) return bar; else return baz;")
 # if the previous line is a break or return and is indented 1 tab more...
-- 
2.10.0.rc2.1.g053435c

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web