jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/33622 )
Change subject: Change return value of bts_supports_cm() from int to bool ......................................................................
Change return value of bts_supports_cm() from int to bool
Change-Id: I72e30fe852ab69a162b117a534071ebddd4b16ba --- M include/osmo-bts/bts.h M src/common/bts.c M src/common/rsl.c M tests/misc/misc_test.c 4 files changed, 32 insertions(+), 23 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/22/33622/1
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h index 5cdfc94..d103b60 100644 --- a/include/osmo-bts/bts.h +++ b/include/osmo-bts/bts.h @@ -416,8 +416,8 @@
int bts_main(int argc, char **argv);
-int bts_supports_cm(const struct gsm_bts *bts, - const struct rsl_ie_chan_mode *cm); +bool bts_supports_cm(const struct gsm_bts *bts, + const struct rsl_ie_chan_mode *cm);
int32_t bts_get_avg_fn_advance(const struct gsm_bts *bts);
diff --git a/src/common/bts.c b/src/common/bts.c index 6652ce6..0ca4b6d 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -779,8 +779,8 @@ return &bts->gsm_time; }
-int bts_supports_cm(const struct gsm_bts *bts, - const struct rsl_ie_chan_mode *cm) +bool bts_supports_cm(const struct gsm_bts *bts, + const struct rsl_ie_chan_mode *cm) { enum osmo_bts_features feature = _NUM_BTS_FEAT;
@@ -788,22 +788,22 @@ case RSL_CMOD_SPD_SIGN: /* We assume that signalling support is mandatory, * there is no BTS_FEAT_* definition to check that. */ - return 1; + return true; case RSL_CMOD_SPD_SPEECH: break; case RSL_CMOD_CRT_TCH_GROUP_Bm: case RSL_CMOD_CRT_TCH_GROUP_Lm: if (!osmo_bts_has_feature(bts->features, BTS_FEAT_VGCS)) - return 0; + return false; break; case RSL_CMOD_CRT_TCH_BCAST_Bm: case RSL_CMOD_CRT_TCH_BCAST_Lm: if (!osmo_bts_has_feature(bts->features, BTS_FEAT_VBS)) - return 0; + return false; break; case RSL_CMOD_SPD_DATA: default: - return 0; + return false; }
/* Before the requested pchan/cm combination can be checked, we need to @@ -811,7 +811,7 @@ switch (cm->chan_rt) { case RSL_CMOD_CRT_OSMO_TCH_VAMOS_Bm: if (!osmo_bts_has_feature(bts->features, BTS_FEAT_VAMOS)) - return 0; + return false; /* fall-through */ case RSL_CMOD_CRT_TCH_Bm: case RSL_CMOD_CRT_TCH_GROUP_Bm: @@ -828,13 +828,13 @@ break; default: /* Invalid speech codec type => Not supported! */ - return 0; + return false; } break;
case RSL_CMOD_CRT_OSMO_TCH_VAMOS_Lm: if (!osmo_bts_has_feature(bts->features, BTS_FEAT_VAMOS)) - return 0; + return false; /* fall-through */ case RSL_CMOD_CRT_TCH_Lm: case RSL_CMOD_CRT_TCH_GROUP_Lm: @@ -848,7 +848,7 @@ break; default: /* Invalid speech codec type => Not supported! */ - return 0; + return false; } break;
@@ -856,14 +856,14 @@ LOGP(DRSL, LOGL_ERROR, "Unhandled RSL channel type=0x%02x/rate=0x%02x\n", cm->chan_rt, cm->chan_rate); - return 0; + return false; }
/* Check if the feature is supported by this BTS */ if (osmo_bts_has_feature(bts->features, feature)) - return 1; + return true;
- return 0; + return false; }
/* return the gsm_lchan for the CBCH (if it exists at all) */ diff --git a/src/common/rsl.c b/src/common/rsl.c index 7bd950f..ad643ae 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -248,7 +248,7 @@
#undef RSL_CMODE
- if (bts_supports_cm(lchan->ts->trx->bts, cm) != 1) { + if (bts_supports_cm(lchan->ts->trx->bts, cm) == false) { LOGPLCHAN(lchan, DRSL, LOGL_ERROR, "Channel type=0x%02x/mode=%s " "is not supported by the PHY\n", cm->chan_rt, gsm48_chan_mode_name(lchan->tch_mode)); diff --git a/tests/misc/misc_test.c b/tests/misc/misc_test.c index b1b9820..cdc57df 100644 --- a/tests/misc/misc_test.c +++ b/tests/misc/misc_test.c @@ -172,11 +172,11 @@ /* Signalling shall be supported regardless of the features */ cm = (struct rsl_ie_chan_mode) { .chan_rt = RSL_CMOD_CRT_TCH_Bm, .spd_ind = RSL_CMOD_SPD_SIGN }; - OSMO_ASSERT(bts_supports_cm(bts, &cm) == 1); /* TCH/F */ + OSMO_ASSERT(bts_supports_cm(bts, &cm) == true); /* TCH/F */
cm = (struct rsl_ie_chan_mode) { .chan_rt = RSL_CMOD_CRT_TCH_Lm, .spd_ind = RSL_CMOD_SPD_SIGN }; - OSMO_ASSERT(bts_supports_cm(bts, &cm) == 1); /* TCH/H */ + OSMO_ASSERT(bts_supports_cm(bts, &cm) == true); /* TCH/H */
osmo_bts_set_feature(bts->features, BTS_FEAT_SPEECH_F_V1); osmo_bts_set_feature(bts->features, BTS_FEAT_SPEECH_H_V1); @@ -186,27 +186,27 @@ cm = (struct rsl_ie_chan_mode) { .chan_rt = RSL_CMOD_CRT_TCH_Bm, .spd_ind = RSL_CMOD_SPD_SPEECH, .chan_rate = RSL_CMOD_SP_GSM1 }; - OSMO_ASSERT(bts_supports_cm(bts, &cm) == 1); /* TCH/FS */ + OSMO_ASSERT(bts_supports_cm(bts, &cm) == true); /* TCH/FS */
cm = (struct rsl_ie_chan_mode) { .chan_rt = RSL_CMOD_CRT_TCH_Lm, .spd_ind = RSL_CMOD_SPD_SPEECH, .chan_rate = RSL_CMOD_SP_GSM1 }; - OSMO_ASSERT(bts_supports_cm(bts, &cm) == 1); /* TCH/HS */ + OSMO_ASSERT(bts_supports_cm(bts, &cm) == true); /* TCH/HS */
cm = (struct rsl_ie_chan_mode) { .chan_rt = RSL_CMOD_CRT_TCH_Bm, .spd_ind = RSL_CMOD_SPD_SPEECH, .chan_rate = RSL_CMOD_SP_GSM2 }; - OSMO_ASSERT(bts_supports_cm(bts, &cm) == 0); /* TCH/EFS */ + OSMO_ASSERT(bts_supports_cm(bts, &cm) == false); /* TCH/EFS */
cm = (struct rsl_ie_chan_mode) { .chan_rt = RSL_CMOD_CRT_TCH_Bm, .spd_ind = RSL_CMOD_SPD_SPEECH, .chan_rate = RSL_CMOD_SP_GSM3 }; - OSMO_ASSERT(bts_supports_cm(bts, &cm) == 1); /* TCH/AFS */ + OSMO_ASSERT(bts_supports_cm(bts, &cm) == true); /* TCH/AFS */
cm = (struct rsl_ie_chan_mode) { .chan_rt = RSL_CMOD_CRT_TCH_Lm, .spd_ind = RSL_CMOD_SPD_SPEECH, .chan_rate = RSL_CMOD_SP_GSM3 }; - OSMO_ASSERT(bts_supports_cm(bts, &cm) == 1); /* TCH/AHS */ + OSMO_ASSERT(bts_supports_cm(bts, &cm) == true); /* TCH/AHS */
talloc_free(bts); }