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

Re: [Xen-devel] Xen checkpatch infrastructure design



Hi Iurii,

I wanted to double check, as we had previously looked into clang-format, and it showed some gaps with what it can be used for in Xen coding styles.  Which is why we tried to get agreement - and got it - to upstream Xen related changes into clang–format

== Indentation: ok ==

[+] Indent using spaces = ok with clang-format

[+] Indent level = 4 spaces = ok with clang-format

[+] Code within blocks is indented by one extra indent level = ok with clang-format

[+] The enclosing braces of a block are indented the same as the code _outside_ the block = ok with clang-format


== Whitespace: partly ok ==

[?] spread out logical statements = so no complete support (to do that we have add spaces before and after parenthesis but they apply to all others parenthesis as well)

[?] spaces are placed between the keyword and the brackets surrounding the condition, between the 40 brackets and the condition itself = same as above

[+] around binary operators (except the structure access operators, '.' and '->') = ok

[-] There should be no trailing white space at the end of lines = no support

== Line length: partly ok ==

[+] Lines should be less than 80 characters in length = ok with clang-format

[-] Split at "sensible places" = no tool can do that

[-] Trailing portions indented = no support in clang-format

[-] User visible strings (e.g., printk() messages) should not be split = no support in clang-format (it splits everything)


== Brackets: partly ok ==

[+] Usually placed on a line of their own = ok

[-] Except for the do/while loop = no support

[-] Brackets should be omitted for blocks with a single statement = no support


== Comments: no support ==

[-] Only C style /* ... */ comments are to be used = no support

[-] Multi-word comments should begin with a capital letter. = no support

[-] Comments containing a single sentence may end with a full stop; = no support

[-] Comments containing several sentences must have a full stop after each sentence = no support

[-] Multi-line comment blocks should start and end with comment markers on separate lines and each line should begin with a leading '*'. = No support


Emacs local variables = no support


I was wondering how you deal with the gaps. I suppose these gaps could possibly be covered in clang-format-diff.py

Of course this info may be out-of-date


Regards

Lars


From: Iurii Artemenko <Iurii_Artemenko@xxxxxxxx>
Date: Monday, 24 July 2017 at 17:55
To: Juergen Gross <jgross@xxxxxxxx>
Cc: Lars Kurth <lars.kurth@xxxxxxxxxx>, Wei Liu <wei.liu2@xxxxxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, Ian Jackson <Ian.Jackson@xxxxxxxxxx>, 'Jan Beulich' <JBeulich@xxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, cardoe <cardoe@xxxxxxxxxx>, Andrii Anisov <Andrii_Anisov@xxxxxxxx>, Lars Kurth <lars.kurth.xen@xxxxxxxxx>
Subject: Re: [Xen-devel] Xen checkpatch infrastructure design

Hello Juergen,


I've started to work on checkpatch-like python script. I make it based on  clang-format-diff.py and it works as pre-commit hook. 


> The easiest way to accomplish that is a file in the repository's root
> directory containing the necessary information. It will be named
> "STYLES" and contains lines in the format:

I will follow this approach.


> Remains the question how to design the style checker itself. It could
> be:
> (a) a monolithic script (perl, python, whatever) being capable of
>    handling all the different coding styles
> (b) a main script checking the patch header and calling a code style
>    specific script for each source file modified by the patch

It seems like specific script for style checking is not needed. Because clang-format tool does style checking by itself.
All we need is just to provide appropriate coding style description file for each.
Clang-format is a bit specific tool, so we can not specify explicitly file with coding style description.
It just looks for a .clang-format file in one of a parent directories of a file being checked.
As we got at least three coding-styles we have to substitute needed file in sources top directory for each check.
It could be done by generating .clang-format file dynamically depending on style/path from the STYLES file.
Another way could be using appropriate symlink on existing .clang-format file which is located somewhere in  tools/clang-format/coding-style-file like:
tools/clang-format/xen-style
tools/clang-format/linux-style
tools/clang-format/xl-style


Regards
Iurii
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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