diff options
author | Keith Whyte <keith@rhizomatica.org> | 2018-09-10 09:15:52 -0400 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-09-11 00:28:10 +0200 |
commit | 17577b7c00d4748d318034ca2babe54b8b8f769d (patch) | |
tree | e3ceaaa125a6110907449a5191453122cd06c229 /src/common/bts.c | |
parent | 734eb40e72a331802620eafa98b9fc18d5620351 (diff) |
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
Diffstat (limited to 'src/common/bts.c')
-rw-r--r-- | src/common/bts.c | 13 |
1 files changed, 11 insertions, 2 deletions
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 */ |