mirror of https://gerrit.osmocom.org/libosmocore
msgb_trim(): actually trim to an absolute length, as the comment states
The previous commit introduced a new msgb_trim() but the implementation differed from the specification.
This commit is contained in:
parent
b0f91513cd
commit
3068d5747a
|
@ -319,13 +319,11 @@ static inline void msgb_reserve(struct msgb *msg, int len)
|
||||||
*/
|
*/
|
||||||
static inline int msgb_trim(struct msgb *msg, int len)
|
static inline int msgb_trim(struct msgb *msg, int len)
|
||||||
{
|
{
|
||||||
if (msg->len < len)
|
if (len > msg->data_len)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
msg->len -= len;
|
msg->len = len;
|
||||||
msg->tail -= len;
|
msg->tail = msg->data + len;
|
||||||
if (msg->tail < msg->data)
|
|
||||||
msg->tail = msg->data;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue