summaryrefslogtreecommitdiffstats
path: root/util/check-format.pl
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-04-29 09:41:30 +0200
committerDr. David von Oheimb <dev@ddvo.net>2021-05-20 16:29:13 +0200
commitd3fc80abfc71dbe6e74bdf2af09df328380096a8 (patch)
treedc8b4805073f8f030c9c1ee4713157ae371a0144 /util/check-format.pl
parent9ad9002dd5f705d528ae20acb0e1b53767cde3dd (diff)
check-format.pl: Fix false positive on struct/union/enum in func return type
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15077)
Diffstat (limited to 'util/check-format.pl')
-rwxr-xr-xutil/check-format.pl10
1 files changed, 6 insertions, 4 deletions
diff --git a/util/check-format.pl b/util/check-format.pl
index 734022c540..882b38de41 100755
--- a/util/check-format.pl
+++ b/util/check-format.pl
@@ -929,10 +929,12 @@ while (<>) { # loop over all lines of all input files
}
# set $in_typedecl and potentially $hanging_offset for type declaration
- if (!$in_expr && @nested_indents == 0 && # not in expression
- m/(^|^.*\W)(typedef|struct|union|enum)(\W.*|$)$/ &&
- parens_balance($1) == 0) { # not in newly started expression
- # not needed: $keyword_opening_brace = $2 if $3 =~ m/\{/;
+ if (!$in_expr && @nested_indents == 0 # not in expression
+ && m/(^|^.*\W)(typedef|struct|union|enum)(\W.*|$)$/
+ && parens_balance($1) == 0 # not in newly started expression or function arg list
+ && ($2 eq "typedef" || !($3 =~ m/\s*\w++\s*(.)/ && $1 ne "{")) # 'struct'/'union'/'enum' <name> not followed by '{'
+ # not needed: && $keyword_opening_brace = $2 if $3 =~ m/\{/;
+ ) {
$in_typedecl++;
$hanging_offset += INDENT_LEVEL if m/\*.*\(/; # '*' followed by '(' - seems consistent with Emacs C mode
}