[MERGED] osmo-bts[master]: DTX: fix array size calculation

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Oct 13 11:02:59 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: DTX: fix array size calculation
......................................................................


DTX: fix array size calculation

Compute array size in-place and pass it to function.

Change-Id: I4cd480ceb20efc69df1b00e3c7359fcbd14c19cd
Fixes: coverity CID 1357844.
---
M src/common/msg_utils.c
1 file changed, 5 insertions(+), 4 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c
index f9853c5..09596f3 100644
--- a/src/common/msg_utils.c
+++ b/src/common/msg_utils.c
@@ -234,10 +234,10 @@
 	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 @@
 				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;
 }

-- 
To view, visit https://gerrit.osmocom.org/1010
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4cd480ceb20efc69df1b00e3c7359fcbd14c19cd
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list