fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/31495 )


Change subject: gsm: use OSMO_ASSERT() in osmo_iuup_msgb_alloc_c()
......................................................................

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
---
M src/gsm/iuup.c
1 file changed, 27 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/95/31495/1

diff --git a/src/gsm/iuup.c b/src/gsm/iuup.c
index c6a575e..16a6f5e 100644
--- a/src/gsm/iuup.c
+++ b/src/gsm/iuup.c
@@ -191,7 +191,7 @@
 #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");
 }


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/31495
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I53db679728250e0c60ed277efb18142073ffe9c4
Gerrit-Change-Number: 31495
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-MessageType: newchange

Reply via email to