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
This commit is contained in:
Vadim Yanitskiy 2023-02-24 18:27:29 +07:00 committed by fixeria
parent 22ade291ad
commit 7184511754
1 changed files with 1 additions and 1 deletions

View File

@ -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");
}