[PATCH] osmo-msc[master]: reset: remove name variable from reset context

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 9 10:40:18 UTC 2017


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

reset: remove name variable from reset context

The reset context contains a string buffer to allow for setting
a human readable name, that is then displayed in the logs. Since
OSMO-FSMs already have such a feature there is no need for an
extra name variable.

Use LOGPFSML and the name parameter of osmo_fsm_inst_alloc()
to display the name of the FSM

Fixes: Coverity CID#178664

Change-Id: I5b051606791c5e085ca6bb1be20592127d48ceb5
---
M src/libcommon-cs/a_reset.c
M src/libmsc/a_iface.c
2 files changed, 12 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/54/4754/1

diff --git a/src/libcommon-cs/a_reset.c b/src/libcommon-cs/a_reset.c
index 7dbd014..32c00ae 100644
--- a/src/libcommon-cs/a_reset.c
+++ b/src/libcommon-cs/a_reset.c
@@ -62,8 +62,9 @@
 {
 	struct a_reset_ctx *reset = (struct a_reset_ctx *)data;
 	OSMO_ASSERT(reset);
+	OSMO_ASSERT(reset->fsm);
 
-	LOGP(DMSC, LOGL_NOTICE, "(%s) fsm-state (msc-reset): %s, fsm-event: %s\n", reset->name,
+	LOGPFSML(reset->fsm, LOGL_NOTICE, "fsm-state (msc-reset): %s, fsm-event: %s\n",
 	     get_value_string(fsm_state_names, ST_CONN), get_value_string(fsm_evt_names, event));
 
 	reset->conn_loss_counter = 0;
@@ -76,13 +77,13 @@
 	struct a_reset_ctx *reset = (struct a_reset_ctx *)data;
 	OSMO_ASSERT(reset);
 
-	LOGP(DMSC, LOGL_NOTICE, "(%s) fsm-state (msc-reset): %s, fsm-event: %s\n", reset->name,
+	LOGPFSML(reset->fsm, LOGL_NOTICE, "fsm-state (msc-reset): %s, fsm-event: %s\n",
 	     get_value_string(fsm_state_names, ST_CONN), get_value_string(fsm_evt_names, event));
 
 	switch (event) {
 	case EV_N_DISCONNECT:
 		if (reset->conn_loss_counter >= BAD_CONNECTION_THRESOLD) {
-			LOGP(DMSC, LOGL_NOTICE, "(%s) SIGTRAN connection down, reconnecting...\n", reset->name);
+			LOGPFSML(reset->fsm, LOGL_NOTICE, "SIGTRAN connection down, reconnecting...\n");
 			osmo_fsm_inst_state_chg(fi, ST_DISC, RESET_RESEND_INTERVAL, RESET_RESEND_TIMER_NO);
 		} else
 			reset->conn_loss_counter++;
@@ -97,8 +98,9 @@
 static int fsm_reset_ack_timeout_cb(struct osmo_fsm_inst *fi)
 {
 	struct a_reset_ctx *reset = (struct a_reset_ctx *)fi->priv;
+	OSMO_ASSERT(reset->fsm);
 
-	LOGP(DMSC, LOGL_NOTICE, "(%s) reset-ack timeout (T%i) in state %s, resending...\n", reset->name, fi->T,
+	LOGPFSML(reset->fsm, LOGL_NOTICE, "reset-ack timeout (T%i) in state %s, resending...\n", fi->T,
 	     get_value_string(fsm_state_names, fi->state));
 
 	reset->cb(reset->priv);
@@ -147,12 +149,11 @@
 	OSMO_ASSERT(reset);
 	reset->priv = priv;
 	reset->cb = cb;
-	strncpy(reset->name, name, sizeof(reset->name));
 	reset->conn_loss_counter = 0;
-	reset->fsm = osmo_fsm_inst_alloc(&fsm, NULL, NULL, LOGL_DEBUG, NULL);
+	reset->fsm = osmo_fsm_inst_alloc(&fsm, NULL, NULL, LOGL_DEBUG, name);
 	OSMO_ASSERT(reset->fsm);
 	reset->fsm->priv = reset;
-	LOGP(DMSC, LOGL_NOTICE, "(%s) reset handler fsm created.\n", reset->name);
+	LOGPFSML(reset->fsm, LOGL_NOTICE, "reset handler fsm created.\n");
 
 	/* kick off reset-ack sending mechanism */
 	osmo_fsm_inst_state_chg(reset->fsm, ST_DISC, RESET_RESEND_INTERVAL, RESET_RESEND_TIMER_NO);
@@ -172,7 +173,7 @@
 	memset(reset, 0, sizeof(*reset));
 	talloc_free(reset);
 
-	LOGP(DMSC, LOGL_NOTICE, "(%s) reset handler fsm destroyed.\n", reset->name);
+	LOGPFSML(reset->fsm, LOGL_NOTICE, "reset handler fsm destroyed.\n");
 }
 
 /* Confirm that we sucessfully received a reset acknowlege message */
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 4892fb8..bdfef87 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -460,6 +460,7 @@
 {
 	struct bsc_context *bsc_ctx;
 	struct osmo_ss7_instance *ss7;
+	char bsc_name[32];
 
 	OSMO_ASSERT(bsc_addr);
 	OSMO_ASSERT(msc_addr);
@@ -482,7 +483,8 @@
 	llist_add_tail(&bsc_ctx->list, &gsm_network->a.bscs);
 
 	/* Start reset procedure to make the new connection active */
-	bsc_ctx->reset = a_reset_alloc(bsc_ctx, osmo_sccp_addr_name(ss7, bsc_addr), a_reset_cb, bsc_ctx);
+	snprintf(bsc_name, sizeof(bsc_name), "bsc-%i", bsc_addr->pc);
+	bsc_ctx->reset = a_reset_alloc(bsc_ctx, bsc_name, a_reset_cb, bsc_ctx);
 }
 
 /* Callback function, called by the SSCP stack when data arrives */

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

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



More information about the gerrit-log mailing list