Change in osmo-bts[master]: lchan2lch_par(): fix missing default branch in switch

laforge gerrit-no-reply at lists.osmocom.org
Wed Apr 21 06:32:37 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/23816 )

Change subject: lchan2lch_par(): fix missing default branch in switch
......................................................................

lchan2lch_par(): fix missing default branch in switch

New channel mode values have recently been added with change [1]
to 'enum gsm48_chan_mode'.  The lack of default branch in
lchan2lch_par() caused build failures on Jenkins:

  oml.c:956:2: error: enumeration value ‘GSM48_CMODE_SPEECH_V2_VAMOS’
                      not handled in switch [-Werror=switch]
  oml.c:956:2: error: enumeration value ‘GSM48_CMODE_SPEECH_V3_VAMOS’
                      not handled in switch [-Werror=switch]
  oml.c:956:2: error: enumeration value ‘GSM48_CMODE_SPEECH_V5_VAMOS’
                      not handled in switch [-Werror=switch]

This function is duplicated in osmo-bts-{lc15,oc2g,octphy,sysmo},
so we unfortunately need to apply the same fix to all copy-pasted files.

Change-Id: I557ff8cac6564d22485c101fba9212f5f0e95bb7
Related: [1] Ie0ea592da5610ae70290106d004e549cf3212a89
---
M src/osmo-bts-lc15/oml.c
M src/osmo-bts-oc2g/oml.c
M src/osmo-bts-octphy/l1_oml.c
M src/osmo-bts-sysmo/oml.c
4 files changed, 63 insertions(+), 25 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/osmo-bts-lc15/oml.c b/src/osmo-bts-lc15/oml.c
index 44139cf..39d0e5e 100644
--- a/src/osmo-bts-lc15/oml.c
+++ b/src/osmo-bts-lc15/oml.c
@@ -935,7 +935,7 @@
 	lch_par->tch.tchPlFmt = GsmL1_TchPlFmt_Rtp;
 }
 
-static void lchan2lch_par(GsmL1_LogChParam_t *lch_par, struct gsm_lchan *lchan)
+static int lchan2lch_par(GsmL1_LogChParam_t *lch_par, struct gsm_lchan *lchan)
 {
 	struct amr_multirate_conf *amr_mrc = &lchan->tch.amr_mr;
 	struct gsm48_multi_rate_conf *mr_conf =
@@ -1020,10 +1020,13 @@
 	case GSM48_CMODE_DATA_12k0:
 	case GSM48_CMODE_DATA_6k0:
 	case GSM48_CMODE_DATA_3k6:
-		LOGP(DL1C, LOGL_ERROR, "%s: CSD not supported!\n",
-			gsm_lchan_name(lchan));
-		break;
+	default:
+		LOGPLCHAN(lchan, DL1C, LOGL_ERROR, "Channel mode %s is not supported!\n",
+			  gsm48_chan_mode_name(lchan->tch_mode));
+		return -ENOTSUP;
 	}
+
+	return 0;
 }
 
 static int mph_send_activate_req(struct gsm_lchan *lchan, struct sapi_cmd *cmd)
@@ -1032,6 +1035,7 @@
 	struct msgb *msg = l1p_msgb_alloc();
 	int sapi = cmd->sapi;
 	int dir = cmd->dir;
+	int rc;
 	GsmL1_MphActivateReq_t *act_req;
 	GsmL1_LogChParam_t *lch_par;
 
@@ -1054,7 +1058,10 @@
 		break;
 	case GsmL1_Sapi_TchH:
 	case GsmL1_Sapi_TchF:
-		lchan2lch_par(lch_par, lchan);
+		if ((rc = lchan2lch_par(lch_par, lchan)) != 0) {
+			talloc_free(msg);
+			return rc;
+		}
 		/*
 		 * Be sure that every packet is received, even if it
 		 * fails. In this case the length might be lower or 0.
@@ -1390,6 +1397,7 @@
 	struct msgb *msg = l1p_msgb_alloc();
 	GsmL1_MphConfigReq_t *conf_req;
 	GsmL1_LogChParam_t *lch_par;
+	int rc;
 
 	/* channel mode, encryption and/or multirate have changed */
 
@@ -1404,7 +1412,10 @@
 	conf_req->hLayer3 = (HANDLE)l1if_lchan_to_hLayer(lchan);
 
 	lch_par = &conf_req->cfgParams.setLogChParams.logChParams;
