[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC] xen: Add .astylerc for automated style-formatting



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.

Signed-off-by: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
---
 .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>
-- 
2.20.1


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.