[PATCH] osmo-bsc[master]: cosmetic: use fsm pointer from parameter list

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/.

dexter gerrit-no-reply at lists.osmocom.org
Thu Nov 23 13:44:38 UTC 2017


Review at  https://gerrit.osmocom.org/4985

cosmetic: use fsm pointer from parameter list

the parameter list of osmo-fsm callbacks contains a pointer
to the fsm instance. Use this pointer instead of reaching
out for mgcp_ctx->fsm.

Change-Id: I05ff62e7e2de64c2dbf5ea2736f5e58faf16df0b
---
M src/osmo-bsc/osmo_bsc_mgcp.c
1 file changed, 31 insertions(+), 39 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/85/4985/1

diff --git a/src/osmo-bsc/osmo_bsc_mgcp.c b/src/osmo-bsc/osmo_bsc_mgcp.c
index 1bc4c42..f450c11 100644
--- a/src/osmo-bsc/osmo_bsc_mgcp.c
+++ b/src/osmo-bsc/osmo_bsc_mgcp.c
@@ -185,14 +185,13 @@
 	mgcp = mgcp_ctx->mgcp;
 	OSMO_ASSERT(mgcp);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
-		 "fsm-state: %s, fsm-event: %s\n",
+	LOGPFSML(fi, LOGL_DEBUG, "fsm-state: %s, fsm-event: %s\n",
 		 get_value_string(fsm_bsc_mgcp_state_names, fi->state), get_value_string(fsm_evt_names, event));
 
 	rtp_endpoint = mgcp_client_next_endpoint(mgcp);
 	mgcp_ctx->rtp_endpoint = rtp_endpoint;
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
+	LOGPFSML(fi, LOGL_DEBUG,
 		 "CRCX/BTS: creating connection for the BTS side on " "MGW endpoint:%x...\n", rtp_endpoint);
 
 	/* Generate MGCP message string */
@@ -211,14 +210,14 @@
 	OSMO_ASSERT(msg);
 
 	/* Transmit MGCP message to MGW */
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "CRCX/BTS: transmitting MGCP message to MGW...\n");
+	LOGPFSML(fi, LOGL_DEBUG, "CRCX/BTS: transmitting MGCP message to MGW...\n");
 	rc = mgcp_client_tx(mgcp, msg, crcx_for_bts_resp_cb, mgcp_ctx);
 	if (rc < 0) {
 		handle_error(mgcp_ctx, MGCP_ERR_MGW_TX_FAIL);
 		return;
 	}
 
-	osmo_fsm_inst_state_chg(mgcp_ctx->fsm, ST_ASSIGN_PROC, MGCP_MGW_TIMEOUT, MGCP_MGW_TIMEOUT_TIMER_NR);
+	osmo_fsm_inst_state_chg(fi, ST_ASSIGN_PROC, MGCP_MGW_TIMEOUT, MGCP_MGW_TIMEOUT_TIMER_NR);
 }
 
 /* Callback for MGCP-Client: handle response for BTS associated CRCX */
@@ -282,8 +281,7 @@
 	conn = mgcp_ctx->conn;
 	OSMO_ASSERT(conn);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
-		 "fsm-state: %s, fsm-event: %s\n",
+	LOGPFSML(fi, LOGL_DEBUG, "fsm-state: %s, fsm-event: %s\n",
 		 get_value_string(fsm_bsc_mgcp_state_names, fi->state), get_value_string(fsm_evt_names, event));
 
 	switch (event) {
@@ -298,7 +296,7 @@
 	chan_mode = mgcp_ctx->chan_mode;
 	full_rate = mgcp_ctx->full_rate;
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "MGW proceeding assignment request...\n");
+	LOGPFSML(fi, LOGL_DEBUG, "MGW proceeding assignment request...\n");
 	rc = gsm0808_assign_req(conn->conn, chan_mode, full_rate);
 
 	if (rc < 0) {
@@ -329,8 +327,7 @@
 	conn = mgcp_ctx->conn;
 	OSMO_ASSERT(conn);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
-		 "fsm-state: %s, fsm-event: %s\n",
+	LOGPFSML(fi, LOGL_DEBUG, "fsm-state: %s, fsm-event: %s\n",
 		 get_value_string(fsm_bsc_mgcp_state_names, fi->state), get_value_string(fsm_evt_names, event));
 
 	switch (event) {
@@ -346,15 +343,15 @@
 	lchan = mgcp_ctx->lchan;
 	OSMO_ASSERT(lchan);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "BSS has completed the assignment, now prceed with MDCX towards BTS...\n");
+	LOGPFSML(fi, LOGL_DEBUG, "BSS has completed the assignment, now prceed with MDCX towards BTS...\n");
 
 	rtp_endpoint = mgcp_ctx->rtp_endpoint;
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
+	LOGPFSML(fi, LOGL_DEBUG,
 		 "MDCX/BTS: completing connection for the BTS side on " "MGW endpoint:%x...\n", rtp_endpoint);
 
 	addr.s_addr = osmo_ntohl(lchan->abis_ip.bound_ip);
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
+	LOGPFSML(fi, LOGL_DEBUG,
 		 "MDCX/BTS: BTS expects RTP input on address %s:%u\n", inet_ntoa(addr), lchan->abis_ip.bound_port);
 
 	/* Generate MGCP message string */
@@ -377,14 +374,14 @@
 	OSMO_ASSERT(msg);
 
 	/* Transmit MGCP message to MGW */
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "MDCX/BTS: transmitting MGCP message to MGW...\n");
+	LOGPFSML(fi, LOGL_DEBUG, "MDCX/BTS: transmitting MGCP message to MGW...\n");
 	rc = mgcp_client_tx(mgcp, msg, mdcx_for_bts_resp_cb, mgcp_ctx);
 	if (rc < 0) {
 		handle_error(mgcp_ctx, MGCP_ERR_MGW_TX_FAIL);
 		return;
 	}
 
