diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-06-15 11:15:11 +0800 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-06-15 11:15:11 +0800 |
commit | babbbbf6ee39d748f967eed7dee8df628d2a70e8 (patch) | |
tree | 25ba02e53ca5475f3291ced1eadcff8980a74eb4 /src/common/load_indication.c | |
parent | 821bf067e408f649bed62f10683fd44b43c0d673 (diff) |
CCCH LOAD IND: Avoid divide-by-zero
The total count of RACH or PCH slots should never be zero, as they
constantly increment. However, just as a safeguard, we introduce
an explicit handign to avoid divide-by-zero situations
Diffstat (limited to 'src/common/load_indication.c')
-rw-r--r-- | src/common/load_indication.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/common/load_indication.c b/src/common/load_indication.c index 3e6fa740..e52952c3 100644 --- a/src/common/load_indication.c +++ b/src/common/load_indication.c @@ -43,7 +43,11 @@ static void load_timer_cb(void *data) unsigned int pch_percent, rach_percent; /* compute percentages */ - pch_percent = (btsb->load.ccch.pch_used * 100) / btsb->load.ccch.pch_total; + if (btsb->load.ccch.pch_total == 0) + pch_percent = 0; + else + pch_percent = (btsb->load.ccch.pch_used * 100) / + btsb->load.ccch.pch_total; if (pch_percent >= btsb->load.ccch.load_ind_thresh) { /* send RSL load indication message to BSC */ @@ -51,7 +55,12 @@ static void load_timer_cb(void *data) rsl_tx_ccch_load_ind_pch(bts, buffer_space); } - rach_percent = (btsb->load.rach.busy * 100) / btsb->load.rach.total; + if (btsb->load.rach.total == 0) + rach_percent = 0; + else + rach_percent = (btsb->load.rach.busy * 100) / + btsb->load.rach.total; + if (rach_percent >= btsb->load.ccch.load_ind_thresh) { /* send RSL load indication message to BSC */ rsl_tx_ccch_load_ind_rach(bts, btsb->load.rach.total, |