summaryrefslogtreecommitdiff
path: root/docs/CODING_STYLE.md
diff options
context:
space:
mode:
authorAnita Zhang <the.anitazha@gmail.com>2020-10-27 00:16:25 -0700
committerAnita Zhang <the.anitazha@gmail.com>2020-10-27 00:20:17 -0700
commit800d0802e41087e52df4af0082c3057e9a8dff94 (patch)
tree21dc6123b2df74c17598f72e13c1917a6bd6a0be /docs/CODING_STYLE.md
parent311e3d4637a98f75792ff3a56f1de43e04f9048e (diff)
downloadsystemd-800d0802e41087e52df4af0082c3057e9a8dff94.tar.gz
docs: update coding style for `return (void) func(...)`
Seems that people think it's useful for brevity so make it explicit in the CODING_STYLE.
Diffstat (limited to 'docs/CODING_STYLE.md')
-rw-r--r--docs/CODING_STYLE.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md
index 8f9b2d43b8..851676bc2b 100644
--- a/docs/CODING_STYLE.md
+++ b/docs/CODING_STYLE.md
@@ -318,6 +318,14 @@ layout: default
unlink("/foo/bar/baz");
```
+ When returning from a `void` function, you may also want to shorten the error
+ path boilerplate by returning a function invocation cast to `(void)` like so:
+
+ ```c
+ if (condition_not_met)
+ return (void) log_tests_skipped("Cannot run ...");
+ ```
+
Don't cast function calls to `(void)` that return no error
conditions. Specifically, the various `xyz_unref()` calls that return a
`NULL` object shouldn't be cast to `(void)`, since not using the return value