[MERGED] osmo-bts[master]: RSL: add assertions to check args of public API

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

dexter gerrit-no-reply at lists.osmocom.org
Tue Jan 10 14:14:33 UTC 2017


dexter has submitted this change and it was merged.

Change subject: RSL: add assertions to check args of public API
......................................................................


RSL: add assertions to check args of public API

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

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

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: I63f127ce70a4127180f90238f564b63e355216ec
Gerrit-PatchSet: 5
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list