[PATCH] 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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Oct 6 10:44:38 UTC 2016


Review at  https://gerrit.osmocom.org/1010

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(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/10/1010/1

diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c
index 99a211f..388bf72 100644
--- a/src/common/msg_utils.c
+++ b/src/common/msg_utils.c
@@ -203,10 +203,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;
@@ -225,9 +225,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: newchange
Gerrit-Change-Id: I4cd480ceb20efc69df1b00e3c7359fcbd14c19cd
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list