aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-21 14:33:15 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-21 14:40:16 +0100
commit00727558a95a9063857b0767b33588f07605df2d (patch)
tree4167fa100366533f4efdc86b77ac6b6cd0a2fff8 /src
parent162a3fe5dd7f327d192b2df08e61249a2adc45b5 (diff)
HO: fix minor issues found by coverity
handover_decision_2: - lchan->conn should never be NULL, but if it is, don't crash in LOGPHO* macros. - make certain to avoid modulo-zero. It's cosmetic since that config item is not allowed to be zero. handover_test: - check return value of gsm_generate_si(). - safer evaluation of main()'s argv. Fixes: CID#182929, CID#182928, CID#182927, CID#182926 Change-Id: I68e8ed3a1e8659edb47ac3e8a10508f17a3f5670
Diffstat (limited to 'src')
-rw-r--r--src/libbsc/handover_decision_2.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libbsc/handover_decision_2.c b/src/libbsc/handover_decision_2.c
index 752b0d559..0135020a6 100644
--- a/src/libbsc/handover_decision_2.c
+++ b/src/libbsc/handover_decision_2.c
@@ -46,7 +46,7 @@
lchan->ts->nr, \
lchan->nr, \
gsm_pchan_name(lchan->ts->pchan), \
- bsc_subscr_name(lchan->conn->bsub), \
+ bsc_subscr_name(lchan->conn? lchan->conn->bsub : NULL), \
## args)
#define LOGPHOLCHANTOBTS(lchan, new_bts, level, fmt, args...) \
@@ -57,7 +57,7 @@
lchan->nr, \
gsm_pchan_name(lchan->ts->pchan), \
new_bts->nr, \
- bsc_subscr_name(lchan->conn->bsub), \
+ bsc_subscr_name(lchan->conn? lchan->conn->bsub : NULL), \
## args)
#define REQUIREMENT_A_TCHF 0x01
@@ -1114,6 +1114,7 @@ static void on_measurement_report(struct gsm_meas_rep *mr)
struct gsm_lchan *lchan = mr->lchan;
struct gsm_bts *bts = lchan->ts->trx->bts;
int av_rxlev = -EINVAL, av_rxqual = -EINVAL;
+ unsigned int pwr_interval;
/* we currently only do handover for TCH channels */
switch (mr->lchan->type) {
@@ -1234,8 +1235,12 @@ static void on_measurement_report(struct gsm_meas_rep *mr)
return;
}
+ /* pwr_interval's range is 1-99, clarifying that no div-zero shall happen in modulo below: */
+ pwr_interval = ho_get_hodec2_pwr_interval(bts->ho);
+ OSMO_ASSERT(pwr_interval);
+
/* try handover to a better cell */
- if (av_rxlev >= 0 && (mr->nr % ho_get_hodec2_pwr_interval(bts->ho)) == 0) {
+ if (av_rxlev >= 0 && (mr->nr % pwr_interval) == 0) {
LOGPHOLCHAN(lchan, LOGL_INFO, "Looking whether a cell has better RXLEV\n");
global_ho_reason = HO_REASON_BETTER_CELL;
find_alternative_lchan(lchan, false);