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.
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index ea2ee53..e465ec2 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -319,13 +319,11 @@
*/
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;
}