lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 09 Dec 2020 21:25:37 -0800
From:   Joe Perches <joe@...ches.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     LKML <linux-kernel@...r.kernel.org>
Subject: Re: checkpatch

On Wed, 2020-12-09 at 19:13 +0100, Thomas Gleixner wrote:
> Joe,

Hi Thomas.

> the below made it through my filters for some reason so I actually
> looked and immediately wondered why checkpatch.pl did not identify this
> as pure garbage.
> 
>  Original mail is here: lore.kernel.org/r/69cb540a-09d5-4956-b062-071ccded7090@....de
> 
> Can you have a look please? Adding brackets in the middle of the code
> for absolutely no reason is wrong to begin with and then not indenting
> the enclosed code makes it even worse.

Well, maybe something like this, but there are probably some
drawbacks with initializations.
---
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7b086d1cd6c2..057be2cfe118 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4047,6 +4047,25 @@ sub process {
 			}
 		}
 
+# Check open brace and any possible statement indentation
+		if (defined($stat) &&
+		    $stat =~ /^\+([ \t]+)\{[ \t]*\n/) {
+			if (substr($stat, pos($stat), length($1)+1) !~ /^$1\s/) {
+				my $cnt = statement_rawlines($stat);
+				my $herectx = get_stat_here($linenr, $cnt, $here);
+				my @array = split(/\n/, $herectx);
+				$cnt = 0;
+				$herectx = "";
+				foreach my $aline (@array) {
+					$herectx .= $aline . "\n";
+					$cnt++ if ($aline =~ /^\+/);
+					last if ($cnt >= 2);
+				}
+				WARN("OPEN_BRACE",
+				     "A line with only an open brace should start an indented block\n" . $herectx);
+			}
+		}
+
 # Check relative indent for conditionals and blocks.
 		if ($line =~ /\b(?:(?:if|while|for|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|(?:do|else)\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
 			($stat, $cond, $line_nr_next, $remain_next, $off_next) =


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