1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 20:10:18 +03:00

Allow the use of NULL values in CLI lookup tables. (#5489)

This commit is contained in:
Michael Keller 2018-03-22 06:13:02 +13:00 committed by Andrey Mironov
parent 3a917a3755
commit 09f52d420d

View file

@ -489,10 +489,13 @@ static void cliPrintVarRange(const clivalue_t *var)
case (MODE_LOOKUP): {
const lookupTableEntry_t *tableEntry = &lookupTables[var->config.lookup.tableIndex];
cliPrint("Allowed values:");
for (uint32_t i = 0; i < tableEntry->valueCount ; i++) {
if (i > 0)
cliPrint(",");
cliPrintf(" %s", tableEntry->values[i]);
for (uint32_t i = 0; i < tableEntry->valueCount; i++) {
if (tableEntry->values[i]) {
cliPrintf(" %s", tableEntry->values[i]);
if (i + 1 < tableEntry->valueCount) {
cliPrint(",");
}
}
}
cliPrintLinefeed();
}
@ -2965,7 +2968,7 @@ STATIC_UNIT_TESTED void cliSet(char *cmdline)
const lookupTableEntry_t *tableEntry = &lookupTables[val->config.lookup.tableIndex];
bool matched = false;
for (uint32_t tableValueIndex = 0; tableValueIndex < tableEntry->valueCount && !matched; tableValueIndex++) {
matched = strcasecmp(tableEntry->values[tableValueIndex], eqptr) == 0;
matched = tableEntry->values[tableValueIndex] && strcasecmp(tableEntry->values[tableValueIndex], eqptr) == 0;
if (matched) {
value = tableValueIndex;