diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-01-14 22:07:59 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-01-14 22:08:28 +0100 |
commit | 3068d5747ac81caacd3c496920fb509f2fa3a182 (patch) | |
tree | 2acb37a21ba27acc36d9ae3b1838afd6e635c816 /include/osmocom/core | |
parent | b0f91513cd8d06262711e18734cf415f8a17d7a6 (diff) |
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.
Diffstat (limited to 'include/osmocom/core')
-rw-r--r-- | include/osmocom/core/msgb.h | 8 |
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; } |