From c5e0f1db92673e7520e42563dff894b211187b28 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 31 Aug 2023 11:39:15 -0700 Subject: til_setup: add another helper for setup_func baking fails This introduces til_setup_free_with_ret_err() which just does the common idiom of: - free the setup - return with err code so all these failure cases can be reduced to just a direct return of calling this function. Simpler version of til_setup_free_with_failed_setting_ret_err(), which could have been reuesed for this by making the settings-related parameters optional... but this way the call sites are less verbose and these are tiny helpers it's harmless. --- src/til_setup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/til_setup.c') diff --git a/src/til_setup.c b/src/til_setup.c index c06614f..d5231a1 100644 --- a/src/til_setup.c +++ b/src/til_setup.c @@ -124,3 +124,14 @@ int til_setup_free_with_failed_setting_ret_err(til_setup_t *setup, til_setting_t return err; } + + +/* another ergonomic helper for setup_funcs to use in res_setup baking */ +int til_setup_free_with_ret_err(til_setup_t *setup, int err) +{ + assert(err < 0); + + til_setup_free(setup); + + return err; +} -- cgit v1.2.1