[cli] style fixes & remove core defined error constants (#9868)

This commit contains small changes in the CLI modules:

- Replace use of core-internal `kError` with `OT_ERROR` constants.
- Remove `#endif` comments when the corresponding `#if` is less
  than 20 lines away adhering to OT style guide.
- Adhere to single `return` policy (use `ExitNow()`).
- Avoid calling `static` method `ParseToIp6Address()` with an object.
- Smaller style fixes: New lines after variable declaration, use
  shorter local variable names, etc.
This commit is contained in:
Abtin Keshavarzian
2024-02-22 11:29:38 -08:00
committed by GitHub
parent 3aa3cbc341
commit a0d805c8f0
7 changed files with 84 additions and 44 deletions
+9 -8
View File
@@ -132,11 +132,11 @@ template <> otError UdpExample::Process<Cmd("connect")>(Arg aArgs[])
{
otError error;
otSockAddr sockaddr;
bool nat64SynthesizedAddress;
bool nat64Synth;
SuccessOrExit(
error = Interpreter::ParseToIp6Address(GetInstancePtr(), aArgs[0], sockaddr.mAddress, nat64SynthesizedAddress));
if (nat64SynthesizedAddress)
SuccessOrExit(error = Interpreter::ParseToIp6Address(GetInstancePtr(), aArgs[0], sockaddr.mAddress, nat64Synth));
if (nat64Synth)
{
OutputFormat("Connecting to synthesized IPv6 address: ");
OutputIp6AddressLine(sockaddr.mAddress);
@@ -267,11 +267,12 @@ template <> otError UdpExample::Process<Cmd("send")>(Arg aArgs[])
if (!aArgs[2].IsEmpty())
{
bool nat64SynthesizedAddress;
bool nat64Synth;
SuccessOrExit(error = Interpreter::ParseToIp6Address(GetInstancePtr(), aArgs[0], messageInfo.mPeerAddr,
nat64SynthesizedAddress));
if (nat64SynthesizedAddress)
SuccessOrExit(
error = Interpreter::ParseToIp6Address(GetInstancePtr(), aArgs[0], messageInfo.mPeerAddr, nat64Synth));
if (nat64Synth)
{
OutputFormat("Sending to synthesized IPv6 address: ");
OutputIp6AddressLine(messageInfo.mPeerAddr);