[MERGED] osmo-bts[master]: octphy: initalize nmsg only when needed

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jun 28 13:21:52 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: octphy: initalize nmsg only when needed
......................................................................


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(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: If51dc50a9f4bdb4aba62c0ae5fbfac552806f0c0
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list