From 6ce2cabd7efa5a2e12fc8e69e9d95939fac554c8 Mon Sep 17 00:00:00 2001 From: Xavier Chapron Date: Tue, 23 Jan 2024 14:40:20 +0100 Subject: [PATCH] cx_errors.h: Add CX_ASSERT macro --- include/cx_errors.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/cx_errors.h b/include/cx_errors.h index a2b260612..b409ec899 100644 --- a/include/cx_errors.h +++ b/include/cx_errors.h @@ -6,6 +6,7 @@ #pragma once #include +#include "ledger_assert.h" /** * Checks the error code of a function. @@ -32,6 +33,15 @@ } \ } while (0) +/** + * Checks the error code of a function and assert in case of error. + */ +#define CX_ASSERT(call) \ + do { \ + cx_err_t _assert_err = call; \ + LEDGER_ASSERT(!_assert_err, "err 0x%X <%s>", _assert_err, #call); \ + } while (0) + /** Success. */ #define CX_OK 0x00000000