lkml.org 
[lkml]   [2018]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: list iterator spacing: clang-format vs checkpatch
On Mon, Oct 8, 2018 at 5:40 PM Joe Perches <joe@perches.com> wrote:
>
> On Mon, 2018-10-08 at 09:31 +0200, Miguel Ojeda wrote:
> > On Mon, Oct 8, 2018 at 4:01 AM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> > > The shiny new .clang-format file lists a number of nice iterators in
> > > the ForEachMacros category, the consequence being that there is a
> > > space between the iterator name and the opening parenthesis. This
> > > strikes me as the right thing to do.
>
> It does not strike me as the right thing to do.
>
> Keeping an exhaustive list current is a continuing
> burden and the list generally goes stale over time.

Indeed, it is not nice. It would be best if clang-format had a special
case for macros before a block (i.e. assuming those are meant to be
"for loop macros"). Alas...

>
> > > However, checkpatch.pl complains about it:
> > >
> > > WARNING: space prohibited between function name and open parenthesis '('
> > > #65: FILE: ratelimiter.c:65:
> > > + hlist_for_each_entry_safe (entry, temp, &table_v4[i], hash) {
> > >
> > > It would seem that .clang-format is right and checkpatch.pl is wrong?
> >
> > Checking quickly, it would seem most of the kernel does not put a
> > space there (a minority does), e.g.:
> >
> > git grep 'list_for_each[a-zA-Z0-9_]* (' | wc -l # 67
> > git grep 'list_for_each[a-zA-Z0-9_]*(' | wc -l # 13892
> >
> > So in that sense, checkpatch.pl is right (even if it is not a function call).
>
> As a general rule, I believe any dominant coding style
> is correct. These things are just a convention.
>
> .clang-format is a work in progress and should be updated
> where possible to reflect the kernel dominant styles.

Ideally, in a handful of years we would have an almost perfect mapping
(and/or agree to dismiss the old style that cannot be easily emulated)
and simply force to pass all code through clang-format in a
(server-side) git hook. One can dream... :-)

>
> > We would probably need to implement SpaceBeforeForEachMacros (or a new
> > option for SpaceBeforeParens). I haven't had the time to look into
> > adding the missing support for the few things that the kernel style
> > requires, sadly, but it is in my TODO list.
>
> Good luck and as you are the .clang_format maintainer,
> I hope you find the time.
>

Thanks a lot! I will try for sure at some point, since coding style
stuff takes a looooot of time from everyone.

Cheers,
Miguel

\
 
 \ /
  Last update: 2018-10-08 18:03    [W:0.063 / U:12.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site