Review at https://gerrit.osmocom.org/3058
octphy: initalize nmsg only when needed
nmsg is initalized every time the function runs, even when it
is not needed. Move the initalization into the if (msg) body
so that nmsg is only initalized when we really need it.
(Patch by Octasic Inc.)
Change-Id: If51dc50a9f4bdb4aba62c0ae5fbfac552806f0c0
---
M src/osmo-bts-octphy/l1_if.c
1 file changed, 6 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/58/3058/1
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 9b348a9..0efc4bb 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -584,13 +584,14 @@
lchan = get_lchan_by_chan_nr(trx, chan_nr);
- /* create new message */
- nmsg = l1p_msgb_alloc();
- if (!nmsg)
- return -ENOMEM;
-
/* create new message and fill data */
if (msg) {
+ nmsg = l1p_msgb_alloc();
+ if (!nmsg) {
+ LOGP(DL1C, LOGL_FATAL, "L1SAP PH-TCH.req msg alloc
failed\n");
+ return -ENOMEM;
+ }
+
msgb_pull(msg, sizeof(*l1sap));
tOCTVC1_GSM_MSG_TRX_REQUEST_LOGICAL_CHANNEL_DATA_CMD *data_req =
(tOCTVC1_GSM_MSG_TRX_REQUEST_LOGICAL_CHANNEL_DATA_CMD *)
--
To view, visit https://gerrit.osmocom.org/3058
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If51dc50a9f4bdb4aba62c0ae5fbfac552806f0c0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <[email protected]>