summary refs log tree commit diff
path: root/CONTRIBUTING.md
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2022-02-14 19:23:28 +0100
committerMichael Biebl <biebl@debian.org>2022-02-14 19:23:28 +0100
commit2f94dba7385fd0e0ef19a06eb4a2fcf6c43d7946 (patch)
treee2222f5577115985dd52044d2991253403cdd952 /CONTRIBUTING.md
parent88c227d90a6b7b388c5c85d72802a0ca8f05ed5c (diff)
New upstream version 1.35.91 upstream/1.35.91
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r--CONTRIBUTING.md34
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