Fix link failure on non-ADC targets from unconditional checkBatteryVoltageState() call - #11865
Conversation
…ltageState() call checkBatteryVoltageState() is only defined inside #ifdef USE_ADC in battery.c, but osdDisplayBatteryVoltage() and the multifunction low-battery warning check both called it unconditionally. Any target without USE_ADC (e.g. COLIBRI/QUANTON, which have no analog battery-voltage sensing at all) fails to link with an undefined reference. Both call sites now use getBatteryState(), which is defined unconditionally and returns the same cached state - multifunction.c already uses it two lines later for the equivalent capacity-based warning check. This restores the behavior both call sites had before the voltage-state check was extracted into checkBatteryVoltageState() (commit f3de644, 2023-02-07), which is when this bug was introduced.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoFix non-ADC link failure in battery warning call sites
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
|
This isn't the right way to fix this. Probably best to just make multifunction and OSD voltage conditional on |
Thank you! |
The previous commit fixed the non-ADC link failure by switching both call sites to getBatteryState(), but that broke voltage-specific semantics: when capacity thresholds are enabled, getBatteryState() returns capacity-derived state, so the voltage warning/blink would duplicate the capacity warning (e.g. reporting VBATT LOW on healthy voltage) or miss a genuine low-voltage condition while capacity is fine. Caught by review (qodo bot + breadoven) on PR iNavFlight#11865. Both call sites now use checkBatteryVoltageState() again, guarded by #ifdef USE_ADC (the only compilation unit it's defined in). On non-ADC targets there's no voltage to display or warn about, so the voltage warning/blink is simply omitted instead of substituting unrelated state - restoring correct behavior on ADC targets while still fixing the link error on non-ADC ones.
|
Good catch, thanks! Pushed a fix. Both call sites now use |
|
Test firmware build ready — commit Download firmware for PR #11865 249 targets built. Find your board's
|
Summary
checkBatteryVoltageState()is defined only inside#ifdef USE_ADCinsrc/main/sensors/battery.c, but two call sites invoked it unconditionally:src/main/io/osd.c—osdDisplayBatteryVoltage()src/main/fc/multifunction.c— the low-battery-voltage warning checkAny target that doesn't define
USE_ADCfails to link withundefined reference to checkBatteryVoltageState. This affects COLIBRI and QUANTON, which have no analog battery-voltage sensing hardware at all. Bisected the regression to commit f3de644 ("osd batt cleanup", 2023-02-07), which extracted the voltage-state check out of the always-definedgetBatteryState()path into the new ADC-only function without updating these two unconditional callers. It went unnoticed because both affected targets areSKIP_RELEASESand aren't in the normal release build sweep.Changes
getBatteryState()instead, which is defined unconditionally and returns the same cached state.multifunction.calready usesgetBatteryState()two lines later for the equivalent capacity-based warning check, so this also makes the two checks consistent with each other.Testing