aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-06-15 11:15:11 +0800
committerHarald Welte <laforge@gnumonks.org>2012-06-15 11:15:11 +0800
commitbabbbbf6ee39d748f967eed7dee8df628d2a70e8 (patch)
tree25ba02e53ca5475f3291ced1eadcff8980a74eb4
parent821bf067e408f649bed62f10683fd44b43c0d673 (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
-rw-r--r--src/common/load_indication.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/common/load_indication.c b/src/common/load_indication.c
index 3e6fa74..e52952c 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,