diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-12-28 18:49:12 +0100 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2016-02-01 13:58:13 +0100 |
commit | aa9daa1b9dfc74deb2ab4993f74ba61ee2712f73 (patch) | |
tree | 2b83b2e2820dcb02bc5fada8a4db45bd36ef3ba2 /src/gprs_rlcmac_ts_alloc.cpp | |
parent | 38f18698b3413bf3e608026aff519427af740335 (diff) |
tbf: Replace static casts by calls to as_ul_tbf/as_dl_tbf
Currently casts from gprs_rlcmac_tbf to gprs_rlcmac_ul_tbf and
gprs_rlcmac_dl_tbf are done by using static_cast. This doesn't provide
protection against converting a gprs_rlcmac_ul_tbf pointer to a
gprs_rlcmac_dl_tbf pointer and vice versa.
This commit provides two functions as_ul_tbf and as_dl_tbf, that
behave similar like dynamic_cast but use the direction field instead
of RTTI.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/gprs_rlcmac_ts_alloc.cpp')
-rw-r--r-- | src/gprs_rlcmac_ts_alloc.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 0daeaf5c..e6c8ad4c 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -480,14 +480,12 @@ int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, /* The allocation will be successful, so the system state and tbf_/ms_ * may be modified from now on. */ if (tbf->direction == GPRS_RLCMAC_UL_TBF) { - struct gprs_rlcmac_ul_tbf *ul_tbf = - static_cast<gprs_rlcmac_ul_tbf *>(tbf_); + struct gprs_rlcmac_ul_tbf *ul_tbf = as_ul_tbf(tbf_); LOGP(DRLCMAC, LOGL_DEBUG, "- Assign uplink TS=%d TFI=%d USF=%d\n", ts, tfi, usf); assign_uplink_tbf_usf(pdch, ul_tbf, tfi, usf); } else { - struct gprs_rlcmac_dl_tbf *dl_tbf = - static_cast<gprs_rlcmac_dl_tbf *>(tbf_); + struct gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf_); LOGP(DRLCMAC, LOGL_DEBUG, "- Assign downlink TS=%d TFI=%d\n", ts, tfi); assign_dlink_tbf(pdch, dl_tbf, tfi); @@ -1010,8 +1008,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, tbf_->first_ts = first_ts; if (tbf->direction == GPRS_RLCMAC_DL_TBF) { - struct gprs_rlcmac_dl_tbf *dl_tbf = - static_cast<gprs_rlcmac_dl_tbf *>(tbf_); + struct gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf_); for (ts = 0; ts < 8; ts++) { if (!(dl_slots & (1 << ts))) continue; @@ -1021,8 +1018,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, assign_dlink_tbf(&trx->pdch[ts], dl_tbf, tfi); } } else { - struct gprs_rlcmac_ul_tbf *ul_tbf = - static_cast<gprs_rlcmac_ul_tbf *>(tbf_); + struct gprs_rlcmac_ul_tbf *ul_tbf = as_ul_tbf(tbf_); for (ts = 0; ts < 8; ts++) { if (!(ul_slots & (1 << ts))) |