diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2022-07-13 00:05:48 +0200 |
---|---|---|
committer | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2022-07-20 13:07:42 +0200 |
commit | 03421456b3eb745b8cdd908a3fcd3014132adf5b (patch) | |
tree | 670841853a5e05572dd8c12b4752f4d5200dfeea /util | |
parent | c4e65dc8a83118e27f27238c846fdffc5e7bb41f (diff) |
check-format.pl: fix false positive on 'for(;; stmt)'
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(cherry picked from commit 4e9fa07121abf3ebaaf7e0367bd9be3a8b273ebf)
Diffstat (limited to 'util')
-rw-r--r-- | util/check-format-test-negatives.c | 4 | ||||
-rwxr-xr-x | util/check-format.pl | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/util/check-format-test-negatives.c b/util/check-format-test-negatives.c index 4d925572c4..58a1f59e6c 100644 --- a/util/check-format-test-negatives.c +++ b/util/check-format-test-negatives.c @@ -70,6 +70,10 @@ int f(void) /* ; for (i = 0; i < 1;) ; + for (;;) + for (; i < n; i++) + for (;; p++) + ; for (;;) ; /* should not trigger: space before ';' */ lab: ; /* should not trigger: space before ';' */ diff --git a/util/check-format.pl b/util/check-format.pl index 705455020d..9fcebb4382 100755 --- a/util/check-format.pl +++ b/util/check-format.pl @@ -677,6 +677,7 @@ while (<>) { # loop over all lines of all input files $intra_line =~ s/\s+$//; # strip any (resulting) space at EOL $intra_line =~ s/(for\s*\([^;]*);;(\))/"$1$2"/eg; # strip trailing ';;' in for (;;) $intra_line =~ s/(for\s*\([^;]+;[^;]+);(\))/"$1$2"/eg; # strip trailing ';' in for (;;) + $intra_line =~ s/(for\s*\();(;)/"$1$2"/eg; # replace leading ';;' in for (;;) by ';' $intra_line =~ s/(=\s*)\{ /"$1@ "/eg; # do not report {SPC in initializers such as ' = { 0, };' $intra_line =~ s/, \};/, @;/g; # do not report SPC} in initializers such as ' = { 0, };' report("space before '$1'") if $intra_line =~ m/[\w)\]]\s+(\+\+|--)/; # postfix ++/-- with preceding space |