From 17577b7c00d4748d318034ca2babe54b8b8f769d Mon Sep 17 00:00:00 2001 From: Keith Whyte Date: Mon, 10 Sep 2018 09:15:52 -0400 Subject: fix handling of odd pchans in bts_supports_cm() Convert the if-cascade to a switch(). For any unexpected pchan kind, reject the chan mode immediately instead of going on to invoke gsm_bts_has_feature on feature = _NUM_BTS_FEAT, and log the error. Tweaked-by: neels Change-Id: Ieaded9258554b15fcc4b7f05d5a8847175b7962f --- src/common/bts.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/common/bts.c') diff --git a/src/common/bts.c b/src/common/bts.c index bec611cc..c251fdda 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -704,7 +704,8 @@ int bts_supports_cm(struct gsm_bts *bts, enum gsm_phys_chan_config pchan, /* Before the requested pchan/cm combination can be checked, we need to * convert it to a feature identifier we can check */ - if (pchan == GSM_PCHAN_TCH_F) { + switch (pchan) { + case GSM_PCHAN_TCH_F: switch(cm) { case GSM48_CMODE_SPEECH_V1: feature = BTS_FEAT_SPEECH_F_V1; @@ -719,7 +720,9 @@ int bts_supports_cm(struct gsm_bts *bts, enum gsm_phys_chan_config pchan, /* Invalid speech codec type => Not supported! */ return 0; } - } else if (pchan == GSM_PCHAN_TCH_H) { + break; + + case GSM_PCHAN_TCH_H: switch(cm) { case GSM48_CMODE_SPEECH_V1: feature = BTS_FEAT_SPEECH_H_V1; @@ -731,6 +734,12 @@ int bts_supports_cm(struct gsm_bts *bts, enum gsm_phys_chan_config pchan, /* Invalid speech codec type => Not supported! */ return 0; } + break; + + default: + LOGP(DRSL, LOGL_ERROR, "BTS %u: unhandled pchan %s when checking mode %s\n", + bts->nr, gsm_pchan_name(pchan), gsm48_chan_mode_name(cm)); + return 0; } /* Check if the feature is supported by this BTS */ -- cgit v1.2.3