AP_Param: fixed bug with deeply nested parameter trees

enumeration could loop forever if the IDs overlapped due to 8 bit
masking
This commit is contained in:
Andrew Tridgell 2016-10-22 18:10:11 +11:00
parent 1e2e24eeac
commit 68f0777dac
2 changed files with 6 additions and 6 deletions

View File

@ -113,7 +113,7 @@ void AP_Param::erase_all(void)
level gets the next 6 bits, and the 3rd level gets the last 6
bits. This limits groups to having at most 64 elements.
*/
uint32_t AP_Param::group_id(const struct GroupInfo *grpinfo, uint8_t base, uint8_t i, uint8_t shift)
uint32_t AP_Param::group_id(const struct GroupInfo *grpinfo, uint32_t base, uint8_t i, uint8_t shift)
{
if (grpinfo[i].idx == 0 && shift != 0 && !(grpinfo[i].flags & AP_PARAM_NO_SHIFT)) {
/*
@ -310,7 +310,7 @@ bool AP_Param::get_base(const struct Info &info, ptrdiff_t &base)
const struct AP_Param::Info *AP_Param::find_by_header_group(struct Param_header phdr, void **ptr,
uint16_t vindex,
const struct GroupInfo *group_info,
uint8_t group_base,
uint32_t group_base,
uint8_t group_shift,
ptrdiff_t group_offset)
{
@ -1329,7 +1329,7 @@ AP_Param *AP_Param::first(ParamToken *token, enum ap_var_type *ptype)
/// as needed
AP_Param *AP_Param::next_group(uint16_t vindex, const struct GroupInfo *group_info,
bool *found_current,
uint8_t group_base,
uint32_t group_base,
uint8_t group_shift,
ptrdiff_t group_offset,
ParamToken *token,

View File

@ -168,7 +168,7 @@ public:
// level of nesting, so the first level of nesting gets 6 bits the 2nd
// level gets the next 6 bits, and the 3rd level gets the last 6
// bits. This limits groups to having at most 64 elements.
static uint32_t group_id(const struct GroupInfo *grpinfo, uint8_t base, uint8_t i, uint8_t shift);
static uint32_t group_id(const struct GroupInfo *grpinfo, uint32_t base, uint8_t i, uint8_t shift);
/// Copy the variable's name, prefixed by any containing group name, to a
/// buffer.
@ -418,7 +418,7 @@ private:
struct Param_header phdr, void **ptr,
uint16_t vindex,
const struct GroupInfo *group_info,
uint8_t group_base,
uint32_t group_base,
uint8_t group_shift,
ptrdiff_t group_offset);
static const struct Info * find_by_header(
@ -450,7 +450,7 @@ private:
uint16_t vindex,
const struct GroupInfo *group_info,
bool *found_current,
uint8_t group_base,
uint32_t group_base,
uint8_t group_shift,
ptrdiff_t group_offset,
ParamToken *token,