From: Dr. David von Oheimb Date: Mon, 16 Jun 2025 14:43:03 +0000 (+0200) Subject: check-format.pl: prevent false positive on typedef with space and '(' after type... X-Git-Tag: openssl-3.6.0-alpha1~595 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a3809f7056b78031e72fc4e90eec3e708ca27e1;p=thirdparty%2Fopenssl.git check-format.pl: prevent false positive on typedef with space and '(' after type name Reviewed-by: Neil Horman Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27836) --- diff --git a/util/check-format-test-negatives.c b/util/check-format-test-negatives.c index 33abf002153..b813e5548f2 100644 --- a/util/check-format-test-negatives.c +++ b/util/check-format-test-negatives.c @@ -296,6 +296,7 @@ const OPTIONS passwd_options[] = { {NULL} }; +typedef bool (*LOG_cb_t)(int lineno, severity level, const char *msg); typedef * d(int) x; typedef (int) diff --git a/util/check-format.pl b/util/check-format.pl index 81b05f9ace2..baa4ab94ef8 100755 --- a/util/check-format.pl +++ b/util/check-format.pl @@ -833,7 +833,8 @@ while (<>) { # loop over all lines of all input files report("space after function/macro name") if $intra_line =~ m/(\w+)\s+\(/ # fn/macro name with space before '(' && !($1 =~ m/^(sizeof|if|else|while|do|for|switch|case|default|break|continue|goto|return|void|char|signed|unsigned|int|short|long|float|double|typedef|enum|struct|union|auto|extern|static|const|volatile|register)$/) # not keyword - && !(m/^\s*#\s*define\s+\w+\s+\(/); # not a macro without parameters having a body that starts with '(' + && !(m/^\s*#\s*define\s+\w+\s+\(/) # not a macro without parameters having a body that starts with '(' + && !(m/^\s*typedef\W/); # not a typedef report("missing space before '{'") if $intra_line =~ m/[^\s{(\[]\{/; # '{' without preceding space or {([ report("missing space after '}'") if $intra_line =~ m/\}[^\s,;\])}]/; # '}' without following space or ,;])} }