[PATCH] openbsc[master]: gsm_ts2chan_nr(): add assertions for lchan_nr

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 Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Jul 25 15:57:03 UTC 2016


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

gsm_ts2chan_nr(): add assertions for lchan_nr

Change-Id: Ibfdef347c85d4a145645a7325cd193ea1b475a54
---
M openbsc/src/libcommon/gsm_data_shared.c
1 file changed, 14 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/89/589/1

diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index e84fa7b..5f86dc9 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -560,21 +560,35 @@
 	case GSM_PCHAN_TCH_F:
 	case GSM_PCHAN_PDCH:
 	case GSM_PCHAN_TCH_F_PDCH:
+		OSMO_ASSERT(lchan_nr == 0);
 		chan_nr = RSL_CHAN_Bm_ACCHs;
 		break;
 	case GSM_PCHAN_TCH_H:
+		OSMO_ASSERT(lchan_nr < 2);
 		chan_nr = RSL_CHAN_Lm_ACCHs + (RSL_CHAN_NR_1 * lchan_nr);
 		break;
 	case GSM_PCHAN_CCCH_SDCCH4:
 	case GSM_PCHAN_CCCH_SDCCH4_CBCH:
+		/*
+		 * As a special hack for BCCH, lchan_nr == 4 may be passed
+		 * here. This should never be sent in an RSL message, so just
+		 * return 0. See osmo-bts-xxx/oml.c:opstart_compl().
+		 */
+		if (lchan_nr == 4) {
+			chan_nr = 0;
+			break;
+		}
+		OSMO_ASSERT(lchan_nr < 4);
 		chan_nr = RSL_CHAN_SDCCH4_ACCH + (RSL_CHAN_NR_1 * lchan_nr);
 		break;
 	case GSM_PCHAN_SDCCH8_SACCH8C:
 	case GSM_PCHAN_SDCCH8_SACCH8C_CBCH:
+		OSMO_ASSERT(lchan_nr < 8);
 		chan_nr = RSL_CHAN_SDCCH8_ACCH + (RSL_CHAN_NR_1 * lchan_nr);
 		break;
 	default:
 	case GSM_PCHAN_CCCH:
+		OSMO_ASSERT(lchan_nr == 0);
 		chan_nr = RSL_CHAN_BCCH;
 		break;
 	}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibfdef347c85d4a145645a7325cd193ea1b475a54
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list