All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tamas K Lengyel <tamas@tklengyel.com>
To: Julien Grall <julien.grall@arm.com>
Cc: Artem Mygaiev <Artem_Mygaiev@epam.com>,
	Lars Kurth <lars.kurth@citrix.com>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Iurii Artemenko <Iurii_Artemenko@epam.com>,
	Jan Beulich <jbeulich@suse.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [Xen-devel] [RFC] xen: Add .astylerc for automated style-formatting
Date: Thu, 18 Jul 2019 09:14:25 -0600	[thread overview]
Message-ID: <CABfawh=DwOP5eQYmMVNF+n-khkbEDFia0eo=JbE0yhCKjV_+8Q@mail.gmail.com> (raw)
In-Reply-To: <119d0edb-cb12-fbad-9e3e-8c0a469983df@arm.com>

On Thu, Jul 18, 2019 at 9:02 AM Julien Grall <julien.grall@arm.com> wrote:
>
> Hi Tamas,
>
> Adding Lars, Artem and Iurii. Iurii has been working on a version for
> clang-format recently.
>
> On 7/18/19 3:43 PM, Tamas K Lengyel wrote:
> > Using astyle (http://astyle.sourceforge.net) can greatly reduce the overhead of
> > manually checking and applying style-fixes to source-code. The included
> > .astylerc is the closest approximation of the established Xen style (including
> > styles not formally spelled out by CODING_STYLE but commonly requested).
> >
> > Checking the comment styles are not included in the automation.
> >
> > Incorporating Xen's exception to the do-while style is only partially possible,
> > thus a change is proposed to the CODING_STYLE of moving the brace from "do {"
> > to the next line.
> >
> > Most of Xen's code-base is non-conforming at the moment: 289 files pass
> > unchanged, 876 have some style issues.
> >
> > Ideally we can slowly migrate the entire code-base to be conforming, thus
> > eliminating the need of discussing and enforcing style issues manually on the
> > mailinglist.
>
> I quite like the idea of an automatic coding style checker. However, it
> is a bit concerning that not even a 1/3 of the files are able to pass
> the coding style you suggest. Could you explain whether this is because
> the files does not already follow Xen coding style or is it just the
> difference with astyle?
>
> What are the main style issues?

Looks like a lot of files that don't follow the Xen coding style
as-is. Alignment issues seem to me to be the most common errors. See
the full diff here:

https://gist.github.com/tklengyel/c5cac14a0d57f119dd7747a1be6fb260

We can perhaps tune some aspects of it we disagree with the astyle
generated style and try to override it. I did my best to make it
conform to the existing Xen style but certainly there could be other
tweaks made to reduce the churn.

> >
> > Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
> > ---
> >   .astylerc    | 14 ++++++++++++++
> >   CODING_STYLE | 18 +++++++++++++++---
> >   2 files changed, 29 insertions(+), 3 deletions(-)
> >   create mode 100644 .astylerc
> >
> > diff --git a/.astylerc b/.astylerc
> > new file mode 100644
> > index 0000000000..bbd1d55ddd
> > --- /dev/null
> > +++ b/.astylerc
> > @@ -0,0 +1,14 @@
> > +style=bsd
> > +suffix=none
> > +align-pointer=name
> > +align-reference=name
> > +indent=spaces=4
> > +max-code-length=80
> > +min-conditional-indent=0
> > +attach-closing-while
> > +remove-braces
> > +indent-switches
> > +break-one-line-headers
> > +keep-one-line-blocks
> > +pad-comma
> > +pad-header
> > diff --git a/CODING_STYLE b/CODING_STYLE
> > index 6cc5b774cf..0b37f7ae4d 100644
> > --- a/CODING_STYLE
> > +++ b/CODING_STYLE
> > @@ -60,8 +60,8 @@ Bracing
> >   -------
> >
> >   Braces ('{' and '}') are usually placed on a line of their own, except
> > -for the do/while loop.  This is unlike the Linux coding style and
> > -unlike K&R.  do/while loops are an exception. e.g.:
> > +for the while-part of do/while loops.  This is unlike the Linux coding style
> > +and unlike K&R.  do/while loops are an exception. e.g.:
> >
> >   if ( condition )
> >   {
> > @@ -77,7 +77,8 @@ while ( condition )
> >       /* Do stuff. */
> >   }
> >
> > -do {
> > +do
> > +{
> >       /* Do stuff. */
> >   } while ( condition );
> >
> > @@ -120,3 +121,14 @@ the end of files.  It should be:
> >    * indent-tabs-mode: nil
> >    * End:
> >    */
> > +
> > +Automated style formatting using astyle
> > +---------------------------------------
> > +
> > +The .astylerc included in the Xen tree incorporates most of Xen's
> > +style requirements, except the formatting of comments.
> > +
> > +The steps to automatically format a file are:
> > +
> > +export ARTISTIC_STYLE_OPTIONS=".astylerc"
> > +astyle <source or header file>
>
> I think you want to provide easy way for the user to install/compile it.
> So there are an higher chance for them to use it.

It is generally included in all major distributions, I just do apt-get
install astyle on debian/ubuntu.

>
> Long-term we probably want to get this hooked to the CI loop.

Indeed. I already do that in my project's CI using Travis and it has
been awesome (https://github.com/tklengyel/drakvuf/blob/master/.travis.yml#L28).

Tamas

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-07-18 15:15 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18 14:43 [Xen-devel] [RFC] xen: Add .astylerc for automated style-formatting Tamas K Lengyel
2019-07-18 15:02 ` Julien Grall
2019-07-18 15:14   ` Tamas K Lengyel [this message]
2019-07-18 15:42     ` Julien Grall
2019-07-18 17:18       ` Tamas K Lengyel
2019-07-19  8:26         ` Julien Grall
2019-07-18 17:22       ` Tamas K Lengyel
2019-07-19  8:35         ` Julien Grall
2019-07-26 14:58           ` Viktor Mitin
2019-07-26 15:12             ` Julien Grall
2019-07-26 15:23               ` Tamas K Lengyel
2019-07-29  7:31               ` Lars Kurth
2019-07-19  9:00         ` Jan Beulich
2019-07-19 13:10           ` Tamas K Lengyel
2019-07-26 14:52         ` Viktor Mitin
2019-07-18 17:25       ` Tamas K Lengyel
2019-07-18 17:32       ` Tamas K Lengyel
2019-07-18 17:38       ` Tamas K Lengyel
2019-07-18 17:48       ` Tamas K Lengyel
2019-07-19  8:43         ` Julien Grall
2019-07-19 13:00           ` Tamas K Lengyel
2019-07-19 13:11             ` Julien Grall
2019-07-19 13:14               ` Tamas K Lengyel
2019-07-19 13:24                 ` Julien Grall
2019-07-19 13:31                   ` Julien Grall
2019-07-19 13:50                     ` Rich Persaud
2019-07-19 14:47                       ` Julien Grall
2019-07-24 12:53                       ` Lars Kurth
2019-07-19 13:52                     ` Tamas K Lengyel
2019-07-26 14:54         ` Viktor Mitin
2019-07-26 14:49       ` Viktor Mitin
2019-07-26 14:57         ` Julien Grall
2019-07-29 12:19         ` Jan Beulich
2019-07-29 12:49           ` Julien Grall
2019-07-29 13:02             ` Jan Beulich
2019-07-31 16:20               ` Viktor Mitin
2019-08-01  7:37                 ` Jan Beulich
2019-08-01 12:16                   ` Viktor Mitin
2019-08-01 12:43                     ` Jan Beulich
2019-08-01 12:50                     ` Juergen Gross
2019-08-02  8:38                       ` Viktor Mitin
2019-08-02  9:23                         ` Juergen Gross
2019-08-02 11:44                           ` Viktor Mitin
2019-08-02 12:57                             ` Jan Beulich
2019-07-18 15:13 ` Jan Beulich
2019-07-18 15:16   ` Tamas K Lengyel
2019-07-26 14:42   ` Viktor Mitin
2019-07-26 14:50     ` Tamas K Lengyel
2019-07-18 17:58 ` Andrew Cooper
2019-07-18 18:34   ` Tamas K Lengyel
2019-07-19  9:03     ` Julien Grall
2019-07-19 13:05       ` Tamas K Lengyel
2019-07-19 13:34         ` Julien Grall
2019-07-19 13:36           ` Tamas K Lengyel
2019-07-19 13:26 ` Rich Persaud
2019-07-26 15:48 ` Viktor Mitin
2019-07-26 15:54   ` Julien Grall
2019-07-29  7:20     ` Viktor Mitin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABfawh=DwOP5eQYmMVNF+n-khkbEDFia0eo=JbE0yhCKjV_+8Q@mail.gmail.com' \
    --to=tamas@tklengyel.com \
    --cc=Artem_Mygaiev@epam.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Iurii_Artemenko@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=lars.kurth@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.