Change in osmo-bts[master]: osmo-bts-trx/loops.c: Make code control flow more readable

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Dec 12 23:10:03 UTC 2018


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/12290


Change subject: osmo-bts-trx/loops.c: Make code control flow more readable
......................................................................

osmo-bts-trx/loops.c: Make code control flow more readable

Use the 'else' construct where applicable to avoid too many return paths
from functions

Change-Id: I819f0c80e90855e8b3252795c837f8e3053b6e87
Related: OS#1622, OS#1851
---
M src/osmo-bts-trx/loops.c
1 file changed, 9 insertions(+), 20 deletions(-)



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

diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c
index e9bc560..a0b979a 100644
--- a/src/osmo-bts-trx/loops.c
+++ b/src/osmo-bts-trx/loops.c
@@ -78,19 +78,15 @@
 	if (lchan->ms_power_ctrl.current == new_power) {
 		LOGPLCHAN(lchan, DLOOP, LOGL_INFO, "Keeping MS new_power at control level %d (%d dBm)\n",
 			new_power, ms_pwr_dbm(band, new_power));
+	} else {
+		LOGPLCHAN(lchan, DLOOP, LOGL_INFO, "%s MS new_power from control level %d (%d dBm) to %d (%d dBm)\n",
+			(diff > 0) ? "Raising" : "Lowering",
+			lchan->ms_power_ctrl.current, ms_pwr_dbm(band, lchan->ms_power_ctrl.current),
+			new_power, ms_pwr_dbm(band, new_power));
 
-		return;
+		/* store the resulting new MS power level in the lchan */
+		lchan->ms_power_ctrl.current = new_power;
 	}
-
-	LOGPLCHAN(lchan, DLOOP, LOGL_INFO, "%s MS new_power from control level %d (%d dBm) to %d (%d dBm)\n",
-		(diff > 0) ? "Raising" : "Lowering",
-		lchan->ms_power_ctrl.current, ms_pwr_dbm(band, lchan->ms_power_ctrl.current),
-		new_power, ms_pwr_dbm(band, new_power));
-
-	/* store the resulting new MS power level in the lchan */
-	lchan->ms_power_ctrl.current = new_power;
-
-	return;
 }
 
 /*! Input a new RSSI value into the MS power control loop for the given logical channel.
@@ -110,8 +106,7 @@
 	chan_state->meas.rssi_got_burst = 1;
 
 	/* store and process RSSI */
-	if (chan_state->meas.rssi_valid_count
-					== ARRAY_SIZE(chan_state->meas.rssi))
+	if (chan_state->meas.rssi_valid_count == ARRAY_SIZE(chan_state->meas.rssi))
 		return;
 	chan_state->meas.rssi[chan_state->meas.rssi_valid_count++] = rssi;
 	chan_state->meas.rssi_valid_count++;
@@ -293,11 +288,7 @@
 				chan_state->dl_cmr - 1);
 			chan_state->dl_cmr--;
 		}
-		return;
-	}
-
-	/* upgrade */
-	if (chan_state->dl_cmr < chan_state->codecs - 1) {
+	} else if (chan_state->dl_cmr < chan_state->codecs - 1) {
 		/* degrade, if ber is above threshold  FIXME: C/I*/
 		if (ber <
 		    lchan->tch.amr_mr.bts_mode[chan_state->dl_cmr].threshold
@@ -307,8 +298,6 @@
 				chan_state->dl_cmr + 1);
 			chan_state->dl_cmr++;
 		}
-
-		return;
 	}
 }
 

-- 
To view, visit https://gerrit.osmocom.org/12290
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I819f0c80e90855e8b3252795c837f8e3053b6e87
Gerrit-Change-Number: 12290
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181212/29a83c93/attachment.htm>


More information about the gerrit-log mailing list