param: Fix an off by 1 issue and some style fixes.

This commit is contained in:
Stephan Brown
2017-01-04 14:45:39 -08:00
committed by Beat Küng
parent fe8deeeed9
commit bf57e86dc2
2 changed files with 12 additions and 4 deletions
+8 -3
View File
@@ -263,25 +263,30 @@ param_find_internal(const char *name, bool notification)
{
param_t middle;
param_t front = 0;
param_t last = get_param_info_count()-1;
param_t last = get_param_info_count() - 1;
/* perform a binary search of the known parameters */
while (front <= last) {
middle = front + (last-front) / 2;
middle = front + (last - front) / 2;
int ret = strcmp(name, param_info_base[middle].name);
if (ret == 0) {
if (notification) {
param_set_used_internal(middle);
}
return middle;
} else if (middle == front || middle == last) {
/* An end point has been hit, but there has been no match */
break;
} else if (ret < 0) {
last = middle - 1;
} else {
front = middle + 1;
front = middle;
}
}