Change in osmo-bts[master]: osmo-bts-{lc15, oc2g}: drop redundant checks in VTY commands

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

fixeria gerrit-no-reply at lists.osmocom.org
Tue May 11 08:45:22 UTC 2021


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

Change subject: osmo-bts-{lc15,oc2g}: drop redundant checks in VTY commands
......................................................................

osmo-bts-{lc15,oc2g}: drop redundant checks in VTY commands

Change-Id: I4fea6d661b7193c3a04e88c9399a9e2bc402254f
---
M src/osmo-bts-lc15/lc15bts_vty.c
M src/osmo-bts-oc2g/oc2gbts_vty.c
2 files changed, 6 insertions(+), 84 deletions(-)

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



diff --git a/src/osmo-bts-lc15/lc15bts_vty.c b/src/osmo-bts-lc15/lc15bts_vty.c
index 4a9d790..be6a4f8 100644
--- a/src/osmo-bts-lc15/lc15bts_vty.c
+++ b/src/osmo-bts-lc15/lc15bts_vty.c
@@ -340,12 +340,6 @@
 	int nominal_power = atoi(argv[0]);
 	struct gsm_bts_trx *trx = vty->index;
 
-	if (( nominal_power >  40 ) ||  ( nominal_power < 0 )) {
-		vty_out(vty, "Nominal Tx power level must be between 0 and 40 dBm (%d) %s",
-		nominal_power, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	trx->nominal_power = nominal_power;
 	trx->power_params.trx_p_max_out_mdBm = to_mdB(nominal_power);
 
@@ -359,12 +353,6 @@
 	struct phy_instance *pinst = vty->index;
 	int cell_size = (uint8_t)atoi(argv[0]);
 
-	if (( cell_size >  166 ) || ( cell_size < 0 )) {
-		vty_out(vty, "Max cell size must be between 0 and 166 qbits (%d) %s",
-				cell_size, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	pinst->u.lc15.max_cell_size = (uint8_t)cell_size;
 	return CMD_SUCCESS;
 }
@@ -377,10 +365,7 @@
 	struct phy_instance *pinst = vty->index;
 	int val = get_string_value(lc15_diversity_mode_strs, argv[0]);
 
-	if((val < LC15_DIVERSITY_SISO_A) || (val > LC15_DIVERSITY_MRC)) {
-			vty_out(vty, "Invalid reception diversity mode %d%s", val, VTY_NEWLINE);
-			return CMD_WARNING;
-	}
+	OSMO_ASSERT(val != -EINVAL);
 
 	pinst->u.lc15.diversity_mode = (uint8_t)val;
 	return CMD_SUCCESS;
@@ -394,10 +379,7 @@
 	struct phy_instance *pinst = vty->index;
 	int val = get_string_value(lc15_pedestal_mode_strs, argv[0]);
 
-	if((val < LC15_PEDESTAL_OFF)  || (val > LC15_PEDESTAL_ON)) {
-			vty_out(vty, "Invalid unused time-slot transmission mode %d%s", val, VTY_NEWLINE);
-			return CMD_WARNING;
-	}
+	OSMO_ASSERT(val != -EINVAL);
 
 	pinst->u.lc15.pedestal_mode = (uint8_t)val;
 	return CMD_SUCCESS;
@@ -411,10 +393,7 @@
 	struct gsm_bts *bts = vty->index;
 	int val = get_string_value(lc15_led_mode_strs, argv[0]);
 
-	if((val < LC15_LED_CONTROL_BTS)  || (val > LC15_LED_CONTROL_EXT)) {
-			vty_out(vty, "Invalid LED control mode %d%s", val, VTY_NEWLINE);
-			return CMD_WARNING;
-	}
+	OSMO_ASSERT(val != -EINVAL);
 
         struct bts_lc15_priv *bts_lc15 = bts->model_priv;
 	bts_lc15->led_ctrl_mode = (uint8_t)val;
@@ -429,12 +408,6 @@
 	struct phy_instance *pinst = vty->index;
 	uint8_t period = (uint8_t)atoi(argv[0]);
 
-	if (( period >  60 ) || ( period < 0 )) {
-		vty_out(vty, "DSP heart beat alive timer period must be between 0 and 60 seconds (%d) %s",
-				period, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	pinst->u.lc15.dsp_alive_period = period;
 	return CMD_SUCCESS;
 }
@@ -446,10 +419,7 @@
 	struct phy_instance *pinst = vty->index;
 	int val = get_string_value(lc15_auto_adj_pwr_strs, argv[0]);
 
-	if((val < LC15_TX_PWR_ADJ_NONE) || (val > LC15_TX_PWR_ADJ_AUTO)) {
-		vty_out(vty, "Invalid output power adjustment mode %d%s", val, VTY_NEWLINE);
-	return CMD_WARNING;
-	}
+	OSMO_ASSERT(val != -EINVAL);
 
 	pinst->u.lc15.tx_pwr_adj_mode = (uint8_t)val;
 	return CMD_SUCCESS;
@@ -462,12 +432,6 @@
 	struct phy_instance *pinst = vty->index;
 	int val = atoi(argv[0]);
 
-	if ((val > 40) || (val < 0)) {
-		vty_out(vty, "Reduction Tx power level must be between 0 and 40 dB (%d) %s",
-		val, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	pinst->u.lc15.tx_pwr_red_8psk = (uint8_t)val;
 	return CMD_SUCCESS;
 }
@@ -479,12 +443,6 @@
 	struct phy_instance *pinst = vty->index;
 	int val = atoi(argv[0]);
 
-	if ((val > 40) || (val < 0)) {
-		vty_out(vty, "Reduction Tx power level must be between 0 and 40 dB (%d) %s",
-		val, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	pinst->u.lc15.tx_c0_idle_pwr_red = (uint8_t)val;
 	return CMD_SUCCESS;
 }
diff --git a/src/osmo-bts-oc2g/oc2gbts_vty.c b/src/osmo-bts-oc2g/oc2gbts_vty.c
index c3b2a31..d69225a 100644
--- a/src/osmo-bts-oc2g/oc2gbts_vty.c
+++ b/src/osmo-bts-oc2g/oc2gbts_vty.c
@@ -333,12 +333,6 @@
 	int nominal_power = atoi(argv[0]);
 	struct gsm_bts_trx *trx = vty->index;
 
-	if (( nominal_power > 25 ) ||  ( nominal_power < 0 )) {
-		vty_out(vty, "Nominal Tx power level must be between 0 and 25 dBm (%d) %s",
-		nominal_power, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	trx->nominal_power = nominal_power;
 	trx->power_params.trx_p_max_out_mdBm = to_mdB(nominal_power);
 
@@ -352,12 +346,6 @@
 	struct phy_instance *pinst = vty->index;
 	int cell_size = (uint8_t)atoi(argv[0]);
 
-	if (( cell_size >  166 ) || ( cell_size < 0 )) {
-		vty_out(vty, "Max cell size must be between 0 and 166 qbits (%d) %s",
-				cell_size, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	pinst->u.oc2g.max_cell_size = (uint8_t)cell_size;
 	return CMD_SUCCESS;
 }
@@ -370,10 +358,7 @@
 	struct phy_instance *pinst = vty->index;
 	int val = get_string_value(oc2g_pedestal_mode_strs, argv[0]);
 
-	if((val < OC2G_PEDESTAL_OFF)  || (val > OC2G_PEDESTAL_ON)) {
-			vty_out(vty, "Invalid unused time-slot transmission mode %d%s", val, VTY_NEWLINE);
-			return CMD_WARNING;
-	}
+	OSMO_ASSERT(val != -EINVAL);
 
 	pinst->u.oc2g.pedestal_mode = (uint8_t)val;
 	return CMD_SUCCESS;
@@ -386,12 +371,6 @@
 	struct phy_instance *pinst = vty->index;
 	uint8_t period = (uint8_t)atoi(argv[0]);
 
-	if (( period >  60 ) || ( period < 0 )) {
-		vty_out(vty, "DSP heart beat alive timer period must be between 0 and 60 seconds (%d) %s",
-				period, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	pinst->u.oc2g.dsp_alive_period = period;
 	return CMD_SUCCESS;
 }
@@ -403,10 +382,7 @@
 	struct phy_instance *pinst = vty->index;
 	int val = get_string_value(oc2g_auto_adj_pwr_strs, argv[0]);
 
-	if((val < OC2G_TX_PWR_ADJ_NONE) || (val > OC2G_TX_PWR_ADJ_AUTO)) {
-		vty_out(vty, "Invalid output power adjustment mode %d%s", val, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
+	OSMO_ASSERT(val != -EINVAL);
 
 	pinst->u.oc2g.tx_pwr_adj_mode = (uint8_t)val;
 	return CMD_SUCCESS;
@@ -419,12 +395,6 @@
 	struct phy_instance *pinst = vty->index;
 	int val = atoi(argv[0]);
 
-	if ((val > 40) || (val < 0)) {
-		vty_out(vty, "Reduction Tx power level must be between 0 and 40 dB (%d) %s",
-		val, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	pinst->u.oc2g.tx_pwr_red_8psk = (uint8_t)val;
 	return CMD_SUCCESS;
 }
@@ -436,12 +406,6 @@
 	struct phy_instance *pinst = vty->index;
 	int val = atoi(argv[0]);
 
-	if ((val > 40) || (val < 0)) {
-		vty_out(vty, "Reduction Tx power level must be between 0 and 40 dB (%d) %s",
-		val, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
 	pinst->u.oc2g.tx_c0_idle_pwr_red = (uint8_t)val;
 	return CMD_SUCCESS;
 }

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I4fea6d661b7193c3a04e88c9399a9e2bc402254f
Gerrit-Change-Number: 24199
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210511/80a9ccc8/attachment.htm>


More information about the gerrit-log mailing list