Skip to content

Commit

Permalink
Fix MODE_STRING blank value output and improve validation messages
Browse files Browse the repository at this point in the history
Emptry MODE_STRING paramaters would produce CLI output that would then generate errors if reapplied using a `diff` or `dump`. Fixed the output for blank values to be compatible with setting an empty string (clearing a previous value).

Also improve the length validation to report the allowed character range.
  • Loading branch information
etracer65 committed May 7, 2019
1 parent 1cbff2b commit f572227
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/cli/cli.c
Expand Up @@ -542,7 +542,7 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
}
break;
case MODE_STRING:
cliPrintf("%s", (char *)valuePointer);
cliPrintf("%s", (strlen((char *)valuePointer) == 0) ? "-" : (char *)valuePointer);
break;
}

Expand Down Expand Up @@ -4162,6 +4162,8 @@ STATIC_UNIT_TESTED void cliSet(char *cmdline)
strncpy((char *)cliGetValuePointer(val), valPtr, len);
}
valueChanged = true;
} else {
cliPrintErrorLinef("STRING MUST BE 1-%d CHARACTERS OR '-' FOR EMPTY", max);
}
}
break;
Expand Down

0 comments on commit f572227

Please sign in to comment.