-	osmo_fsm_inst_state_chg(mgcp_ctx->fsm, ST_CRCX_NET, MGCP_MGW_TIMEOUT, MGCP_MGW_TIMEOUT_TIMER_NR);
+	osmo_fsm_inst_state_chg(fi, ST_CRCX_NET, MGCP_MGW_TIMEOUT, MGCP_MGW_TIMEOUT_TIMER_NR);
 }
 
 /* Callback for MGCP-Client: handle response for BTS associated MDCX */
@@ -452,8 +449,7 @@
 	mgcp = mgcp_ctx->mgcp;
 	OSMO_ASSERT(mgcp);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
-		 "fsm-state: %s, fsm-event: %s\n",
+	LOGPFSML(fi, LOGL_DEBUG, "fsm-state: %s, fsm-event: %s\n",
 		 get_value_string(fsm_bsc_mgcp_state_names, fi->state), get_value_string(fsm_evt_names, event));
 
 	switch (event) {
@@ -466,7 +462,7 @@
 
 	rtp_endpoint = mgcp_ctx->rtp_endpoint;
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
+	LOGPFSML(fi, LOGL_DEBUG,
 		 "CRCX/NET: creating connection for the NET side on " "MGW endpoint:%x...\n", rtp_endpoint);
 
 	/* Currently we only have support for IPv4 in our MGCP software, the
@@ -476,7 +472,7 @@
 	 * why we stop here in case some MSC tries to signal IPv6 AoIP
 	 * transport identifiers */
 	if (conn->aoip_rtp_addr_remote.ss_family != AF_INET) {
-		LOGPFSML(mgcp_ctx->fsm, LOGL_ERROR,
+		LOGPFSML(fi, LOGL_ERROR,
 			 "CRCX/NET: endpoint:%x MSC uses unsupported address format in AoIP transport identifier -- aborting...\n",
 			 rtp_endpoint);
 		handle_error(mgcp_ctx, MGCP_ERR_UNSUPP_ADDR_FMT);
@@ -486,7 +482,7 @@
 	sin = (struct sockaddr_in *)&conn->aoip_rtp_addr_remote;
 	addr = inet_ntoa(sin->sin_addr);
 	port = osmo_ntohs(sin->sin_port);
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "CRCX/NET: MSC expects RTP input on address %s:%u\n", addr, port);
+	LOGPFSML(fi, LOGL_DEBUG, "CRCX/NET: MSC expects RTP input on address %s:%u\n", addr, port);
 
 	/* Generate MGCP message string */
 	mgcp_msg = (struct mgcp_msg) {
@@ -507,14 +503,14 @@
 	OSMO_ASSERT(msg);
 
 	/* Transmit MGCP message to MGW */
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "CRCX/NET: transmitting MGCP message to MGW...\n");
+	LOGPFSML(fi, LOGL_DEBUG, "CRCX/NET: transmitting MGCP message to MGW...\n");
 	rc = mgcp_client_tx(mgcp, msg, crcx_for_net_resp_cb, mgcp_ctx);
 	if (rc < 0) {
 		handle_error(mgcp_ctx, MGCP_ERR_MGW_TX_FAIL);
 		return;
 	}
 
-	osmo_fsm_inst_state_chg(mgcp_ctx->fsm, ST_ASSIGN_COMPL, MGCP_MGW_TIMEOUT, MGCP_MGW_TIMEOUT_TIMER_NR);
+	osmo_fsm_inst_state_chg(fi, ST_ASSIGN_COMPL, MGCP_MGW_TIMEOUT, MGCP_MGW_TIMEOUT_TIMER_NR);
 }
 
 /* Callback for MGCP-Client: handle response for NET associated CRCX */
@@ -576,7 +572,7 @@
 
 	OSMO_ASSERT(mgcp_ctx);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
+	LOGPFSML(fi, LOGL_DEBUG,
 		 "fsm-state: %s, fsm-event: %s\n",
 		 get_value_string(fsm_bsc_mgcp_state_names, fi->state), get_value_string(fsm_evt_names, event));
 
@@ -596,9 +592,9 @@
 	 * where the MGW expects the RTP input from the MSC side */
 	bssmap_send_aoip_ass_compl(lchan);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "call in progress, waiting for call end...\n");
