aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-trx/loops.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-04-16 14:48:34 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-04-16 14:55:40 +0200
commitbea9c3330e949957b5e3a379e0bb75c767816e57 (patch)
tree9b99ceb1e6adbf7d502c76e8d08d95f915ee3735 /src/osmo-bts-trx/loops.c
parentdd4a6518f2118775c12affc02ac1e0dcc848d89a (diff)
osmo-bts-trx: fix MS power loop: remove extranous increment
Increment chan_state->meas.rssi_valid_count only once, to record only valid rssi values, instead of interleaving with zero at every second element. Theoretically, the index within chan_state->meas.rssi[] could even walk past the array end, practically didn't only because the array size is even. To be superficially safer, change the condition from == to >=.
Diffstat (limited to 'src/osmo-bts-trx/loops.c')
-rw-r--r--src/osmo-bts-trx/loops.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c
index a959a71..2e54023 100644
--- a/src/osmo-bts-trx/loops.c
+++ b/src/osmo-bts-trx/loops.c
@@ -102,11 +102,9 @@ static int ms_power_val(struct l1sched_chan_state *chan_state, int8_t rssi)
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 0;
chan_state->meas.rssi[chan_state->meas.rssi_valid_count++] = rssi;
- chan_state->meas.rssi_valid_count++;
return 0;
}