mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-09 22:08:56 +08:00
fix(param): restore half-open interval bound in param_find binary search
The grouped-parameter refactor changed `last = param_info_count` to `last = param_info_count - 1` in `param_find_internal`. The binary search uses a half-open interval (`front <= last`, with `middle == front` as the termination condition), so shrinking `last` by one made the highest-named parameter unreachable. SITL exportImportAll caught this: BSON verify rejected `WV_YRATE_MAX` as `invalid parameter`, making `param_save_default` fail and tripping the `sitl-parameters` ctest. Restore the original upper bound. The added nullptr guards remain since they harden the path against an unset `param_info_count`. Signed-off-by: Nuno Marques <n.marques21@hotmail.com>
This commit is contained in:
@@ -189,7 +189,7 @@ static param_t param_find_internal(const char *name, bool notification)
|
||||
|
||||
param_t middle;
|
||||
param_t front = 0;
|
||||
param_t last = param_info_count - 1;
|
||||
param_t last = param_info_count;
|
||||
|
||||
/* perform a binary search of the known parameters */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user