aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/core/msgb.h8
1 files 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;
}