[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
Thu Jul 28 10:02:31 UTC 2016


Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/589

to look at the new patch set (#2).

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

diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index 2fc5690..14c33d7 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -560,24 +560,38 @@
 	case GSM_PCHAN_TCH_F:
 	case GSM_PCHAN_PDCH:
 	case GSM_PCHAN_TCH_F_PDCH:
+		OSMO_ASSERT(lchan_nr == 0);
 		cbits = 0x01;
 		break;
 	case GSM_PCHAN_TCH_H:
+		OSMO_ASSERT(lchan_nr < 2);
 		cbits = 0x02;
 		cbits += 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);
 		cbits = 0x04;
 		cbits += lchan_nr;
 		break;
 	case GSM_PCHAN_SDCCH8_SACCH8C:
 	case GSM_PCHAN_SDCCH8_SACCH8C_CBCH:
+		OSMO_ASSERT(lchan_nr < 8);
 		cbits = 0x08;
 		cbits += lchan_nr;
 		break;
 	default:
 	case GSM_PCHAN_CCCH:
+		OSMO_ASSERT(lchan_nr == 0);
 		cbits = 0x10;
 		break;
 	}

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ibfdef347c85d4a145645a7325cd193ea1b475a54
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels_test_account <neels at hofmeyr.de>



More information about the gerrit-log mailing list