cleanup: Add conditional guard helper
Add a new if_not_guard() macro to cleanup.h for handling conditional guards such as mutext_trylock(). This is more ergonomic than scoped_guard() for most use cases. Instead of hiding the error handling statement in the macro args, it works like a normal if statement and allow the error path to be indented while the normal code flow path is not indented. And it avoid unwanted side-effect from hidden for loop in scoped_guard(). Signed-off-by:David Lechner <dlechner@baylibre.com> Co-developed-by:
Fabio M. De Francesco <fabio.m.de.francesco@linux.intel.com> Signed-off-by:
Fabio M. De Francesco <fabio.m.de.francesco@linux.intel.com> Signed-off-by:
Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by:
Dan Williams <dan.j.williams@intel.com> Link: https://lkml.kernel.org/r/20241001-cleanup-if_not_cond_guard-v1-1-7753810b0f7a@baylibre.com
Loading
Please sign in to comment