On 30/10/2019 20.15, Joe Perches wrote: > On Wed, 2019-10-30 at 21:46 +0300, Dan Carpenter wrote: >> Hm... I imagined the checkpatch code a little different in my head but >> this would also work to make it stricter. I doubt it miss very many >> real life style problems. > > Well, doubts vs reality... > >> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > [] >> @@ -3607,7 +3607,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|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) { >> + if ($line =~ /(.*)\b((?:if|while|for|switch|(?:list|hlist)_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); > > So - nak How about changing the check so it only matches the if/while/for/*for_each*/ thing when it's the first thing on a line _and_ has non-trivial whitespace in front. Then a function declaration as static void test_for_each() { would not fire, nor would it if it were written in the other common style static void test_for_each() { ? Maybe there'd still be a problem at the call-sites test_for_each(); this_is_not_indented; but the ending semi-colon should actually make it appear as a loop with an empty body (though that in itself might fire a different warning, dunno if checkpatch has that kind of warnings). But in any case the above should remove _some_ false positives. Rasmus