[PATCH] checkpatch: Fix function pointers in blank line needed after declarations test

From: Joe Perches
Date: Fri Jun 06 2014 - 14:33:23 EST


Add a function pointer declaration check to the
test for blank line needed after declarations.

Reported-by: Bruce W Allan <bruce.w.allan@xxxxxxxxx>
Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
On Fri, 2014-06-06 at 17:23 +0000, Allan, Bruce W wrote:
> > WARNING: Missing a blank line after declarations
> > #318: FILE: drivers/crypto/qat/qat_common/adf_accel_devices.h:140:
> > + struct adf_hw_device_class *dev_class;
> > + uint32_t (*get_accel_mask)(uint32_t fuse);
>
> This one is a false positive from checkpatch

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 010b18e..f4b8911 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2295,6 +2295,8 @@ sub process {
if ($sline =~ /^\+\s+\S/ && #Not at char 1
# actual declarations
($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
+ # function pointer declarations
+ $prevline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
# foo bar; where foo is some local typedef or #define
$prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
# known declaration macros
@@ -2307,6 +2309,8 @@ sub process {
$prevline =~ /(?:\{\s*|\\)$/) &&
# looks like a declaration
!($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
+ # function pointer declarations
+ $sline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
# foo bar; where foo is some local typedef or #define
$sline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
# known declaration macros


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/