mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 20:10:18 +03:00
Merge pull request #6697 from etracer65/cli_lookup_index_validation
Add CLI validation of parameters and print a corrupted value message
This commit is contained in:
commit
3a62d40372
1 changed files with 16 additions and 4 deletions
|
@ -385,6 +385,10 @@ static void cliPrintErrorLinef(const char *format, ...)
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cliPrintCorruptMessage(int value)
|
||||||
|
{
|
||||||
|
cliPrintf("%d ###CORRUPTED CONFIG###", value);
|
||||||
|
}
|
||||||
|
|
||||||
static void printValuePointer(const clivalue_t *var, const void *valuePointer, bool full)
|
static void printValuePointer(const clivalue_t *var, const void *valuePointer, bool full)
|
||||||
{
|
{
|
||||||
|
@ -440,13 +444,21 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
|
||||||
|
|
||||||
switch (var->type & VALUE_MODE_MASK) {
|
switch (var->type & VALUE_MODE_MASK) {
|
||||||
case MODE_DIRECT:
|
case MODE_DIRECT:
|
||||||
cliPrintf("%d", value);
|
if ((value < var->config.minmax.min) || (value > var->config.minmax.max)) {
|
||||||
if (full) {
|
cliPrintCorruptMessage(value);
|
||||||
cliPrintf(" %d %d", var->config.minmax.min, var->config.minmax.max);
|
} else {
|
||||||
|
cliPrintf("%d", value);
|
||||||
|
if (full) {
|
||||||
|
cliPrintf(" %d %d", var->config.minmax.min, var->config.minmax.max);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MODE_LOOKUP:
|
case MODE_LOOKUP:
|
||||||
cliPrint(lookupTables[var->config.lookup.tableIndex].values[value]);
|
if (value < lookupTables[var->config.lookup.tableIndex].valueCount) {
|
||||||
|
cliPrint(lookupTables[var->config.lookup.tableIndex].values[value]);
|
||||||
|
} else {
|
||||||
|
cliPrintCorruptMessage(value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MODE_BITSET:
|
case MODE_BITSET:
|
||||||
if (value & 1 << var->config.bitpos) {
|
if (value & 1 << var->config.bitpos) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue