aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-07-23 19:46:04 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-07-23 19:46:04 +0800
commit6e95c5ffa17761bc9ab7e308edd8a83b286eea3f (patch)
tree322fc0ab9fa0c75a2a7a8c8bf22a2faf182439ba
parent8d7b10ef58a4fbb2b21d0411d1f420dd69b5987c (diff)
meas_rep.c: clang reports a possible division by zero
Check the input and exit early if we have no measurement reports to avoid a possible division by zero.
-rw-r--r--openbsc/src/meas_rep.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/openbsc/src/meas_rep.c b/openbsc/src/meas_rep.c
index 4b9cc1a0c..8b5bff1b8 100644
--- a/openbsc/src/meas_rep.c
+++ b/openbsc/src/meas_rep.c
@@ -76,6 +76,9 @@ int get_meas_rep_avg(const struct gsm_lchan *lchan,
unsigned int i, idx;
int avg = 0;
+ if (num < 1)
+ return 0;
+
idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
lchan->meas_rep_idx, num);