-	lchan2lch_par(lch_par, lchan);
+	if ((rc = lchan2lch_par(lch_par, lchan)) != 0) {
+		talloc_free(msg);
+		return rc;
+	}
 
 	/* Update the MS Power Level */
 	if (cmd->sapi == GsmL1_Sapi_Sacch && trx_ms_pwr_ctrl_is_osmo(trx))
diff --git a/src/osmo-bts-oc2g/oml.c b/src/osmo-bts-oc2g/oml.c
index ced6ad1..8fd3688 100644
--- a/src/osmo-bts-oc2g/oml.c
+++ b/src/osmo-bts-oc2g/oml.c
@@ -950,7 +950,7 @@
 	lch_par->tch.tchPlFmt = GsmL1_TchPlFmt_Rtp;
 }
 
-static void lchan2lch_par(GsmL1_LogChParam_t *lch_par, struct gsm_lchan *lchan)
+static int lchan2lch_par(GsmL1_LogChParam_t *lch_par, struct gsm_lchan *lchan)
 {
 	struct amr_multirate_conf *amr_mrc = &lchan->tch.amr_mr;
 	struct gsm48_multi_rate_conf *mr_conf =
@@ -1035,10 +1035,13 @@
 	case GSM48_CMODE_DATA_12k0:
 	case GSM48_CMODE_DATA_6k0:
 	case GSM48_CMODE_DATA_3k6:
-		LOGP(DL1C, LOGL_ERROR, "%s: CSD not supported!\n",
-			gsm_lchan_name(lchan));
-		break;
+	default:
+		LOGPLCHAN(lchan, DL1C, LOGL_ERROR, "Channel mode %s is not supported!\n",
+			  gsm48_chan_mode_name(lchan->tch_mode));
+		return -ENOTSUP;
 	}
+
+	return 0;
 }
 
 static int mph_send_activate_req(struct gsm_lchan *lchan, struct sapi_cmd *cmd)
@@ -1047,6 +1050,7 @@
 	struct msgb *msg = l1p_msgb_alloc();
 	int sapi = cmd->sapi;
 	int dir = cmd->dir;
+	int rc;
 	GsmL1_MphActivateReq_t *act_req;
 	GsmL1_LogChParam_t *lch_par;
 
@@ -1069,7 +1073,10 @@
 		break;
 	case GsmL1_Sapi_TchH:
 	case GsmL1_Sapi_TchF:
-		lchan2lch_par(lch_par, lchan);
+		if ((rc = lchan2lch_par(lch_par, lchan)) != 0) {
+			talloc_free(msg);
+			return rc;
+		}
 		/*
 		 * Be sure that every packet is received, even if it
 		 * fails. In this case the length might be lower or 0.
@@ -1401,6 +1408,7 @@
 	struct msgb *msg = l1p_msgb_alloc();
 	GsmL1_MphConfigReq_t *conf_req;
 	GsmL1_LogChParam_t *lch_par;
+	int rc;
 
 	/* channel mode, encryption and/or multirate have changed */
 
@@ -1415,7 +1423,10 @@
 	conf_req->hLayer3 = (HANDLE)l1if_lchan_to_hLayer(lchan);
 
 	lch_par = &conf_req->cfgParams.setLogChParams.logChParams;
-	lchan2lch_par(lch_par, lchan);
+	if ((rc = lchan2lch_par(lch_par, lchan)) != 0) {
+		talloc_free(msg);
+		return rc;
+	}
 
 	/* Update the MS Power Level */
 	if (cmd->sapi == GsmL1_Sapi_Sacch && trx_ms_pwr_ctrl_is_osmo(trx))
diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c
index bf17125..b7f4935 100644
--- a/src/osmo-bts-octphy/l1_oml.c
+++ b/src/osmo-bts-octphy/l1_oml.c
@@ -250,7 +250,7 @@
 		p_Config->abyRate[i] = cOCTVC1_GSM_AMR_CODEC_MODE_ENUM_UNSET;
 }
 
