Pau Espin Pedrol has submitted this change and it was merged.

Change subject: sysmo/tch.c: Clean up use of empty buffer
......................................................................


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
---
M src/osmo-bts-sysmo/tch.c
1 file changed, 4 insertions(+), 3 deletions(-)

Approvals:
  Max: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
 {
        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 @@
                        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) {

-- 
To view, visit https://gerrit.osmocom.org/3055
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5ecfc4df5a3fcad3d3ad50bf3dd3db65b694481a
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <[email protected]>
Gerrit-Reviewer: Pau Espin Pedrol <[email protected]>

Reply via email to