diff options
| author | Jeremy Bicha <jeremy.bicha@canonical.com> | 2022-02-22 16:46:07 -0500 |
|---|---|---|
| committer | Jeremy Bicha <jeremy.bicha@canonical.com> | 2022-02-22 16:46:07 -0500 |
| commit | 297ac7f51b68aaa0e281336e6c6154bb2c913580 (patch) | |
| tree | ff98cec3cc8eeb03b58cfeae184f2da4bfa6c93f /CONTRIBUTING.md | |
| parent | c713c9f47084b639644c0b9a8bb04faa3ccd21e3 (diff) | |
| parent | 7d8baf4ac0480a542f000c1201df85427a22332c (diff) | |
Update to upstream version '1.35.90
Diffstat (limited to 'CONTRIBUTING.md')
| -rw-r--r-- | CONTRIBUTING.md | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f5de7da..246bcdbb 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 @@ -84,6 +100,10 @@ some details of the style we use: * Don't use `GDBusProxy` or `GDBusObjectManager`. Use plain `GDBusConnection`. +* Names in our header files should always have an "nm" prefix (like "nm_", + "NM_", "_nm_", "_nmp_"). Names in source files usually should not have an + "nm" prefix. + * Indent with spaces. (_no_ tabs). * C-style comments @@ -101,14 +121,8 @@ some details of the style we use: - GOOD: `#define MY_CONSTANT 42` - BAD: `static const unsigned myConstant = 42;` -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. +* Always use curly braces for blocks that span multiple lines. For single lines + the braces may be omitted, but are not prohibited. ### Checkpatch |