diff options
author | Thomas Haller <thaller@redhat.com> | 2022-01-11 14:39:10 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-01-11 15:18:08 +0100 |
commit | e0cdbd733b2dbe4096e8285cc281ac85cf5398b0 (patch) | |
tree | efc227eba1f46a4a1fcba9757d1d02f1455b8030 /CONTRIBUTING.md | |
parent | 5f0ddaa610c45a1dfa309e8fae5e2081ca9656d5 (diff) | |
download | NetworkManager-e0cdbd733b2dbe4096e8285cc281ac85cf5398b0.tar.gz |
CONTRIBUTING: update "Coding Style" section
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r-- | CONTRIBUTING.md | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89c663e8c4..ddd53d181a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,8 +69,24 @@ $ git config --add 'blame.ignoreRevsFile' '.git-blame-ignore-revs' ### Style -Since our coding style is entirely automated, the following are just -some details of the style we use: +As we use clang-format, our style is in parts determined by the tool. +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 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 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 We have a [checkpatch.pl](contrib/scripts/checkpatch.pl) script, which is |