-static void lchan2lch_par(struct gsm_lchan *lchan,
+static int lchan2lch_par(struct gsm_lchan *lchan,
 		   tOCTVC1_GSM_LOGICAL_CHANNEL_CONFIG * p_Config)
 {
 	struct amr_multirate_conf *amr_mrc = &lchan->tch.amr_mr;
@@ -348,11 +348,13 @@
 	case GSM48_CMODE_DATA_12k0:
 	case GSM48_CMODE_DATA_6k0:
 	case GSM48_CMODE_DATA_3k6:
-		LOGP(DL1C, LOGL_ERROR, "%s: CSD not supported!\n",
-		     gsm_lchan_name(lchan));
-		break;
-
+	default:
+		LOGPLCHAN(lchan, DL1C, LOGL_ERROR, "Channel mode %s is not supported!\n",
+			  gsm48_chan_mode_name(lchan->tch_mode));
+		return -ENOTSUP;
 	}
+
+	return 0;
 }
 
 /***********************************************************************
@@ -444,6 +446,7 @@
 	struct octphy_hdl *fl1h = pinst->phy_link->u.octphy.hdl;
 	struct msgb *msg = l1p_msgb_alloc();
 	tOCTVC1_GSM_MSG_TRX_ACTIVATE_LOGICAL_CHANNEL_CMD *lac;
+	int rc;
 
 	lac = (tOCTVC1_GSM_MSG_TRX_ACTIVATE_LOGICAL_CHANNEL_CMD *)
 			msgb_put(msg, sizeof(*lac));
@@ -458,8 +461,10 @@
 
 	lac->Config.byTimingAdvance = lchan->rqd_ta;
 	lac->Config.byBSIC = lchan->ts->trx->bts->bsic;
-
-	lchan2lch_par(lchan, &lac->Config);
+	if ((rc = lchan2lch_par(lchan, &lac->Config)) != 0) {
+		talloc_free(msg);
+		return rc;
+	}
 
 	mOCTVC1_GSM_MSG_TRX_ACTIVATE_LOGICAL_CHANNEL_CMD_SWAP(lac);
 
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index 8e38c60..ac3176c 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -943,7 +943,7 @@
 #endif /* L1_HAS_RTP_MODE */
 }
 
-static void lchan2lch_par(GsmL1_LogChParam_t *lch_par, struct gsm_lchan *lchan)
+static int lchan2lch_par(GsmL1_LogChParam_t *lch_par, struct gsm_lchan *lchan)
 {
 	struct amr_multirate_conf *amr_mrc = &lchan->tch.amr_mr;
 	struct gsm48_multi_rate_conf *mr_conf =
@@ -1028,10 +1028,13 @@
 	case GSM48_CMODE_DATA_12k0:
 	case GSM48_CMODE_DATA_6k0:
 	case GSM48_CMODE_DATA_3k6:
-		LOGP(DL1C, LOGL_ERROR, "%s: CSD not supported!\n",
-			gsm_lchan_name(lchan));
-		break;
+	default:
+		LOGPLCHAN(lchan, DL1C, LOGL_ERROR, "Channel mode %s is not supported!\n",
+			  gsm48_chan_mode_name(lchan->tch_mode));
+		return -ENOTSUP;
 	}
+
+	return 0;
 }
 
 static int mph_send_activate_req(struct gsm_lchan *lchan, struct sapi_cmd *cmd)
@@ -1040,6 +1043,7 @@
 	struct msgb *msg = l1p_msgb_alloc();
 	int sapi = cmd->sapi;
 	int dir = cmd->dir;
+	int rc;
 	GsmL1_MphActivateReq_t *act_req;
 	GsmL1_LogChParam_t *lch_par;
 
@@ -1062,7 +1066,10 @@
 		break;
 	case GsmL1_Sapi_TchH:
 	case GsmL1_Sapi_TchF:
-		lchan2lch_par(lch_par, lchan);
+		if ((rc = lchan2lch_par(lch_par, lchan)) != 0) {
+			talloc_free(msg);
+			return rc;
+		}
 		/*
 		 * Be sure that every packet is received, even if it
 		 * fails. In this case the length might be lower or 0.
@@ -1347,6 +1354,7 @@
 	struct msgb *msg = l1p_msgb_alloc();
 	GsmL1_MphConfigReq_t *conf_req;
 	GsmL1_LogChParam_t *lch_par;
+	int rc;
 
 	/* channel mode, encryption and/or multirate have changed */
 
@@ -1361,7 +1369,10 @@
 	conf_req->hLayer3 = l1if_lchan_to_hLayer(lchan);
 
 	lch_par = &conf_req->cfgParams.setLogChParams.logChParams;
-	lchan2lch_par(lch_par, lchan);
+	if ((rc = lchan2lch_par(lch_par, lchan)) != 0) {
+		talloc_free(msg);
+		return rc;
+	}
 
 	/* Update the MS Power Level */
 	if (cmd->sapi == GsmL1_Sapi_Sacch && trx_ms_pwr_ctrl_is_osmo(trx))

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I557ff8cac6564d22485c101fba9212f5f0e95bb7
Gerrit-Change-Number: 23816
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210421/b2853033/attachment.htm>


More information about the gerrit-log mailing list