Commit 36c2cf88 authored by David Lechner's avatar David Lechner Committed by Peter Zijlstra
Browse files

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: default avatarDavid Lechner <dlechner@baylibre.com>
Co-developed-by: default avatarFabio M. De Francesco <fabio.m.de.francesco@linux.intel.com>
Signed-off-by: default avatarFabio M. De Francesco <fabio.m.de.francesco@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Link: https://lkml.kernel.org/r/20241001-cleanup-if_not_cond_guard-v1-1-7753810b0f7a@baylibre.com
parent fcc22ac5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment