diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2023-02-24 18:27:29 +0700 |
---|---|---|
committer | fixeria <vyanitskiy@sysmocom.de> | 2023-02-27 09:58:46 +0000 |
commit | 7184511754f1bee00507ec3722c12f634eb6e2fd (patch) | |
tree | 93185461830166d70f0b0e792a0fcacc0634f565 | |
parent | 22ade291ad8f90dc5e4581630bfae21bfd1dcdc3 (diff) |
gsm: use OSMO_ASSERT() in osmo_iuup_msgb_alloc_c()
This patch is a preparation for the upcoming change making use of
the built-in static_assert(), which is available since C11.
When using built-in static_assert(), gcc v12.2.1 fails:
iuup.c: In function 'osmo_iuup_msgb_alloc_c':
iuup.c:194:33: error: expression in static assertion is not constant
194 | osmo_static_assert(size > IUUP_MSGB_HEADROOM_MIN_REQUIRED, iuup_msgb_alloc_headroom_bigger);
../../include/osmocom/core/utils.h:86:24: note: in definition of macro 'osmo_static_assert'
86 | static_assert((exp), "(" #exp ") failed")
| ^~~
This one is not really a *static* assert(), because it operates on the
user supplied argument 'size', which is not guaranteed to be an integer
literal. Neither it triggers a compilation failure as expected, nor
does it abort at run-time. It simply does nothing.
Change-Id: I53db679728250e0c60ed277efb18142073ffe9c4
-rw-r--r-- | src/gsm/iuup.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gsm/iuup.c b/src/gsm/iuup.c index c6a575e4..16a6f5e0 100644 --- a/src/gsm/iuup.c +++ b/src/gsm/iuup.c @@ -191,7 +191,7 @@ static inline uint8_t iuup_get_hdr_crc(const uint8_t *data) #define IUUP_MSGB_HEADROOM_MIN_REQUIRED (OSMO_MAX(sizeof(struct osmo_iuup_tnl_prim), sizeof(struct osmo_iuup_rnl_prim)) + (PTR_ALIGNMENT_BYTES - 1)) static inline struct msgb *osmo_iuup_msgb_alloc_c(void *ctx, size_t size) { - osmo_static_assert(size > IUUP_MSGB_HEADROOM_MIN_REQUIRED, iuup_msgb_alloc_headroom_bigger); + OSMO_ASSERT(size > IUUP_MSGB_HEADROOM_MIN_REQUIRED); return msgb_alloc_headroom_c(ctx, size, IUUP_MSGB_HEADROOM_MIN_REQUIRED, "iuup-msgb"); } |