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] [day] [month] [year] [list]
Date:	Fri, 18 Jul 2014 13:39:32 -0700
From:	Joe Perches <joe@...ches.com>
To:	Gregory Fong <gregory.0xf0@...il.com>
Cc:	Andy Whitcroft <apw@...onical.com>,
	Brian Norris <computersforpeace@...il.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] checkpatch.pl: 1-tab relative indent for
 conditionals/blocks

On Fri, 2014-07-18 at 12:40 -0700, Gregory Fong wrote:
> The following would incorrectly pass checkpatch:
> 
> void foo(void)
> {
>         if (a) {
>                 something;
>                 somethingelse;
>         } else {
>                         messed_up_indentation;
>                 }
> }
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2606,6 +2607,7 @@ sub process {
>  			#print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
>  
>  			if ($check && (($sindent % 8) != 0 ||
> +			    ((($sindent - $indent) / 8) > 1) ||
>  			    ($sindent <= $indent && $s ne ''))) {
>  				WARN("SUSPECT_CODE_INDENT",
>  				     "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");

This might be better testing only tab indented lines like:

	if ($check &&
	    length($prevtabindent) + 1 != length($tabindent))

It'd also be useful to check non-conditional, non-blank
after decommenting code lines so that a block like:

static bool func(void)
{
	bool b;
		/* comment about something */
		int a[2] = foo();

		b = a[0] == a[1];

	/* ready to return */
	return b;
}

emits a couple of "suspect code indent" warnings.
One on int a[2], another on return b.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists