Change in libosmocore[master]: rsl: make rsl_dec_chan_nr() more readable, use RSL_CHAN_NR_MASK

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/.

neels gerrit-no-reply at lists.osmocom.org
Thu May 27 14:24:40 UTC 2021


neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24419 )

Change subject: rsl: make rsl_dec_chan_nr() more readable, use RSL_CHAN_NR_MASK
......................................................................

rsl: make rsl_dec_chan_nr() more readable, use RSL_CHAN_NR_MASK

Change-Id: I1650e3b02e79461e42499268fa8ed30bff667489
---
M src/gsm/rsl.c
1 file changed, 23 insertions(+), 31 deletions(-)

Approvals:
  Jenkins Builder: Verified
  neels: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/src/gsm/rsl.c b/src/gsm/rsl.c
index 8d34543..706fb54 100644
--- a/src/gsm/rsl.c
+++ b/src/gsm/rsl.c
@@ -187,38 +187,30 @@
 {
 	*timeslot = chan_nr & 0x7;
 
-	if ((chan_nr & 0xf8) == RSL_CHAN_Bm_ACCHs) {
-		*type = RSL_CHAN_Bm_ACCHs;
+	switch (chan_nr & RSL_CHAN_NR_MASK) {
+	case RSL_CHAN_Bm_ACCHs:
+	case RSL_CHAN_BCCH:
+	case RSL_CHAN_RACH:
+	case RSL_CHAN_PCH_AGCH:
+	case RSL_CHAN_OSMO_PDCH:
+	case RSL_CHAN_OSMO_CBCH4:
+	case RSL_CHAN_OSMO_CBCH8:
+		*type = chan_nr & RSL_CHAN_NR_MASK;
 		*subch = 0;
-	} else if ((chan_nr & 0xf0) == RSL_CHAN_Lm_ACCHs) {
-		*type = RSL_CHAN_Lm_ACCHs;
-		*subch = (chan_nr >> 3) & 0x1;
-	} else if ((chan_nr & 0xe0) == RSL_CHAN_SDCCH4_ACCH) {
-		*type = RSL_CHAN_SDCCH4_ACCH;
-		*subch = (chan_nr >> 3) & 0x3;
-	} else if ((chan_nr & 0xc0) == RSL_CHAN_SDCCH8_ACCH) {
-		*type = RSL_CHAN_SDCCH8_ACCH;
-		*subch = (chan_nr >> 3) & 0x7;
-	} else if ((chan_nr & 0xf8) == RSL_CHAN_BCCH) {
-		*type = RSL_CHAN_BCCH;
-		*subch = 0;
-	} else if ((chan_nr & 0xf8) == RSL_CHAN_RACH) {
-		*type = RSL_CHAN_RACH;
-		*subch = 0;
-	} else if ((chan_nr & 0xf8) == RSL_CHAN_PCH_AGCH) {
-		*type = RSL_CHAN_PCH_AGCH;
-		*subch = 0;
-	} else if ((chan_nr & 0xf8) == RSL_CHAN_OSMO_PDCH) {
-		*type = RSL_CHAN_OSMO_PDCH;
-		*subch = 0;
-	} else if ((chan_nr & 0xf8) == RSL_CHAN_OSMO_CBCH4) {
-		*type = RSL_CHAN_OSMO_CBCH4;
-		*subch = 0;
-	} else if ((chan_nr & 0xf8) == RSL_CHAN_OSMO_CBCH8) {
-		*type = RSL_CHAN_OSMO_CBCH8;
-		*subch = 0;
-	} else
-		return -EINVAL;
+		break;
+	default:
+		if ((chan_nr & 0xf0) == RSL_CHAN_Lm_ACCHs) {
+			*type = RSL_CHAN_Lm_ACCHs;
+			*subch = (chan_nr >> 3) & 0x1;
+		} else if ((chan_nr & 0xe0) == RSL_CHAN_SDCCH4_ACCH) {
+			*type = RSL_CHAN_SDCCH4_ACCH;
+			*subch = (chan_nr >> 3) & 0x3;
+		} else if ((chan_nr & 0xc0) == RSL_CHAN_SDCCH8_ACCH) {
+			*type = RSL_CHAN_SDCCH8_ACCH;
+			*subch = (chan_nr >> 3) & 0x7;
+		} else
+			return -EINVAL;
+	}
 
 	return 0;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24419
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I1650e3b02e79461e42499268fa8ed30bff667489
Gerrit-Change-Number: 24419
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210527/3fd9b9ab/attachment.htm>


More information about the gerrit-log mailing list