lkml.org 
[lkml]   [2018]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] clang-format: add configuration file
From
Date
On Tue, 2018-03-13 at 22:52 +0100, Miguel Ojeda wrote:
> On Tue, Mar 13, 2018 at 10:00 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> > On Tue, 13 Mar 2018 00:39:52 +0100 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
> > > --- a/Documentation/process/4.Coding.rst
> > > +++ b/Documentation/process/4.Coding.rst
> > > @@ -58,6 +58,12 @@ can never be transgressed. If there is a good reason to go against the
> > > style (a line which becomes far less readable if split to fit within the
> > > 80-column limit, for example), just do it.
> > >
> > > +Note that you can use the clang-format tool to help you with these rules
> > > +and to quickly re-format parts of your code automatically. It is specially
> > > +useful for new files/code and to spot coding style mistakes. It is also
> > > +useful to sort #includes, to align variables or comments, to reflow text
> > > +and other similar tasks.
> >
> > It would be rather helpful to tell people how to invoke clang-format.

clang-format has its drawbacks but at least it is
likely to be improved more in the future.

That is a lot better than Lindent/indent.

Some not kernel-style compliant oddities:

o placements of braces for definitions is like:
static const struct pci_device_id e100_id_table[]
= { INTEL_8255X_ETHERNET_DEVICE(0x1029, 0),
o alignment of block #defines
o alignment of function arguments
o logical tests continuations moved to BOL not EOL
o misalignment of per-line comments
o location of struct/union/enum braces

etc...

After applying Miguel's patch, try it with something like:

$ git ls-files -- "drivers/net/ethernet/intel/*.[ch]" | \
while read file ; do clang-format -i $file ; done

and look at the diff (I used clang-format-5.0.0-3)

\
 
 \ /
  Last update: 2018-03-13 23:29    [W:0.070 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site