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:
Harald Welte 2012-01-14 22:07:59 +01:00
parent b0f91513cd
commit 3068d5747a
1 changed files with 3 additions and 5 deletions

View File

@ -319,13 +319,11 @@ static inline void msgb_reserve(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;
msg->len -= len;
msg->tail -= len;
if (msg->tail < msg->data)
msg->tail = msg->data;
msg->len = len;
msg->tail = msg->data + len;
return 0;
}