]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
check-format.pl: fix false positive on 'for(;; stmt)'
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Tue, 12 Jul 2022 22:05:48 +0000 (00:05 +0200)
committerHugo Landau <hlandau@openssl.org>
Wed, 20 Jul 2022 06:30:28 +0000 (07:30 +0100)
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18789)

util/check-format-test-negatives.c
util/check-format.pl

index 4d925572c408ee3dd4ff6f631752b1bfcdbbc3b9..58a1f59e6c5424fe8a1884d71d4f2b93e3b28afe 100644 (file)
@@ -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 ';' */
 
index 705455020dfe0ea4bebf067c5d6edec0fedb86d3..9fcebb438233cd9ea80dcf91f3b30688200d0951 100755 (executable)
@@ -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