From bea9c3330e949957b5e3a379e0bb75c767816e57 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 16 Apr 2018 14:48:34 +0200 Subject: 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 >=. --- src/osmo-bts-trx/loops.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c index a959a71e..2e540233 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; } -- cgit v1.2.3