From 7738f5282f8ab4571715f1907fa47360b6b68064 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 29 Jun 2017 11:07:44 +0200 Subject: litecell15/tch.c: Clean up use of empty buffer Make code easier to read and avoid reading first byte of the buffer if size is 0. Change-Id: Ib9ee967c0f42098b3a0569e9d84f23832eb4f2d5 --- src/osmo-bts-litecell15/tch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/osmo-bts-litecell15') diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c index ffc1eb38..8bed695d 100644 --- a/src/osmo-bts-litecell15/tch.c +++ b/src/osmo-bts-litecell15/tch.c @@ -361,9 +361,7 @@ int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg) { GsmL1_Prim_t *l1p = msgb_l1prim(l1p_msg); GsmL1_PhDataInd_t *data_ind = &l1p->u.phDataInd; - uint8_t payload_type = data_ind->msgUnitParam.u8Buffer[0]; - uint8_t *payload = data_ind->msgUnitParam.u8Buffer + 1; - uint8_t payload_len, sid_first[9] = { 0 }; + uint8_t *payload, payload_type, payload_len, sid_first[9] = { 0 }; struct msgb *rmsg = NULL; struct gsm_lchan *lchan = &trx->ts[L1SAP_CHAN2TS(chan_nr)].lchan[l1sap_chan2ss(chan_nr)]; @@ -375,6 +373,9 @@ int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg) chan_nr); return -EINVAL; } + + payload_type = data_ind->msgUnitParam.u8Buffer[0]; + payload = data_ind->msgUnitParam.u8Buffer + 1; payload_len = data_ind->msgUnitParam.u8Size - 1; switch (payload_type) { -- cgit v1.2.3