- if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident){1,2}[=\{]/) {
- if (WARN("SPACING",
- "missing space after $1 definition\n" . $herecurr) &&
- $fix) {
- $fixed[$linenr - 1] =~
- s/^(.\s*(?:typedef\s+)?(?:enum|union|struct)(?:\s+$Ident){1,2})([=\{])/$1 $2/;
- }
- }
-
-# Function pointer declarations
-# check spacing between type, funcptr, and args
-# canonical declaration is "type (*funcptr)(args...)"
- 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;
-
-# the $Declare variable will capture all spaces after the type
-# so check it for a missing trailing missing space but pointer return types
-# don't need a space so don't warn for those.
- my $post_declare_space = "";
- if ($declare =~ /(\s+)$/) {
- $post_declare_space = $1;
- $declare = rtrim($declare);
- }
- if ($declare !~ /\*$/ && $post_declare_space =~ /^$/) {
- WARN("SPACING",
- "missing space after return type\n" . $herecurr);
- $post_declare_space = " ";
- }
-
-# unnecessary space "type (*funcptr)(args...)"
-# This test is not currently implemented because these declarations are
-# equivalent to
-# int foo(int bar, ...)
-# and this is form shouldn't/doesn't generate a checkpatch warning.
-#
-# 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 arguments\n" . $herecurr);
- }
-
- if (show_type("SPACING") && $fix) {
- $fixed[$linenr - 1] =~
- s/^(.\s*)$Declare\s*\(\s*\*\s*$Ident\s*\)\s*\(/$1 . $declare . $post_declare_space . '(*' . $funcname . ')('/ex;
- }