[cli] remove aBufLength and error message (#6242)

This commit is contained in:
Yakun Xu
2021-03-08 11:57:45 -08:00
committed by GitHub
parent 46d3a4b7ec
commit 7d1691ed09
8 changed files with 13 additions and 17 deletions
+2 -3
View File
@@ -92,11 +92,10 @@ void otCliConsoleInit(otInstance *aInstance, otCliConsoleOutputCallback aCallbac
/**
* This method is called to feed in a console input line.
*
* @param[in] aBuf A pointer to a buffer with an input.
* @param[in] aBufLength A length of the input data stored in the buffer.
* @param[in] aBuf A pointer to a null-terminated string.
*
*/
void otCliConsoleInputLine(char *aBuf, uint16_t aBufLength);
void otCliConsoleInputLine(char *aBuf);
/**
* Initialize the CLI UART module.
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (82)
#define OPENTHREAD_API_VERSION (83)
/**
* @addtogroup api-instance
+3 -3
View File
@@ -4783,17 +4783,17 @@ otError Interpreter::ProcessDiag(uint8_t aArgsLength, char *aArgs[])
}
#endif
void Interpreter::ProcessLine(char *aBuf, uint16_t aBufLength)
void Interpreter::ProcessLine(char *aBuf)
{
char * args[kMaxArgs] = {nullptr};
uint8_t argsLength;
const Command *command;
VerifyOrExit(aBuf != nullptr && StringLength(aBuf, aBufLength + 1) <= aBufLength);
VerifyOrExit(aBuf != nullptr && StringLength(aBuf, kMaxLineLength) <= kMaxLineLength - 1);
VerifyOrExit(Utils::CmdLineParser::ParseCmd(aBuf, argsLength, args, kMaxArgs) == OT_ERROR_NONE,
OutputLine("Error: too many args (max %d)", kMaxArgs));
VerifyOrExit(argsLength >= 1, OutputLine("Error: no given command."));
VerifyOrExit(argsLength >= 1);
#if OPENTHREAD_CONFIG_DIAG_ENABLE
VerifyOrExit((!otDiagIsEnabled(mInstance) || (strcmp(args[0], "diag") == 0)),
+1 -2
View File
@@ -125,10 +125,9 @@ public:
* This method interprets a CLI command.
*
* @param[in] aBuf A pointer to a string.
* @param[in] aBufLength The length of the string in bytes.
*
*/
void ProcessLine(char *aBuf, uint16_t aBufLength);
void ProcessLine(char *aBuf);
/**
* This method delivers raw characters to the client.
+1 -1
View File
@@ -44,7 +44,7 @@
*
*/
#ifndef OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
#define OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH 128
#define OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH 384
#endif
/**
+2 -2
View File
@@ -53,9 +53,9 @@ extern "C" void otCliConsoleInit(otInstance *aInstance, otCliConsoleOutputCallba
Console::Initialize(aInstance, aCallback, aContext);
}
extern "C" void otCliConsoleInputLine(char *aBuf, uint16_t aBufLength)
extern "C" void otCliConsoleInputLine(char *aBuf)
{
Interpreter::GetInterpreter().ProcessLine(aBuf, aBufLength);
Interpreter::GetInterpreter().ProcessLine(aBuf);
}
// Add stubs for simulation
+1 -1
View File
@@ -227,7 +227,7 @@ otError Uart::ProcessCommand(void)
#endif
if (mRxLength > 0)
{
ProcessLine(mRxBuffer, mRxLength);
ProcessLine(mRxBuffer);
}
mRxLength = 0;
+2 -4
View File
@@ -70,12 +70,10 @@ static void InputCallback(char *aLine)
{
if (aLine != nullptr)
{
size_t len;
if ((len = strlen(aLine)) > 0)
if (aLine[0] != '\0')
{
add_history(aLine);
otCliConsoleInputLine(aLine, (uint16_t)len);
otCliConsoleInputLine(aLine);
}
free(aLine);
}