mirror of
https://github.com/espressif/openthread.git
synced 2026-07-15 00:24:11 +00:00
Enable -Wconversion on clang and fix all warnings. (#358)
This commit is contained in:
+24
-24
@@ -114,7 +114,7 @@ void Interpreter::Init(void)
|
||||
|
||||
int Interpreter::Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength)
|
||||
{
|
||||
uint16_t hexLength = strlen(aHex);
|
||||
size_t hexLength = strlen(aHex);
|
||||
const char *hexEnd = aHex + hexLength;
|
||||
uint8_t *cur = aBin;
|
||||
uint8_t numChars = hexLength & 1;
|
||||
@@ -159,7 +159,7 @@ int Interpreter::Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength)
|
||||
}
|
||||
}
|
||||
|
||||
return cur - aBin;
|
||||
return static_cast<int>(cur - aBin);
|
||||
}
|
||||
|
||||
void Interpreter::AppendResult(ThreadError error)
|
||||
@@ -212,7 +212,7 @@ void Interpreter::ProcessChannel(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetChannel(value);
|
||||
otSetChannel(static_cast<uint8_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -229,7 +229,7 @@ void Interpreter::ProcessChild(int argc, char *argv[])
|
||||
|
||||
if (strcmp(argv[0], "list") == 0)
|
||||
{
|
||||
for (int i = 0; ; i++)
|
||||
for (uint8_t i = 0; ; i++)
|
||||
{
|
||||
if (otGetChildInfoByIndex(i, &childInfo) != kThreadError_None)
|
||||
{
|
||||
@@ -245,7 +245,7 @@ void Interpreter::ProcessChild(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
SuccessOrExit(error = otGetChildInfoById(value, &childInfo));
|
||||
SuccessOrExit(error = otGetChildInfoById(static_cast<uint8_t>(value), &childInfo));
|
||||
|
||||
sServer->OutputFormat("Child ID: %d\r\n", childInfo.mChildId);
|
||||
sServer->OutputFormat("Rloc: %04x\r\n", childInfo.mRloc16);
|
||||
@@ -303,7 +303,7 @@ void Interpreter::ProcessChildTimeout(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetChildTimeout(value);
|
||||
otSetChildTimeout(static_cast<uint32_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -322,7 +322,7 @@ void Interpreter::ProcessContextIdReuseDelay(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(ParseLong(argv[0], value));
|
||||
otSetContextIdReuseDelay(value);
|
||||
otSetContextIdReuseDelay(static_cast<uint32_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -403,7 +403,7 @@ void Interpreter::ProcessEidCache(int argc, char *argv[])
|
||||
{
|
||||
otEidCacheEntry entry;
|
||||
|
||||
for (int i = 0; ; i++)
|
||||
for (uint8_t i = 0; ; i++)
|
||||
{
|
||||
SuccessOrExit(otGetEidCacheEntry(i, &entry));
|
||||
|
||||
@@ -580,7 +580,7 @@ void Interpreter::ProcessKeySequence(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetKeySequenceCounter(value);
|
||||
otSetKeySequenceCounter(static_cast<uint32_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -618,7 +618,7 @@ void Interpreter::ProcessLeaderWeight(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetLocalLeaderWeight(value);
|
||||
otSetLocalLeaderWeight(static_cast<uint8_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -643,11 +643,11 @@ void Interpreter::ProcessMasterKey(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
int8_t keyLength;
|
||||
int keyLength;
|
||||
uint8_t key[16];
|
||||
|
||||
VerifyOrExit((keyLength = Hex2Bin(argv[0], key, sizeof(key))) >= 0, error = kThreadError_Parse);
|
||||
SuccessOrExit(error = otSetMasterKey(key, keyLength));
|
||||
SuccessOrExit(error = otSetMasterKey(key, static_cast<uint8_t>(keyLength)));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -744,7 +744,7 @@ void Interpreter::ProcessNetworkIdTimeout(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetNetworkIdTimeout(value);
|
||||
otSetNetworkIdTimeout(static_cast<uint8_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -780,7 +780,7 @@ void Interpreter::ProcessPanId(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetPanId(value);
|
||||
otSetPanId(static_cast<otPanId>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -904,7 +904,7 @@ ThreadError Interpreter::ProcessPrefixAdd(int argc, char *argv[])
|
||||
|
||||
SuccessOrExit(error = otIp6AddressFromString(argv[argcur], &config.mPrefix.mPrefix));
|
||||
|
||||
config.mPrefix.mLength = strtol(prefixLengthStr, &endptr, 0);
|
||||
config.mPrefix.mLength = static_cast<uint8_t>(strtol(prefixLengthStr, &endptr, 0));
|
||||
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
@@ -994,7 +994,7 @@ ThreadError Interpreter::ProcessPrefixRemove(int argc, char *argv[])
|
||||
|
||||
SuccessOrExit(error = otIp6AddressFromString(argv[argcur], &prefix.mPrefix));
|
||||
|
||||
prefix.mLength = strtol(prefixLengthStr, &endptr, 0);
|
||||
prefix.mLength = static_cast<uint8_t>(strtol(prefixLengthStr, &endptr, 0));
|
||||
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
@@ -1039,7 +1039,7 @@ void Interpreter::ProcessReleaseRouterId(int argc, char *argv[])
|
||||
VerifyOrExit(argc > 0, error = kThreadError_Parse);
|
||||
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
SuccessOrExit(error = otReleaseRouterId(value));
|
||||
SuccessOrExit(error = otReleaseRouterId(static_cast<uint8_t>(value)));
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
@@ -1075,7 +1075,7 @@ ThreadError Interpreter::ProcessRouteAdd(int argc, char *argv[])
|
||||
|
||||
SuccessOrExit(error = otIp6AddressFromString(argv[argcur], &config.mPrefix.mPrefix));
|
||||
|
||||
config.mPrefix.mLength = strtol(prefixLengthStr, &endptr, 0);
|
||||
config.mPrefix.mLength = static_cast<uint8_t>(strtol(prefixLengthStr, &endptr, 0));
|
||||
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
@@ -1136,7 +1136,7 @@ ThreadError Interpreter::ProcessRouteRemove(int argc, char *argv[])
|
||||
|
||||
SuccessOrExit(error = otIp6AddressFromString(argv[argcur], &prefix.mPrefix));
|
||||
|
||||
prefix.mLength = strtol(prefixLengthStr, &endptr, 0);
|
||||
prefix.mLength = static_cast<uint8_t>(strtol(prefixLengthStr, &endptr, 0));
|
||||
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
@@ -1182,7 +1182,7 @@ void Interpreter::ProcessRouter(int argc, char *argv[])
|
||||
|
||||
if (strcmp(argv[0], "list") == 0)
|
||||
{
|
||||
for (int i = 0; ; i++)
|
||||
for (uint8_t i = 0; ; i++)
|
||||
{
|
||||
if (otGetRouterInfo(i, &routerInfo) != kThreadError_None)
|
||||
{
|
||||
@@ -1198,7 +1198,7 @@ void Interpreter::ProcessRouter(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
SuccessOrExit(error = otGetRouterInfo(value, &routerInfo));
|
||||
SuccessOrExit(error = otGetRouterInfo(static_cast<uint8_t>(value), &routerInfo));
|
||||
|
||||
sServer->OutputFormat("Alloc: %d\r\n", routerInfo.mAllocated);
|
||||
|
||||
@@ -1242,7 +1242,7 @@ void Interpreter::ProcessRouterUpgradeThreshold(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetRouterUpgradeThreshold(value);
|
||||
otSetRouterUpgradeThreshold(static_cast<uint8_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -1416,7 +1416,7 @@ void Interpreter::ProcessWhitelist(int argc, char *argv[])
|
||||
sServer->OutputFormat("Disabled\r\n");
|
||||
}
|
||||
|
||||
for (int i = 0; ; i++)
|
||||
for (uint8_t i = 0; ; i++)
|
||||
{
|
||||
if (otGetMacWhitelistEntry(i, &entry) != kThreadError_None)
|
||||
{
|
||||
@@ -1445,7 +1445,7 @@ void Interpreter::ProcessWhitelist(int argc, char *argv[])
|
||||
|
||||
if (++argcur < argc)
|
||||
{
|
||||
rssi = strtol(argv[argcur], NULL, 0);
|
||||
rssi = static_cast<int8_t>(strtol(argv[argcur], NULL, 0));
|
||||
VerifyOrExit(otAddMacWhitelistRssi(extAddr, rssi) == kThreadError_None, error = kThreadError_Parse);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user