mirror of https://gerrit.osmocom.org/libosmocore
msgb: assert msgb->lXh to be not NULL
When any of l1h, l2h, l2h or l4h is set to NULL (which is the default for newly allocated message buffers). Then the msgb_lXhlen() functions will return the address value of msgb->tail. This can lead to unexpected results at a later point. We should have an OSMO_ASSERT to catch the problem early. Change-Id: I1795c559f190713ebbabfbabf3453ab77da46a49 Related: OS#5645
This commit is contained in:
parent
486d98404d
commit
d9d62102cc
|
@ -144,6 +144,7 @@ static inline struct msgb *msgb_dequeue_count(struct llist_head *queue,
|
||||||
*/
|
*/
|
||||||
static inline unsigned int msgb_l1len(const struct msgb *msgb)
|
static inline unsigned int msgb_l1len(const struct msgb *msgb)
|
||||||
{
|
{
|
||||||
|
OSMO_ASSERT(msgb->l1h);
|
||||||
return msgb->tail - (uint8_t *)msgb_l1(msgb);
|
return msgb->tail - (uint8_t *)msgb_l1(msgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +157,7 @@ static inline unsigned int msgb_l1len(const struct msgb *msgb)
|
||||||
*/
|
*/
|
||||||
static inline unsigned int msgb_l2len(const struct msgb *msgb)
|
static inline unsigned int msgb_l2len(const struct msgb *msgb)
|
||||||
{
|
{
|
||||||
|
OSMO_ASSERT(msgb->l2h);
|
||||||
return msgb->tail - (uint8_t *)msgb_l2(msgb);
|
return msgb->tail - (uint8_t *)msgb_l2(msgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +170,7 @@ static inline unsigned int msgb_l2len(const struct msgb *msgb)
|
||||||
*/
|
*/
|
||||||
static inline unsigned int msgb_l3len(const struct msgb *msgb)
|
static inline unsigned int msgb_l3len(const struct msgb *msgb)
|
||||||
{
|
{
|
||||||
|
OSMO_ASSERT(msgb->l3h);
|
||||||
return msgb->tail - (uint8_t *)msgb_l3(msgb);
|
return msgb->tail - (uint8_t *)msgb_l3(msgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +183,7 @@ static inline unsigned int msgb_l3len(const struct msgb *msgb)
|
||||||
*/
|
*/
|
||||||
static inline unsigned int msgb_l4len(const struct msgb *msgb)
|
static inline unsigned int msgb_l4len(const struct msgb *msgb)
|
||||||
{
|
{
|
||||||
|
OSMO_ASSERT(msgb->l4h);
|
||||||
return msgb->tail - (uint8_t *)msgb_sms(msgb);
|
return msgb->tail - (uint8_t *)msgb_sms(msgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue