Put the 'CORRUPTED CONFIG' message on a line of its own as well.

This commit is contained in:
mikeller 2019-02-22 03:50:01 +13:00
parent bad72c884a
commit 31e8b0425c
1 changed files with 24 additions and 17 deletions

View File

@ -390,19 +390,23 @@ static void cliPrintLinef(const char *format, ...)
cliPrintLinefeed();
}
static void cliPrintErrorLinef(const char *format, ...)
static void cliPrintError(const char *format, ...)
{
cliPrint("###ERROR: ");
va_list va;
va_start(va, format);
cliPrintfva(format, va);
va_end(va);
cliPrintLine("###");
cliPrint("###");
}
static void cliPrintCorruptMessage(int value)
static void cliPrintErrorLinef(const char *format, ...)
{
cliPrintf("%d ###ERROR: CORRUPTED CONFIG###", value);
va_list va;
va_start(va, format);
cliPrintError(format, va);
va_end(va);
cliPrintLinefeed();
}
static void getMinMax(const clivalue_t *var, int *min, int *max)
@ -479,29 +483,26 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
break;
}
bool valueIsCorrupted = false;
switch (var->type & VALUE_MODE_MASK) {
case MODE_DIRECT:
if ((var->type & VALUE_TYPE_MASK) == VAR_UINT32) {
cliPrintf("%d", value);
if ((uint32_t) value > var->config.u32Max) {
cliPrintCorruptMessage(value);
} else {
cliPrintf("%d", value);
if (full) {
cliPrintf(" 0 %d", var->config.u32Max);
}
valueIsCorrupted = true;
} else if (full) {
cliPrintf(" 0 %d", var->config.u32Max);
}
} else {
int min;
int max;
getMinMax(var, &min, &max);
cliPrintf("%d", value);
if ((value < min) || (value > max)) {
cliPrintCorruptMessage(value);
} else {
cliPrintf("%d", value);
if (full) {
cliPrintf(" %d %d", min, max);
}
valueIsCorrupted = true;
} else if (full) {
cliPrintf(" %d %d", min, max);
}
}
break;
@ -509,7 +510,7 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
if (value < lookupTables[var->config.lookup.tableIndex].valueCount) {
cliPrint(lookupTables[var->config.lookup.tableIndex].values[value]);
} else {
cliPrintCorruptMessage(value);
valueIsCorrupted = true;
}
break;
case MODE_BITSET:
@ -519,6 +520,11 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
cliPrintf("OFF");
}
}
if (valueIsCorrupted) {
cliPrintLinefeed();
cliPrintError("CORRUPTED CONFIG: %s = %d", var->name, value);
}
}
}
@ -3830,6 +3836,7 @@ STATIC_UNIT_TESTED void cliGet(char *cmdline)
}
cliPrintVarRange(val);
cliPrintVarDefault(val);
matchedCommands++;
}
}