Clean up error names. (#1764)

This commit is contained in:
Jonathan Hui
2017-05-23 09:34:35 -07:00
committed by GitHub
parent b3530deb76
commit 48b9299544
262 changed files with 6230 additions and 6204 deletions
@@ -66,8 +66,8 @@ HANDLE gDeviceArrivalEvent = nullptr;
otApiInstance *gApiInstance = nullptr;
_Success_(return == kThreadError_None)
ThreadError otNodeParsePrefix(const char *aStrPrefix, _Out_ otIp6Prefix *aPrefix)
_Success_(return == OT_ERROR_NONE)
otError otNodeParsePrefix(const char *aStrPrefix, _Out_ otIp6Prefix *aPrefix)
{
char *prefixLengthStr;
char *endptr;
@@ -75,13 +75,13 @@ ThreadError otNodeParsePrefix(const char *aStrPrefix, _Out_ otIp6Prefix *aPrefix
if ((prefixLengthStr = (char*)strchr(aStrPrefix, '/')) == NULL)
{
printf("invalid prefix (%s)!\r\n", aStrPrefix);
return kThreadError_InvalidArgs;
return OT_ERROR_INVALID_ARGS;
}
*prefixLengthStr++ = '\0';
auto error = otIp6AddressFromString(aStrPrefix, &aPrefix->mPrefix);
if (error != kThreadError_None)
if (error != OT_ERROR_NONE)
{
printf("ipaddr (%s) to string failed, 0x%x!\r\n", aStrPrefix, error);
return error;
@@ -92,10 +92,10 @@ ThreadError otNodeParsePrefix(const char *aStrPrefix, _Out_ otIp6Prefix *aPrefix
if (*endptr != '\0')
{
printf("invalid prefix ending (%s)!\r\n", aStrPrefix);
return kThreadError_Parse;
return OT_ERROR_PARSE;
}
return kThreadError_None;
return OT_ERROR_NONE;
}
void OTCALL otNodeDeviceAvailabilityChanged(bool aAdded, const GUID *, void *)
@@ -1012,7 +1012,7 @@ OTNODEAPI int32_t OTCALL otNodeCommissionerJoinerAdd(otNode* aNode, const char *
const uint32_t kDefaultJoinerTimeout = 120;
ThreadError error;
otError error;
if (strcmp(aExtAddr, "*") == 0)
{
@@ -1022,7 +1022,7 @@ OTNODEAPI int32_t OTCALL otNodeCommissionerJoinerAdd(otNode* aNode, const char *
{
otExtAddress extAddr;
if (Hex2Bin(aExtAddr, extAddr.m8, sizeof(extAddr)) != sizeof(extAddr))
return kThreadError_Parse;
return OT_ERROR_PARSE;
error = otCommissionerAddJoiner(aNode->mInstance, &extAddr, aPSKd, kDefaultJoinerTimeout);
}
@@ -1104,9 +1104,9 @@ OTNODEAPI int32_t OTCALL otNodeAddWhitelist(otNode* aNode, const char *aExtAddr,
uint8_t extAddr[8];
if (Hex2Bin(aExtAddr, extAddr, sizeof(extAddr)) != sizeof(extAddr))
return kThreadError_Parse;
return OT_ERROR_PARSE;
ThreadError error;
otError error;
if (aRssi == 0)
{
error = otLinkAddWhitelist(aNode->mInstance, extAddr);
@@ -1126,7 +1126,7 @@ OTNODEAPI int32_t OTCALL otNodeRemoveWhitelist(otNode* aNode, const char *aExtAd
uint8_t extAddr[8];
if (Hex2Bin(aExtAddr, extAddr, sizeof(extAddr)) != sizeof(extAddr))
return kThreadError_InvalidArgs;
return OT_ERROR_INVALID_ARGS;
otLinkRemoveWhitelist(aNode->mInstance, extAddr);
otLogFuncExit();
@@ -1204,7 +1204,7 @@ OTNODEAPI int32_t OTCALL otNodeSetMasterkey(otNode* aNode, const char *aMasterke
if ((keyLength = Hex2Bin(aMasterkey, key.m8, sizeof(key.m8))) != OT_MASTER_KEY_SIZE)
{
printf("invalid length key %d\r\n", keyLength);
return kThreadError_Parse;
return OT_ERROR_PARSE;
}
auto error = otThreadSetMasterKey(aNode->mInstance, &key);
@@ -1239,7 +1239,7 @@ OTNODEAPI int32_t OTCALL otNodeSetPSKc(otNode* aNode, const char *aPSKc)
if (Hex2Bin(aPSKc, pskc, sizeof(pskc)) != OT_PSKC_MAX_SIZE)
{
printf("invalid pskc %s\r\n", aPSKc);
return kThreadError_Parse;
return OT_ERROR_PARSE;
}
auto error = otThreadSetPSKc(aNode->mInstance, pskc);
@@ -1399,7 +1399,7 @@ OTNODEAPI int32_t OTCALL otNodeSetState(otNode* aNode, const char *aState)
otLogFuncEntryMsg("[%d]", aNode->mId);
printf("%d: state %s\r\n", aNode->mId, aState);
ThreadError error;
otError error;
if (strcmp(aState, "detached") == 0)
{
error = otThreadBecomeDetached(aNode->mInstance);
@@ -1418,7 +1418,7 @@ OTNODEAPI int32_t OTCALL otNodeSetState(otNode* aNode, const char *aState)
}
else
{
error = kThreadError_InvalidArgs;
error = OT_ERROR_INVALID_ARGS;
}
otLogFuncExit();
return error;
@@ -1467,7 +1467,7 @@ OTNODEAPI int32_t OTCALL otNodeAddIpAddr(otNode* aNode, const char *aAddr)
otNetifAddress aAddress;
auto error = otIp6AddressFromString(aAddr, &aAddress.mAddress);
if (error != kThreadError_None) return error;
if (error != OT_ERROR_NONE) return error;
aAddress.mPrefixLength = 64;
aAddress.mPreferred = true;
@@ -1559,7 +1559,7 @@ OTNODEAPI int32_t OTCALL otNodeAddPrefix(otNode* aNode, const char *aPrefix, con
otBorderRouterConfig config = {0};
auto error = otNodeParsePrefix(aPrefix, &config.mPrefix);
if (error != kThreadError_None) return error;
if (error != OT_ERROR_NONE) return error;
const char *index = aFlags;
while (*index)
@@ -1588,7 +1588,7 @@ OTNODEAPI int32_t OTCALL otNodeAddPrefix(otNode* aNode, const char *aPrefix, con
config.mStable = true;
break;
default:
return kThreadError_InvalidArgs;
return OT_ERROR_INVALID_ARGS;
}
index++;
@@ -1608,7 +1608,7 @@ OTNODEAPI int32_t OTCALL otNodeAddPrefix(otNode* aNode, const char *aPrefix, con
}
else
{
return kThreadError_InvalidArgs;
return OT_ERROR_INVALID_ARGS;
}
auto result = otNetDataAddPrefixInfo(aNode->mInstance, &config);
@@ -1622,7 +1622,7 @@ OTNODEAPI int32_t OTCALL otNodeRemovePrefix(otNode* aNode, const char *aPrefix)
otIp6Prefix prefix;
auto error = otNodeParsePrefix(aPrefix, &prefix);
if (error != kThreadError_None) return error;
if (error != OT_ERROR_NONE) return error;
auto result = otNetDataRemovePrefixInfo(aNode->mInstance, &prefix);
otLogFuncExit();
@@ -1635,7 +1635,7 @@ OTNODEAPI int32_t OTCALL otNodeAddRoute(otNode* aNode, const char *aPrefix, cons
otExternalRouteConfig config = {0};
auto error = otNodeParsePrefix(aPrefix, &config.mPrefix);
if (error != kThreadError_None) return error;
if (error != OT_ERROR_NONE) return error;
if (strcmp(aPreference, "high") == 0)
{
@@ -1651,7 +1651,7 @@ OTNODEAPI int32_t OTCALL otNodeAddRoute(otNode* aNode, const char *aPrefix, cons
}
else
{
return kThreadError_InvalidArgs;
return OT_ERROR_INVALID_ARGS;
}
auto result = otNetDataAddRoute(aNode->mInstance, &config);
@@ -1665,7 +1665,7 @@ OTNODEAPI int32_t OTCALL otNodeRemoveRoute(otNode* aNode, const char *aPrefix)
otIp6Prefix prefix;
auto error = otNodeParsePrefix(aPrefix, &prefix);
if (error != kThreadError_None) return error;
if (error != OT_ERROR_NONE) return error;
auto result = otNetDataRemoveRoute(aNode->mInstance, &prefix);
otLogFuncExit();
@@ -1700,7 +1700,7 @@ OTNODEAPI int32_t OTCALL otNodeEnergyScan(otNode* aNode, uint32_t aMask, uint8_t
otIp6Address address = {0};
auto error = otIp6AddressFromString(aAddr, &address);
if (error != kThreadError_None)
if (error != OT_ERROR_NONE)
{
printf("otIp6AddressFromString(%s) failed, 0x%x!\r\n", aAddr, error);
return error;
@@ -1709,13 +1709,13 @@ OTNODEAPI int32_t OTCALL otNodeEnergyScan(otNode* aNode, uint32_t aMask, uint8_t
ResetEvent(aNode->mEnergyScanEvent);
error = otCommissionerEnergyScan(aNode->mInstance, aMask, aCount, aPeriod, aDuration, &address, otNodeCommissionerEnergyReportCallback, aNode);
if (error != kThreadError_None)
if (error != OT_ERROR_NONE)
{
printf("otCommissionerEnergyScan failed, 0x%x!\r\n", error);
return error;
}
auto result = WaitForSingleObject(aNode->mEnergyScanEvent, 8000) == WAIT_OBJECT_0 ? kThreadError_None : kThreadError_NotFound;
auto result = WaitForSingleObject(aNode->mEnergyScanEvent, 8000) == WAIT_OBJECT_0 ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND;
otLogFuncExit();
return result;
}
@@ -1734,7 +1734,7 @@ OTNODEAPI int32_t OTCALL otNodePanIdQuery(otNode* aNode, uint16_t aPanId, uint32
otIp6Address address = {0};
auto error = otIp6AddressFromString(aAddr, &address);
if (error != kThreadError_None)
if (error != OT_ERROR_NONE)
{
printf("otIp6AddressFromString(%s) failed, 0x%x!\r\n", aAddr, error);
return error;
@@ -1743,13 +1743,13 @@ OTNODEAPI int32_t OTCALL otNodePanIdQuery(otNode* aNode, uint16_t aPanId, uint32
ResetEvent(aNode->mPanIdConflictEvent);
error = otCommissionerPanIdQuery(aNode->mInstance, aPanId, aMask, &address, otNodeCommissionerPanIdConflictCallback, aNode);
if (error != kThreadError_None)
if (error != OT_ERROR_NONE)
{
printf("otCommissionerPanIdQuery failed, 0x%x!\r\n", error);
return error;
}
auto result = WaitForSingleObject(aNode->mPanIdConflictEvent, 8000) == WAIT_OBJECT_0 ? kThreadError_None : kThreadError_NotFound;
auto result = WaitForSingleObject(aNode->mPanIdConflictEvent, 8000) == WAIT_OBJECT_0 ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND;
otLogFuncExit();
return result;
}
@@ -1770,7 +1770,7 @@ OTNODEAPI uint32_t OTCALL otNodePing(otNode* aNode, const char *aAddr, uint16_t
// Convert string to destination address
otIp6Address otDestinationAddress = {0};
auto error = otIp6AddressFromString(aAddr, &otDestinationAddress);
if (error != kThreadError_None)
if (error != OT_ERROR_NONE)
{
printf("otIp6AddressFromString(%s) failed!\r\n", aAddr);
return 0;
@@ -1940,7 +1940,7 @@ OTNODEAPI int32_t OTCALL otNodeCommissionerAnnounceBegin(otNode* aNode, uint32_t
otIp6Address aAddress;
auto error = otIp6AddressFromString(aAddr, &aAddress);
if (error != kThreadError_None) return error;
if (error != OT_ERROR_NONE) return error;
auto result = otCommissionerAnnounceBegin(aNode->mInstance, aChannelMask, aCount, aPeriod, &aAddress);
otLogFuncExit();
@@ -1981,7 +1981,7 @@ OTNODEAPI int32_t OTCALL otNodeSetActiveDataset(otNode* aNode, uint64_t aTimesta
if ((keyLength = Hex2Bin(aMasterKey, aDataset.mMasterKey.m8, sizeof(aDataset.mMasterKey))) != OT_MASTER_KEY_SIZE)
{
printf("invalid length key %d\r\n", keyLength);
return kThreadError_Parse;
return OT_ERROR_PARSE;
}
aDataset.mIsMasterKeySet = true;
}
@@ -2070,7 +2070,7 @@ OTNODEAPI int32_t OTCALL otNodeSendPendingSet(otNode* aNode, uint64_t aActiveTim
if ((keyLength = Hex2Bin(aMasterKey, aDataset.mMasterKey.m8, sizeof(aDataset.mMasterKey))) != OT_MASTER_KEY_SIZE)
{
printf("invalid length key %d\r\n", keyLength);
return kThreadError_Parse;
return OT_ERROR_PARSE;
}
aDataset.mIsMasterKeySet = true;
}
@@ -2079,7 +2079,7 @@ OTNODEAPI int32_t OTCALL otNodeSendPendingSet(otNode* aNode, uint64_t aActiveTim
{
otIp6Address prefix;
auto error = otIp6AddressFromString(aMeshLocal, &prefix);
if (error != kThreadError_None) return error;
if (error != OT_ERROR_NONE) return error;
memcpy(aDataset.mMeshLocalPrefix.m8, prefix.mFields.m8, sizeof(aDataset.mMeshLocalPrefix.m8));
aDataset.mIsMeshLocalPrefixSet = true;
}
@@ -2133,7 +2133,7 @@ OTNODEAPI int32_t OTCALL otNodeSendActiveSet(otNode* aNode, uint64_t aActiveTime
if ((keyLength = Hex2Bin(aExtPanId, aDataset.mExtendedPanId.m8, sizeof(aDataset.mExtendedPanId))) != OT_EXT_PAN_ID_SIZE)
{
printf("invalid length ext pan id %d\r\n", keyLength);
return kThreadError_Parse;
return OT_ERROR_PARSE;
}
aDataset.mIsExtendedPanIdSet = true;
}
@@ -2144,7 +2144,7 @@ OTNODEAPI int32_t OTCALL otNodeSendActiveSet(otNode* aNode, uint64_t aActiveTime
if ((keyLength = Hex2Bin(aMasterKey, aDataset.mMasterKey.m8, sizeof(aDataset.mMasterKey))) != OT_MASTER_KEY_SIZE)
{
printf("invalid length key %d\r\n", keyLength);
return kThreadError_Parse;
return OT_ERROR_PARSE;
}
aDataset.mIsMasterKeySet = true;
}
@@ -2153,7 +2153,7 @@ OTNODEAPI int32_t OTCALL otNodeSendActiveSet(otNode* aNode, uint64_t aActiveTime
{
otIp6Address prefix;
auto error = otIp6AddressFromString(aMeshLocal, &prefix);
if (error != kThreadError_None) return error;
if (error != OT_ERROR_NONE) return error;
memcpy(aDataset.mMeshLocalPrefix.m8, prefix.mFields.m8, sizeof(aDataset.mMeshLocalPrefix.m8));
aDataset.mIsMeshLocalPrefixSet = true;
}
@@ -2170,7 +2170,7 @@ OTNODEAPI int32_t OTCALL otNodeSendActiveSet(otNode* aNode, uint64_t aActiveTime
if ((length = Hex2Bin(aBinary,tlvs, sizeof(tlvs))) < 0)
{
printf("invalid length tlvs %d\r\n", length);
return kThreadError_Parse;
return OT_ERROR_PARSE;
}
tlvsLength = (uint8_t)length;
}