[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8e8654d4-f81e-be04-7a43-68ff98cdd293@rasmusvillemoes.dk>
Date: Fri, 1 Nov 2019 11:50:07 +0100
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Joe Perches <joe@...ches.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
shuah <shuah@...nel.org>
Cc: David Gow <davidgow@...gle.com>,
Brendan Higgins <brendanhiggins@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Kees Cook <keescook@...omium.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>, kunit-dev@...glegroups.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH linux-kselftest/test v6] lib/list-test: add a test for the
'list' doubly linked list
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
Powered by blists - more mailing lists