+	LOGPFSML(fi, LOGL_DEBUG, "call in progress, waiting for call end...\n");
 
-	osmo_fsm_inst_state_chg(mgcp_ctx->fsm, ST_CALL, 0, 0);
+	osmo_fsm_inst_state_chg(fi, ST_CALL, 0, 0);
 }
 
 static void dlcx_for_all_resp_cb(struct mgcp_response *r, void *priv);
@@ -724,8 +720,7 @@
 
 	OSMO_ASSERT(mgcp_ctx);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
-		 "fsm-state: %s, fsm-event: %s\n",
+	LOGPFSML(fi, LOGL_DEBUG, "fsm-state: %s, fsm-event: %s\n",
 		 get_value_string(fsm_bsc_mgcp_state_names, fi->state), get_value_string(fsm_evt_names, event));
 
 	switch (event) {
@@ -770,8 +765,7 @@
 
 	OSMO_ASSERT(mgcp_ctx);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
-		 "fsm-state: %s, fsm-event: %s\n",
+	LOGPFSML(fi, LOGL_DEBUG, "fsm-state: %s, fsm-event: %s\n",
 		 get_value_string(fsm_bsc_mgcp_state_names, fi->state), get_value_string(fsm_evt_names, event));
 
 	switch (event) {
@@ -780,8 +774,8 @@
 		 * towards the BTS is now updated, so we now change back to
 		 * ST_CALL, where we will wait for the call-end (or another
 		 * handover) */
-		LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "MDCX/BTS/HO: handover done, waiting for call end...\n");
-		osmo_fsm_inst_state_chg(mgcp_ctx->fsm, ST_CALL, 0, 0);
+		LOGPFSML(fi, LOGL_DEBUG, "MDCX/BTS/HO: handover done, waiting for call end...\n");
+		osmo_fsm_inst_state_chg(fi, ST_CALL, 0, 0);
 		break;
 	case EV_HANDOVER:
 		/* This handles the rare, but possible situation where another
@@ -843,18 +837,17 @@
 	conn = mgcp_ctx->conn;
 	OSMO_ASSERT(conn);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG,
-		 "fsm-state: %s, fsm-event: %s\n",
+	LOGPFSML(fi, LOGL_DEBUG, "fsm-state: %s, fsm-event: %s\n",
 		 get_value_string(fsm_bsc_mgcp_state_names, fi->state), get_value_string(fsm_evt_names, event));
 
 	/* Send pending sigtran message */
 	if (mgcp_ctx->resp) {
-		LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "sending pending sigtran response message...\n");
+		LOGPFSML(fi, LOGL_DEBUG, "sending pending sigtran response message...\n");
 		osmo_bsc_sigtran_send(conn, mgcp_ctx->resp);
 		mgcp_ctx->resp = NULL;
 	}
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "state machine halted\n");
+	LOGPFSML(fi, LOGL_DEBUG, "state machine halted\n");
 
 	/* Destroy the state machine and all context information */
 	osmo_fsm_inst_free(mgcp_ctx->fsm);
@@ -871,8 +864,7 @@
 	mgcp = mgcp_ctx->mgcp;
 	OSMO_ASSERT(mgcp);
 
-	LOGPFSML(mgcp_ctx->fsm, LOGL_ERROR,
-		 "timeout (T%i) in state %s, attempting graceful teardown...\n",
+	LOGPFSML(fi, LOGL_ERROR, "timeout (T%i) in state %s, attempting graceful teardown...\n",
 		 fi->T, get_value_string(fsm_bsc_mgcp_state_names, fi->state));
 
 	/* Ensure that no sigtran response, is present. Otherwiese we might try
@@ -883,14 +875,14 @@
 		/* Note: We were unable to communicate with the MGW,
 		 * unfortunately there is no meaningful action we can take
 		 * now other than giving up. */
-		LOGPFSML(mgcp_ctx->fsm, LOGL_ERROR, "graceful teardown not possible, terminating...\n");
+		LOGPFSML(fi, LOGL_ERROR, "graceful teardown not possible, terminating...\n");
 
 		/* At least release the occupied endpoint ID */
 		mgcp_client_release_endpoint(mgcp_ctx->rtp_endpoint, mgcp);
 
 		/* Initiate self destruction of the FSM */
 		osmo_fsm_inst_state_chg(fi, ST_HALT, 0, 0);
-		osmo_fsm_inst_dispatch(mgcp_ctx->fsm, EV_TEARDOWN, mgcp_ctx);
+		osmo_fsm_inst_dispatch(fi, EV_TEARDOWN, mgcp_ctx);
 	} else if (fi->T == MGCP_BSS_TIMEOUT_TIMER_NR)
 		/* Note: If the logic that controls the BSS is unable to
 		 * negotiate a connection, we presumably still have a

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I05ff62e7e2de64c2dbf5ea2736f5e58faf16df0b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list