diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2022-02-08 12:27:22 +0600 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2022-02-08 12:50:48 +0600 |
commit | 9ac355ad513b3daba6eb392d765e3475d2cc35f9 (patch) | |
tree | f4b6b7220b9de0bb41899c6b9bba78d399646485 /include/osmocom | |
parent | e59e839dd949136d2f1b63c59df141e1b01f4763 (diff) |
core/utils.h: wrap OSMO_ASSERT() with do { ... } while (0)
Using do-while is a common practice for complex macros. This allows
invoking OSMO_ASSERT in simple if-else statements without braces.
Change-Id: I42d9c315c9c30bce828564a63c496ee62e5c1431
Diffstat (limited to 'include/osmocom')
-rw-r--r-- | include/osmocom/core/utils.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 7625da16..182da08d 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -111,9 +111,11 @@ do { \ * the predicate evaluates to false (0). */ #define OSMO_ASSERT(exp) \ +do { \ if (!(exp)) { \ osmo_panic("Assert failed %s %s:%d\n", #exp, __FILE__, __LINE__); \ - } + } \ +} while (0); /* some code invokes OSMO_ASSERT() without the semicolon */ /*! duplicate a string using talloc and release its prior content (if any) * \param[in] ctx Talloc context to use for allocation |