[systemd-devel] clang-format: auto-formatting the code base of systemd
Sebastian Jennen
sebastian.jennen at gmx.de
Fri Jan 4 13:23:20 UTC 2019
Hello systemd team,
there is a pull request currently on systemd, which adds a .clang-format
support, which you can find here:
https://github.com/systemd/systemd/pull/11308
clang-format is an automatic formatter for C code maintained by the llvm
project. It works by tokenizing the source code and reassembling it
under consideration of a single source code style defining file
(.clang-format).
I would like to ask you to participate on a poll on this, as this topic
is controversial.
One the hand this:
- enables programmers to auto-format their patches to comply with the
systemd style
- fixes a couple of minor code inconsistencies
on the other hand this:
- reformats all existing code, which requires review
- break some systemd specific styles which would need be changed some
way (see especially the formatting of table blocks in pull request)
- may annoy some developers, as custom styling is lost
Please also take into consideration the suggested file
tools/format-file.py to extend the clang-format formatting.
Here are poll alternatives in detail, to the question, whether the new
style should be applied:
no
--> speaks for itself
no,
--> but *some* features should be derived from it and applied to the
code base.
That would be tedious and not automatable for future changes. This will
not enable programmers to auto apply the code format to their patches,
as this format would need to be cherry picked for the reformatting
allowed by systemd.
yes
--> but with the wrapper script in tools/format-file.py as mentioned in
the pr to be as close as possible to the existing style
Together with this script the coding style already comes quite close to
the style in systemd right now.
All custom changes in tools/format-file.py have been posted on the llvm
mailing list, so these changes might be implemented upstream so the
custom script might eventually get redundant with a newer version of
clang-format. see request on mailing list here:
http://lists.llvm.org/pipermail/cfe-dev/2019-January/060690.html
yes
--> clang-format should applied in the pure form defined by the
.clang-format file without any wrapper script. This makes the most
changes to the code base, but also makes it most obvious how to
auto-format the code.
Independently source code style file and the wrapper script can further
be changed.
You can find the poll here:
http://www.easypolls.net/poll.html?p=5c2f3659e4b026f889160411
Cheers, Sebastian Jennen
More information about the systemd-devel
mailing list