aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-06-26 13:06:13 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2017-06-30 08:47:57 +0000
commit0ada527bc0f3a408cee510ad9105c551642efc8e (patch)
tree017dc918acc28b060c660b263218925846376dc5
parentdd3c7815a51d6655cdebe324cdc6031ed313edd7 (diff)
sysmo/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: I5ecfc4df5a3fcad3d3ad50bf3dd3db65b694481a
-rw-r--r--src/osmo-bts-sysmo/tch.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 475652e..a12b1a7 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -506,9 +506,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)];
@@ -520,6 +518,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) {