Skip to content

Commit

Permalink
cx_errors.h: Add CX_ASSERT macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Chapron committed Jan 23, 2024
1 parent fd35fed commit 6ce2cab
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/cx_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include <stdint.h>
#include "ledger_assert.h"

/**
* Checks the error code of a function.
Expand All @@ -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

Expand Down

0 comments on commit 6ce2cab

Please sign in to comment.