From 711cee9dfacf3ba18260f8bc9d17aa73248cb48c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell <tridge@samba.org> Date: Mon, 13 Feb 2012 07:43:09 +1100 Subject: [PATCH] fixed support for AP_PARAM_SPARE spare group elements are needed if we remove a group parameter --- libraries/AP_Common/AP_Param.cpp | 9 ++++++++- libraries/AP_Common/AP_Param.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Common/AP_Param.cpp b/libraries/AP_Common/AP_Param.cpp index cee87b8ca9..2fd8851a0c 100644 --- a/libraries/AP_Common/AP_Param.cpp +++ b/libraries/AP_Common/AP_Param.cpp @@ -148,7 +148,8 @@ bool AP_Param::check_var_info(void) } else { uint8_t size = type_size((enum ap_var_type)type); if (size == 0) { - // not a valid type - the top level list can't contain AP_PARAM_NONE + // not a valid type - the top level list can't contain + // AP_PARAM_NONE or AP_PARAM_SPARE return false; } total_size += size + sizeof(struct Param_header); @@ -287,6 +288,8 @@ const struct AP_Param::Info *AP_Param::find_var_info_group(const struct GroupInf if (info != NULL) { return info; } + } else if (type == AP_PARAM_SPARE) { + continue; } else if ((uintptr_t)this == base + PGM_POINTER(&group_info[i].offset)) { *group_element = GROUP_OFFSET(group_base, i, group_shift); *group_ret = &group_info[i]; @@ -413,6 +416,8 @@ AP_Param::find_group(const char *name, uint8_t vindex, const struct GroupInfo *g if (ap != NULL) { return ap; } + } else if (type == AP_PARAM_SPARE) { + continue; } else if (strcasecmp_P(name, group_info[i].name) == 0) { uintptr_t p = PGM_POINTER(&_var_info[vindex].ptr); *ptype = (enum ap_var_type)type; @@ -591,6 +596,8 @@ AP_Param *AP_Param::next_group(uint8_t vindex, const struct GroupInfo *group_inf if (ap != NULL) { return ap; } + } else if (type == AP_PARAM_SPARE) { + continue; } else { if (*found_current) { // got a new one diff --git a/libraries/AP_Common/AP_Param.h b/libraries/AP_Common/AP_Param.h index fcccd44482..0c6a479f3d 100644 --- a/libraries/AP_Common/AP_Param.h +++ b/libraries/AP_Common/AP_Param.h @@ -33,6 +33,11 @@ // declare a group var_info line #define AP_GROUPINFO(name, class, element) { AP_CLASSTYPE(class, element), name, AP_VAROFFSET(class, element) } +// declare a spare (unused) group var_info line +// use these when a parameter is removed to ensure that the index of +// the other parameters doesn't change +#define AP_GROUPSPARE { AP_PARAM_SPARE, "" } + // declare a nested group entry in a group var_info #define AP_NESTEDGROUPINFO(class) { AP_PARAM_GROUP, "", 0, class::var_info }