fixeria submitted this change.
tx_power: get_pa_drive_level_mdBm(): assert on out-of-range ARFCN
The function previously returned `INT_MIN` as an error sentinel when
the ARFCN exceeded the calibration table size (1024 entries, covering
all valid GSM ARFCNs 0..1023). None of the callers checked for this
value, so it would silently propagate through power calculations and
eventually be passed to `bts_model_change_power()`.
An out-of-range ARFCN indicates a serious misconfiguration;
replace the range check and `return INT_MIN` with an `OSMO_ASSERT`.
Change-Id: I70c54652e0b07d399363276bc60946aa8b195725
---
M src/common/tx_power.c
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/common/tx_power.c b/src/common/tx_power.c
index 83cdb62..1e026dd 100644
--- a/src/common/tx_power.c
+++ b/src/common/tx_power.c
@@ -20,7 +20,6 @@
*/
#include <stdint.h>
-#include <limits.h>
#include <errno.h>
#include <osmocom/core/utils.h>
@@ -34,8 +33,7 @@
static int get_pa_drive_level_mdBm(const struct power_amp *pa,
int desired_p_out_mdBm, unsigned int arfcn)
{
- if (arfcn >= ARRAY_SIZE(pa->calib.delta_mdB))
- return INT_MIN;
+ OSMO_ASSERT(arfcn < ARRAY_SIZE(pa->calib.delta_mdB));
/* FIXME: temperature compensation */
To view, visit change 42510. To unsubscribe, or for help writing mail filters, visit settings.