fix false positive of check-format.pl regarding '#if' on preceding line; extend negat...
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Tue, 10 Mar 2020 07:12:57 +0000 (08:12 +0100)
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>
Wed, 18 Mar 2020 12:43:36 +0000 (13:43 +0100)
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/11285)

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

index c9f781e06b385e7ca914d82642067478b6a6356d..35cbd75ba39da25255cc452a38a8fc094dec7a40 100644 (file)
@@ -113,7 +113,46 @@ int f(void) /*
         5;
     else
         6;
+
+    if (1) {
+        if (2) {
+        case MAC_TYPE_MAC:
+            {
+                EVP_MAC_CTX *new_mac_ctx;
+
+                if (ctx->pkey == NULL)
+                    return 0;
+            }
+            break;
+        default:
+            /* This should be dead code */
+            return 0;
+        }
+    }
+    if (expr_line1
+        == expr_line2
+            && expr_line3) {
+        c1;
+    } else {
+        c;
+        d;
+    }
+    if (expr_line1
+        == expr_line2
+            && expr_line3)
+        hanging_stmt;
 }
+
+const OPTIONS passwd_options[] = {
+    {"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
+#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
+    {"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
+#endif
+    OPT_R_OPTIONS,
+
+    {NULL}
+};
+
 typedef * d(int)
     x;
 typedef (int)
index a0b493e600f9ba3139e3d3821e42a982fba69e50..b7c28f15ef4efd4dd63b399637e69951b255c646 100755 (executable)
@@ -1001,7 +1001,7 @@ while (<>) { # loop over all lines of all input files
     # check for opening brace after if/while/for/switch/do not on same line
     # note that "no '{' on same line after '} else'" is handled further below
     if (/^[\s@]*{/ && # leading '{'
-        $line_before > 0 &&
+        $line_before > 0 && !($contents_before_ =~ m/^\s*#/) && # not preprocessor directive '#if
         (my ($head, $mid, $tail) = ($contents_before_ =~ m/(^|^.*\W)(if|while|for|switch|do)(\W.*$|$)/))) {
         my $brace_after  = $tail =~ /^[\s@]*{/; # any whitespace or comments then '{'
         report("'{' not on same line as preceding '$mid'") if !$brace_after;