]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
docs: update coding style for `return (void) func(...)` 17438/head
authorAnita Zhang <the.anitazha@gmail.com>
Tue, 27 Oct 2020 07:16:25 +0000 (00:16 -0700)
committerAnita Zhang <the.anitazha@gmail.com>
Tue, 27 Oct 2020 07:20:17 +0000 (00:20 -0700)
Seems that people think it's useful for brevity so make it explicit in
the CODING_STYLE.

docs/CODING_STYLE.md

index 8f9b2d43b8474c042a35a45b7d8f76838aef11d5..851676bc2bda1bdcb0d16083cc0968d41f0daf83 100644 (file)
@@ -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