mirror of
https://github.com/systemd/systemd
synced 2024-07-22 18:55:10 +00:00
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:
parent
311e3d4637
commit
800d0802e4
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue