[PATCH] osmo-pcu[master]: pcu_l1_if: get rid of magic numbers and use ARRAY_SIZE() for...

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 Nov 17 20:11:00 UTC 2016


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

pcu_l1_if: get rid of magic numbers and use ARRAY_SIZE() for array iteration

Change-Id: I61d00950b4eb0b8bcbaf386d5081be84580dac75
---
M src/pcu_l1_if.cpp
1 file changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/73/1273/1

diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index f1c73c9..e1ebbde 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -340,8 +340,8 @@
 	struct gprs_bssgp_pcu *pcu;
 	struct gprs_rlcmac_pdch *pdch;
 	struct in_addr ia;
-	int rc = 0, ts;
-	uint8_t trx;
+	int rc = 0;
+	unsigned int trx, ts;
 	int i;
 
 	if (info_ind->version != PCU_IF_VERSION) {
@@ -357,9 +357,9 @@
 		LOGP(DL1IF, LOGL_NOTICE, "BTS not available\n");
 bssgp_failed:
 		/* free all TBF */
-		for (trx = 0; trx < 8; trx++) {
+		for (trx = 0; trx < ARRAY_SIZE(bts->trx); trx++) {
 			bts->trx[trx].arfcn = info_ind->trx[trx].arfcn;
-			for (ts = 0; ts < 8; ts++)
+			for (ts = 0; ts < ARRAY_SIZE(bts->trx[0].pdch); ts++)
 				bts->trx[trx].pdch[ts].free_resources();
 		}
 		gprs_bssgp_destroy();
@@ -451,7 +451,7 @@
 		bts->initial_cs_ul = bts->initial_cs_dl;
 	}
 
-	for (trx = 0; trx < 8; trx++) {
+	for (trx = 0; trx < ARRAY_SIZE(bts->trx); trx++) {
 		bts->trx[trx].arfcn = info_ind->trx[trx].arfcn;
 		if ((info_ind->flags & PCU_IF_FLAG_SYSMO)
 		 && info_ind->trx[trx].hlayer1) {
@@ -476,7 +476,7 @@
 #endif
 		}
 
-		for (ts = 0; ts < 8; ts++) {
+		for (ts = 0; ts < ARRAY_SIZE(bts->trx[0].pdch); ts++) {
 			pdch = &bts->trx[trx].pdch[ts];
 			if ((info_ind->trx[trx].pdch_mask & (1 << ts))) {
 				/* FIXME: activate dynamically at RLCMAC */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I61d00950b4eb0b8bcbaf386d5081be84580dac75
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list