From 3068d5747ac81caacd3c496920fb509f2fa3a182 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 14 Jan 2012 22:07:59 +0100 Subject: 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. --- include/osmocom/core/msgb.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index ea2ee533..e465ec2b 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -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; } -- cgit v1.2.3