Change in osmocom-bb[master]: trxcon: trx_if_open(): avoid using talloc_reparent()
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/29270 ) Change subject: trxcon: trx_if_open(): avoid using talloc_reparent() ...................................................................... trxcon: trx_if_open(): avoid using talloc_reparent() For consistency with trxcon_inst_alloc(): * first allocate an instance of trx_fsm as a child of trxcon->fi, * then allocate a trx_instance as a child of the trx_fsm. Change-Id: Iafc486347c6ca7a80da88be73c772397fa2deb7d --- M src/host/trxcon/src/trx_if.c 1 file changed, 12 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/70/29270/1 diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c index 5e4e696..7b1ca99 100644 --- a/src/host/trxcon/src/trx_if.c +++ b/src/host/trxcon/src/trx_if.c @@ -703,24 +703,24 @@ { const unsigned int offset = trxcon->id * 2; struct trx_instance *trx; + struct osmo_fsm_inst *fi; int rc; LOGPFSML(trxcon->fi, LOGL_NOTICE, "Init transceiver interface " "(%s:%u/%u)\n", remote_host, base_port, trxcon->id); - /* Try to allocate memory */ - trx = talloc_zero(trxcon, struct trx_instance); - if (!trx) { - LOGPFSML(trxcon->fi, LOGL_ERROR, "Failed to allocate memory\n"); + /* Allocate a new dedicated state machine */ + fi = osmo_fsm_inst_alloc_child(&trx_fsm, trxcon->fi, TRXCON_EV_PHYIF_FAILURE); + if (fi == NULL) { + LOGPFSML(trxcon->fi, LOGL_ERROR, "Failed to allocate an instance " + "of FSM '%s'\n", trx_fsm.name); return NULL; } - /* Allocate a new dedicated state machine */ - trx->fi = osmo_fsm_inst_alloc_child(&trx_fsm, trxcon->fi, TRXCON_EV_PHYIF_FAILURE); - if (trx->fi == NULL) { - LOGPFSML(trxcon->fi, LOGL_ERROR, "Failed to allocate an instance " - "of FSM '%s'\n", trx_fsm.name); - talloc_free(trx); + trx = talloc_zero(fi, struct trx_instance); + if (!trx) { + LOGPFSML(trxcon->fi, LOGL_ERROR, "Failed to allocate memory\n"); + osmo_fsm_inst_free(fi); return NULL; } @@ -742,18 +742,15 @@ if (rc < 0) goto udp_error; - /* Reparent trx_instance from trxcon to trx->fi */ - talloc_reparent(trxcon, trx->fi, trx); - trx->trxcon = trxcon; - trx->fi->priv = trx; + fi->priv = trx; + trx->fi = fi; return trx; udp_error: LOGPFSML(trx->fi, LOGL_ERROR, "Couldn't establish UDP connection\n"); osmo_fsm_inst_free(trx->fi); - talloc_free(trx); return NULL; } -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/29270 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Iafc486347c6ca7a80da88be73c772397fa2deb7d Gerrit-Change-Number: 29270 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> Gerrit-MessageType: newchange
participants (1)
-
fixeria