[code-style] remove multiple return statements per free function or method (#2891)

There should be one return statement per free function or method at the end
of the free function or method.
This commit is contained in:
Jonathan Hui
2018-07-19 20:09:07 -05:00
committed by GitHub
parent 9b211b76c6
commit 1075e35327
14 changed files with 128 additions and 86 deletions
+17 -11
View File
@@ -320,11 +320,9 @@ int Interpreter::Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength)
uint8_t * cur = aBin;
uint8_t numChars = hexLength & 1;
uint8_t byte = 0;
int rval;
if ((hexLength + 1) / 2 > aBinLength)
{
return -1;
}
VerifyOrExit((hexLength + 1) / 2 <= aBinLength, rval = -1);
while (aHex < hexEnd)
{
@@ -342,7 +340,7 @@ int Interpreter::Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength)
}
else
{
return -1;
ExitNow(rval = -1);
}
aHex++;
@@ -360,7 +358,10 @@ int Interpreter::Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength)
}
}
return static_cast<int>(cur - aBin);
rval = static_cast<int>(cur - aBin);
exit:
return rval;
}
void Interpreter::AppendResult(otError aError) const
@@ -816,7 +817,6 @@ void Interpreter::ProcessDns(int argc, char *argv[])
SuccessOrExit(error = otDnsClientQuery(mInstance, &query, &Interpreter::s_HandleDnsResponse, this));
mResolvingInProgress = true;
return;
}
else
{
@@ -824,7 +824,10 @@ void Interpreter::ProcessDns(int argc, char *argv[])
}
exit:
AppendResult(error);
if (error != OT_ERROR_NONE)
{
AppendResult(error);
}
}
void Interpreter::s_HandleDnsResponse(void * aContext,
@@ -3597,12 +3600,12 @@ void Interpreter::ProcessNetworkDiagnostic(int argc, char *argv[])
if (strcmp(argv[0], "get") == 0)
{
otThreadSendDiagnosticGet(mInstance, &address, tlvTypes, count);
// Intentionally exit here for display response.
return;
ExitNow();
}
else if (strcmp(argv[0], "reset") == 0)
{
otThreadSendDiagnosticReset(mInstance, &address, tlvTypes, count);
AppendResult(OT_ERROR_NONE);
}
else
{
@@ -3610,7 +3613,10 @@ void Interpreter::ProcessNetworkDiagnostic(int argc, char *argv[])
}
exit:
AppendResult(error);
if (error != OT_ERROR_NONE)
{
AppendResult(error);
}
}
#endif // OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC