[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191030184600.GC18421@kadam>
Date: Wed, 30 Oct 2019 21:46:00 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: 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 Wed, Oct 30, 2019 at 10:27:12AM -0600, shuah wrote:
> On 10/30/19 4:42 AM, Dan Carpenter wrote:
> > On Wed, Oct 30, 2019 at 01:02:11AM -0700, David Gow wrote:
> > > > ERROR: that open brace { should be on the previous line
> > > > #869: FILE: lib/list-test.c:680:
> > > > +static void list_test_list_for_each_entry_reverse(struct kunit *test)
> > > > +{
> > > >
> > > >
> > > > I am seeing these error and warns. As per our hallway conversation, the
> > > > "for_each*" in the test naming is tripping up checkpatch.pl
> > > >
> > > > For now you can change the name a bit to not trip checkpatch and maybe
> > > > explore fixing checkpatch to differentiate between function names
> > > > with "for_each" in them vs. the actual for_each usages in the code.
> > >
> > > Thanks, Shuah.
> > >
> > > Yes, the problem here is that checkpatch.pl believes that anything
> > > with "for_each" in its name must be a loop, so expects that the open
> > > brace is placed on the same line as for a for loop.
> > >
> > > Longer term, I think it'd be nicer, naming-wise, to fix or work around
> > > this issue in checkpatch.pl itself, as that'd allow the tests to
> > > continue to follow a naming pattern of "list_test_[x]", where [x] is
> > > the name of the function/macro being tested. Of course, short of
> > > trying to fit a whole C parser in checkpatch.pl, that's going to
> > > involve some compromises as well.
> >
> > Just make it a black list of the 5 most common for_each macros.
> >
>
> How does black listing work in the context of checkpatch.pl?
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.
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a85d719df1f4..4f10e8c0d285 100755
--- 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);
Powered by blists - more mailing lists