mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 12:28:11 +02:00
CONTRIBUTING: update "Coding Style" section
This commit is contained in:
parent
5f0ddaa610
commit
e0cdbd733b
1 changed files with 18 additions and 11 deletions
|
|
@ -69,8 +69,24 @@ $ git config --add 'blame.ignoreRevsFile' '.git-blame-ignore-revs'
|
||||||
|
|
||||||
### Style
|
### Style
|
||||||
|
|
||||||
Since our coding style is entirely automated, the following are just
|
As we use clang-format, our style is in parts determined by the tool.
|
||||||
some details of the style we use:
|
Run the tool to format the code. See the earlier point.
|
||||||
|
|
||||||
|
The formatting tool cannot cover all questions. The most important rule is
|
||||||
|
to mimic the existing code and *imitate the surrounding style*.
|
||||||
|
|
||||||
|
In general, we require to build without compiler warnings, for the warnings
|
||||||
|
that we enable. Our language is C11 with some GCC-isms (like typeof(),
|
||||||
|
expression statements, cleanup attribute). In practice, we support various versions
|
||||||
|
of GCC and clang. The supported C "dialect", compilers and libc are those that we
|
||||||
|
can practically build and test in our CI. We don't target a theoretical, pure C11/POSIX
|
||||||
|
standard or a libc/compiler that we cannot test.
|
||||||
|
Patches for making NetworkManager more portable are welcome, if there is a
|
||||||
|
practical use and checked by CI. Glibc and musl libc are supported.
|
||||||
|
|
||||||
|
We follow a mixture of [glib's](https://developer.gnome.org/documentation/guidelines/programming/coding-style.html)
|
||||||
|
and [systemd's](https://github.com/systemd/systemd/blob/main/docs/CODING_STYLE.md) style, which already have extensive
|
||||||
|
guidelines. Following there are a few noteworthy points.
|
||||||
|
|
||||||
* Use cleanup functions (`gs_free`, `gs_*`, `nm_auto*`) to let a stack
|
* Use cleanup functions (`gs_free`, `gs_*`, `nm_auto*`) to let a stack
|
||||||
variable own a resource instead of explicit free. Combine them with
|
variable own a resource instead of explicit free. Combine them with
|
||||||
|
|
@ -104,15 +120,6 @@ some details of the style we use:
|
||||||
* Always use curly braces for blocks that span multiple lines. For single lines
|
* Always use curly braces for blocks that span multiple lines. For single lines
|
||||||
the braces may be omitted, but are not prohibited.
|
the braces may be omitted, but are not prohibited.
|
||||||
|
|
||||||
Additionally, we require to build without compiler warnings for the warnings
|
|
||||||
that we enable. Also, our language is C11 with some GCC-isms (like typeof(),
|
|
||||||
expression statements, cleanup attribute). In practice, we support various versions
|
|
||||||
of GCC and clang. The supported C "dialect", compilers and libc are those that we
|
|
||||||
can practically build and test in our CI. We don't target a theoretical, pure C11/POSIX
|
|
||||||
standard or a libc/compiler that we cannot test.
|
|
||||||
Patches for making NetworkManager more portable are welcome, if there is a
|
|
||||||
practical use and CI tests. Glibc and musl libc are supported.
|
|
||||||
|
|
||||||
### Checkpatch
|
### Checkpatch
|
||||||
|
|
||||||
We have a [checkpatch.pl](contrib/scripts/checkpatch.pl) script, which is
|
We have a [checkpatch.pl](contrib/scripts/checkpatch.pl) script, which is
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue