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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 21 Feb 2012 22:09:09 +0000
From:	"Allan, Bruce W" <bruce.w.allan@...el.com>
To:	Joe Perches <joe@...ches.com>, David Miller <davem@...emloft.net>,
	Andy Whitcroft <apw@...dowen.org>,
	Andrew Morton <akpm@...ux-foundation.org>
CC:	"andrei.emeltchenko.news@...il.com" 
	<andrei.emeltchenko.news@...il.com>,
	"linville@...driver.com" <linville@...driver.com>,
	"linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] checkpatch: Add some --strict coding style checks

> -----Original Message-----
> From: linux-kernel-owner@...r.kernel.org [mailto:linux-kernel-
> owner@...r.kernel.org] On Behalf Of Joe Perches
> Sent: Tuesday, February 21, 2012 12:59 PM
> To: David Miller; Andy Whitcroft; Andrew Morton
> Cc: andrei.emeltchenko.news@...il.com; linville@...driver.com; linux-
> wireless@...r.kernel.org; netdev@...r.kernel.org; linux-
> kernel@...r.kernel.org
> Subject: [PATCH] checkpatch: Add some --strict coding style checks
> 
> Argument alignment across multiple lines should
> match the open parenthesis.
> 
> Logical continuations should be at the end of
> the previous line, not the start of a new line.
> 
> These are not required by CodingStyle so make the
> tests active only when using --strict.
> 
> Tested with:
> int foo(void)
> {
> 	if (foo &&
> 	    bar())
> 		baz();
> 
> 	if (foo &&
> 	     bar())
> 		baz();
> 
> 	foo_some_long_function(bar,
> 			       baz);
> 
> 	foo_some_long_function(bar,
> 		baz);
> 
> 	return 0;
> }
> 
> Signed-off-by: Joe Perches <joe@...ches.com>
> ---
>  scripts/checkpatch.pl |   22 ++++++++++++++++++++++
>  1 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index a3b9782..629944e 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1783,6 +1783,28 @@ sub process {
>  			     "please, no space before tabs\n" . $herevet);
>  		}
> 
> +# check for && or || at the start of a line
> +		if ($rawline =~ /^\+\s*(&&|\|\|)/) {
> +			CHK("LOGICAL_CONTINUATIONS",
> +			    "Logical continuations should be on the previous
> line\n" . $hereprev);
> +		}
> +
> +# check multi-line statement indentation matches previous line
> +		if ($prevline =~ /^\+(\t*)(if
> \(|$Ident\().*(\&\&|\|\||,)\s*$/ && $rawline =~ /^\+([ \t]*)/) {
> +			$prevline =~ /^\+(\t*)(if
> \(|$Ident\().*(\&\&|\|\||,)\s*$/;
> +			my $oldindent = $1;
> +			my $if_or_func = $2;
> +			$rawline =~ /^\+([ \t]*)/;
> +			my $newindent = $1;
> +			my $goodindent = $oldindent .
> +					 "\t" x (length($if_or_func) / 8) .
> +					 " "  x (length($if_or_func) % 8);
> +			if ($newindent ne "$goodindent") {
> +				CHK("PARENTHESIS_ALIGNMENT",
> +				    "Alignment should match open
> parenthesis\n" . $hereprev);
> +			}
> +		}
> +
>  # check for spaces at the beginning of a line.
>  # Exceptions:
>  #  1) within comments

This appears to falsely complain about parenthesis alignment in conditional statements with multiple opening parentheses.  For example, these will report a check condition:

	if (test_and_set_bit(nr,
				   addr))
		baz();

	if (!(func_a(x) &&
		func_b(y)))
		baz();

Assuming my stupid mailer will screw up the indentation above, the 'a' in addr in the first example is meant to be immediately below the 'n' in nr, and the two 'f's in func_* are meant to be vertically lined up in the second example.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