From: Anita Zhang Date: Tue, 27 Oct 2020 07:16:25 +0000 (-0700) Subject: docs: update coding style for `return (void) func(...)` X-Git-Tag: v247-rc2~51^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F17438%2Fhead;p=thirdparty%2Fsystemd.git 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. --- diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md index 8f9b2d43b84..851676bc2bd 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