aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-10-06 12:41:58 +0200
committerHarald Welte <laforge@gnumonks.org>2016-10-13 11:02:59 +0000
commitb058778df1c1ef3476aefd574c7278d11d385ade (patch)
treedf9160027514ece2ee864ba67ad7415139352482
parentde9dbe7958c32f58e39ad7b415ab2a48f876893b (diff)
DTX: fix array size calculation
Compute array size in-place and pass it to function. Change-Id: I4cd480ceb20efc69df1b00e3c7359fcbd14c19cd Fixes: coverity CID 1357844.
-rw-r--r--src/common/msg_utils.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c
index f9853c57..09596f36 100644
--- a/src/common/msg_utils.c
+++ b/src/common/msg_utils.c
@@ -234,10 +234,10 @@ static inline bool dtx_amr_sid_optional(const struct gsm_lchan *lchan,
return false;
}
-static inline bool fn_chk(const uint8_t *t, uint32_t fn)
+static inline bool fn_chk(const uint8_t *t, uint32_t fn, uint8_t len)
{
uint8_t i;
- for (i = 0; i < ARRAY_SIZE(t); i++)
+ for (i = 0; i < len; i++)
if (fn % 104 == t[i])
return false;
return true;
@@ -256,9 +256,10 @@ static inline bool dtx_sched_optional(struct gsm_lchan *lchan, uint32_t fn)
h1[] = { 14, 16, 18, 20, 66, 68, 70, 72 };
if (lchan->tch_mode == GSM48_CMODE_SPEECH_V1) {
if (lchan->type == GSM_LCHAN_TCH_F)
- return fn_chk(f, fn);
+ return fn_chk(f, fn, ARRAY_SIZE(f));
else
- return fn_chk(lchan->nr ? h1 : h0, fn);
+ return fn_chk(lchan->nr ? h1 : h0, fn,
+ ARRAY_SIZE(lchan->nr ? h1 : h0));
}
return false;
}