diff --git a/host/libraries/libbladeRF/src/board/bladerf2/common.h b/host/libraries/libbladeRF/src/board/bladerf2/common.h index 0f1380fe..5a88cb41 100644 --- a/host/libraries/libbladeRF/src/board/bladerf2/common.h +++ b/host/libraries/libbladeRF/src/board/bladerf2/common.h @@ -343,6 +343,23 @@ extern char const *bladerf2_state_to_string[4]; } \ } while (0) +/** + * @brief Call a function and goto error if it fails + * + * @param _fn The function + * + * @note `int status` must be declared in the including scope + */ +#define CHECK_STATUS_GOTO(_fn) \ + do { \ + status = _fn; \ + if (status < 0) { \ + log_error("%s: %i failed: %s\n", #_fn, status, \ + bladerf_strerror(status)); \ + goto error; \ + } \ + } while (0) + /** * @brief Call a function and, if it fails, unlock the mutex and return *