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
| ||
|
Message-ID: <1405229634.9132.38.camel@joe-AO725> Date: Sat, 12 Jul 2014 22:33:54 -0700 From: Joe Perches <joe@...ches.com> To: Andrew Morton <akpm@...ux-foundation.org> Cc: Andy Whitcroft <apw@...onical.com>, Greg KH <gregkh@...uxfoundation.org>, LKML <linux-kernel@...r.kernel.org> Subject: [PATCH] checkpatch: Add for_each tests to indentation and brace tests All the various for_each loop macros were not tested for trailing brace on the following lines and for bad indentation. Add them. Reported-by: Greg KH <gregkh@...uxfoundation.org> Signed-off-by: Joe Perches <joe@...ches.com> --- On Sat, 2014-07-12 at 16:08 -0700, Greg KH wrote: > The following function: > > $ cat foo.c > > static int foo_init(void) > { > > list_for_each_entry(foo, &foo, list) > { > do_something_foo(foo); > } > > return 0; > } > > Will not be caught by checkpatch: > > $ ./scripts/checkpatch.pl --file foo.c > total: 0 errors, 0 warnings, 11 lines checked > > foo.c has no obvious style problems and is ready for submission. scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d5ac001..5efbf50 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2698,7 +2698,7 @@ sub process { # if/while/etc brace do not go on next line, unless defining a do while loop, # or if that brace on the next line is for something else - if ($line =~ /(.*)\b((?:if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) { + if ($line =~ /(.*)\b((?:if|while|for|switch|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) { my $pre_ctx = "$1$2"; my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); @@ -2744,7 +2744,7 @@ sub process { } # Check relative indent for conditionals and blocks. - if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { + if ($line =~ /\b(?:(?:if|while|for|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { ($stat, $cond, $line_nr_next, $remain_next, $off_next) = ctx_statement_block($linenr, $realcnt, 0) if (!defined $stat); -- 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