aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-02-09 09:15:28 +0100
committerHarald Welte <laforge@gnumonks.org>2019-02-12 20:08:18 +0100
commit055c29bc6b5f29578eff9ef3211a334b302a25e6 (patch)
tree9fefb189e025c505485d6d1fa3c08bd93b3a2152
parente57a62deeebd672be85e9ec82a7e274ad402129b (diff)
OML: Reduce code duplication in down_mom/down_fom
Simply use a "mo" variable on the stack rather than having duplicate but otherwise identical calls to oml_tx_failure_event_rep() Change-Id: Ibe6c79e95405b13d041047549d2ffa39aa355eb2
-rw-r--r--src/common/oml.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/common/oml.c b/src/common/oml.c
index 313ff962..ad8ab81b 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -1089,6 +1089,7 @@ static int down_fom(struct gsm_bts *bts, struct msgb *msg)
{
struct abis_om_fom_hdr *foh = msgb_l3(msg);
struct gsm_bts_trx *trx;
+ struct gsm_abis_mo *mo = &bts->mo;
int ret;
if (msgb_l2len(msg) < sizeof(*foh)) {
@@ -1136,16 +1137,10 @@ static int down_fom(struct gsm_bts *bts, struct msgb *msg)
break;
default:
trx = gsm_bts_trx_num(bts, foh->obj_inst.trx_nr);
- if (trx) {
- oml_tx_failure_event_rep(&trx->mo, OSMO_EVT_MAJ_UKWN_MSG,
- "unknown Formatted O&M "
- "msg_type 0x%02x",
- foh->msg_type);
- } else
- oml_tx_failure_event_rep(&bts->mo, OSMO_EVT_MAJ_UKWN_MSG,
- "unknown Formatted O&M "
- "msg_type 0x%02x",
- foh->msg_type);
+ if (trx)
+ mo = &trx->mo;
+ oml_tx_failure_event_rep(mo, OSMO_EVT_MAJ_UKWN_MSG, "unknown Formatted O&M "
+ "msg_type 0x%02x", foh->msg_type);
ret = oml_fom_ack_nack(msg, NM_NACK_MSGTYPE_INVAL);
}
@@ -1371,6 +1366,7 @@ static int rx_oml_ipa_rsl_connect(struct gsm_bts_trx *trx, struct msgb *msg,
static int down_mom(struct gsm_bts *bts, struct msgb *msg)
{
struct abis_om_hdr *oh = msgb_l2(msg);
+ struct gsm_abis_mo *mo = &bts->mo;
struct abis_om_fom_hdr *foh;
struct gsm_bts_trx *trx;
uint8_t idstrlen = oh->data[0];
@@ -1414,14 +1410,10 @@ static int down_mom(struct gsm_bts *bts, struct msgb *msg)
break;
default:
trx = gsm_bts_trx_num(bts, foh->obj_inst.trx_nr);
- if (trx) {
- oml_tx_failure_event_rep(&trx->mo, OSMO_EVT_MAJ_UKWN_MSG,
- "unknown Manufacturer O&M msg_type 0x%02x",
- foh->msg_type);
- } else
- oml_tx_failure_event_rep(&bts->mo, OSMO_EVT_MAJ_UKWN_MSG,
- "unknown Manufacturer O&M msg_type 0x%02x",
- foh->msg_type);
+ if (trx)
+ mo = &trx->mo;
+ oml_tx_failure_event_rep(mo, OSMO_EVT_MAJ_UKWN_MSG, "unknown Manufacturer O&M "
+ "msg_type 0x%02x", foh->msg_type);
ret = oml_fom_ack_nack(msg, NM_NACK_MSGTYPE_INVAL);
}