aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libbsc
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-12-05 16:48:36 +0100
committerHarald Welte <laforge@gnumonks.org>2016-12-09 12:13:02 +0000
commite14f4b93f2cd5b87c5a0c0141662a2c7be3e0f87 (patch)
tree50389637c2ff74b4ec49cb5f273d46c8c51ac458 /openbsc/src/libbsc
parent2440f49a724f19a2f14b6ee1d4616c347b7d33ba (diff)
cosmetic: chan_alloc: use switch instead of if-cascade
Preparing cosmetically for a subsequent commit which will add another pchan kind to be checked, rather use a "switch (pchan) {}". Also reverse one if() branch to "early-exit" style. Change-Id: Ie5eb0fa859c4f225616095dc56d52ce0f2dc8bdc
Diffstat (limited to 'openbsc/src/libbsc')
-rw-r--r--openbsc/src/libbsc/chan_alloc.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c
index 0f4d90a..a50b4ee 100644
--- a/openbsc/src/libbsc/chan_alloc.c
+++ b/openbsc/src/libbsc/chan_alloc.c
@@ -124,7 +124,8 @@ _lc_find_trx(struct gsm_bts_trx *trx, enum gsm_phys_chan_config pchan,
* to check whether a dynamic timeslot is already in TCH/H mode
* and whether one of the two channels is still available.
*/
- if (pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH) {
+ switch (pchan) {
+ case GSM_PCHAN_TCH_F_TCH_H_PDCH:
if (ts->dyn.pchan_is != ts->dyn.pchan_want) {
/* The TS's mode is being switched. Not
* available anymore/yet. */
@@ -141,17 +142,19 @@ _lc_find_trx(struct gsm_bts_trx *trx, enum gsm_phys_chan_config pchan,
continue;
return ts->lchan;
}
- if (ts->dyn.pchan_is == dyn_as_pchan) {
- /* The requested type matches the dynamic
- * timeslot's current mode. A channel may still
- * be available (think TCH/H). */
- check_subslots = ts_subslots(ts);
- } else
- /* Otherwise this slot is not applicable. */
+ if (ts->dyn.pchan_is != dyn_as_pchan)
+ /* not applicable. */
continue;
- } else {
+ /* The requested type matches the dynamic timeslot's
+ * current mode. A channel may still be available
+ * (think TCH/H). */
+ check_subslots = ts_subslots(ts);
+ break;
+
+ default:
/* Not a dynamic channel, there is only one pchan kind: */
check_subslots = ts_subslots(ts);
+ break;
}
/* Is a sub-slot still available? */