[PATCH] osmo-bts[master]: RSL: adding assertions

dexter gerrit-no-reply at lists.osmocom.org
Mon Jan 9 11:40:13 UTC 2017


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

RSL: adding assertions

The public functions in rsl.c do not check for null pointers,
added assertions to catch null pointers early

Change-Id: I63f127ce70a4127180f90238f564b63e355216ec
---
M src/common/rsl.c
1 file changed, 22 insertions(+), 3 deletions(-)


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

diff --git a/src/common/rsl.c b/src/common/rsl.c
index 41dd2ce..a34c455 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -2008,6 +2008,8 @@
 
 void cb_ts_disconnected(struct gsm_bts_trx_ts *ts)
 {
+	OSMO_ASSERT(ts);
+
 	switch (ts->pchan) {
 	case GSM_PCHAN_TCH_F_PDCH:
 		return ipacc_dyn_pdch_ts_disconnected(ts);
@@ -2093,6 +2095,8 @@
 
 void cb_ts_connected(struct gsm_bts_trx_ts *ts)
 {
+	OSMO_ASSERT(ts);
+
 	switch (ts->pchan) {
 	case GSM_PCHAN_TCH_F_PDCH:
 		return ipacc_dyn_pdch_ts_connected(ts);
@@ -2105,7 +2109,10 @@
 
 void ipacc_dyn_pdch_complete(struct gsm_bts_trx_ts *ts, int rc)
 {
-	bool pdch_act = ts->flags & TS_F_PDCH_ACT_PENDING;
+	bool pdch_act;
+	OSMO_ASSERT(ts);
+
+	pdch_act = ts->flags & TS_F_PDCH_ACT_PENDING;
 
 	if ((ts->flags & TS_F_PDCH_PENDING_MASK) == TS_F_PDCH_PENDING_MASK)
 		LOGP(DRSL, LOGL_ERROR,
@@ -2256,7 +2263,12 @@
 int lapdm_rll_tx_cb(struct msgb *msg, struct lapdm_entity *le, void *ctx)
 {
 	struct gsm_lchan *lchan = ctx;
-	struct abis_rsl_common_hdr *rh = msgb_l2(msg);
+	struct abis_rsl_common_hdr *rh;
+
+	/* NOTE: Parameter lapdm_entity *le is ignored */
+
+	OSMO_ASSERT(msg);
+	rh = msgb_l2(msg);
 
 	if (lchan->state != LCHAN_S_ACTIVE) {
 		LOGP(DRSL, LOGL_INFO, "%s(%s) is not active . Dropping message.\n",
@@ -2482,15 +2494,22 @@
 
 int lchan_deactivate(struct gsm_lchan *lchan)
 {
+	OSMO_ASSERT(lchan);
+
 	lchan->ciph_state = 0;
 	return bts_model_lchan_deactivate(lchan);
 }
 
 int down_rsl(struct gsm_bts_trx *trx, struct msgb *msg)
 {
-	struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+	struct abis_rsl_common_hdr *rslh;
 	int ret = 0;
 
+	OSMO_ASSERT(trx);
+	OSMO_ASSERT(msg);
+
+	rslh = msgb_l2(msg);
+
 	if (msgb_l2len(msg) < sizeof(*rslh)) {
 		LOGP(DRSL, LOGL_NOTICE, "RSL message too short\n");
 		msgb_free(msg);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I63f127ce70a4127180f90238f564b63e355216ec
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>


More information about the gerrit-log mailing list