[cli] style fixes and smaller enhancements (#5581)

This commit contains a group of style fixes and smaller enhancements
in CLI modules:
- Remove unnecessary `struct` when declaring variable.
- Remove use of single `"%s"` in `Output` methods.
- Fix order of `#include` headers.
- Remove unnecessary use of `OT_UNUSED_VARIABLE`.
- Remove unnecessary temp variables and casts.
- Add comments to `#endif` directives than are more than  than 20
  lines away from the corresponding `#if` they are associated with.
This commit is contained in:
Abtin Keshavarzian
2020-09-28 17:28:06 -07:00
committed by GitHub
parent 3d22a37267
commit 6b6a3b8f74
10 changed files with 78 additions and 105 deletions
+12 -12
View File
@@ -44,13 +44,13 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot {
namespace Cli {
const struct UdpExample::Command UdpExample::sCommands[] = {{"help", &UdpExample::ProcessHelp},
{"bind", &UdpExample::ProcessBind},
{"close", &UdpExample::ProcessClose},
{"connect", &UdpExample::ProcessConnect},
{"linksecurity", &UdpExample::ProcessLinkSecurity},
{"open", &UdpExample::ProcessOpen},
{"send", &UdpExample::ProcessSend}};
const UdpExample::Command UdpExample::sCommands[] = {{"help", &UdpExample::ProcessHelp},
{"bind", &UdpExample::ProcessBind},
{"close", &UdpExample::ProcessClose},
{"connect", &UdpExample::ProcessConnect},
{"linksecurity", &UdpExample::ProcessLinkSecurity},
{"open", &UdpExample::ProcessOpen},
{"send", &UdpExample::ProcessSend}};
UdpExample::UdpExample(Interpreter &aInterpreter)
: mInterpreter(aInterpreter)
@@ -66,7 +66,7 @@ otError UdpExample::ProcessHelp(uint8_t aArgsLength, char *aArgs[])
for (const Command &command : sCommands)
{
mInterpreter.OutputLine("%s", command.mName);
mInterpreter.OutputLine(command.mName);
}
return OT_ERROR_NONE;
@@ -241,7 +241,7 @@ otError UdpExample::ProcessLinkSecurity(uint8_t aArgsLength, char *aArgs[])
if (aArgsLength == 0)
{
mInterpreter.OutputLine("%s", mLinkSecurityEnabled ? "Enabled" : "Disabled");
mInterpreter.OutputLine(mLinkSecurityEnabled ? "Enabled" : "Disabled");
}
else if (strcmp(aArgs[0], "enable") == 0)
{
@@ -317,8 +317,8 @@ void UdpExample::HandleUdpReceive(void *aContext, otMessage *aMessage, const otM
void UdpExample::HandleUdpReceive(otMessage *aMessage, const otMessageInfo *aMessageInfo)
{
uint8_t buf[1500];
int length;
char buf[1500];
int length;
mInterpreter.OutputFormat("%d bytes from ", otMessageGetLength(aMessage) - otMessageGetOffset(aMessage));
mInterpreter.OutputIp6Address(aMessageInfo->mPeerAddr);
@@ -327,7 +327,7 @@ void UdpExample::HandleUdpReceive(otMessage *aMessage, const otMessageInfo *aMes
length = otMessageRead(aMessage, otMessageGetOffset(aMessage), buf, sizeof(buf) - 1);
buf[length] = '\0';
mInterpreter.OutputLine("%s", buf);
mInterpreter.OutputLine(buf);
}
} // namespace Cli