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.
This commit is contained in:
Anita Zhang 2020-10-27 00:16:25 -07:00
parent 311e3d4637
commit 800d0802e4
1 changed files with 8 additions and 0 deletions

View 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