[debug] adding OT_ASSERT() macro (#4665)

This commit adds a new OpenThread specific `OT_ASSERT()` macro along
with a new config OPENTHREAD_CONFIG_ASSERT_ENABLE option which allows
the assert to be enabled or disabled. This allows a release build to
consider disabling the assert reducing code size. This commit also
adds a new travis (simulation platform) build with asserts disabled.
This commit is contained in:
Abtin Keshavarzian
2020-03-11 17:30:41 -07:00
committed by GitHub
parent 587cb7fb30
commit 5903117da5
67 changed files with 277 additions and 243 deletions
+4 -4
View File
@@ -52,7 +52,7 @@ void otCryptoHmacSha256(const uint8_t *aKey,
{
HmacSha256 hmac;
assert((aKey != NULL) && (aBuf != NULL) && (aHash != NULL));
OT_ASSERT((aKey != NULL) && (aBuf != NULL) && (aHash != NULL));
hmac.Start(aKey, aKeyLength);
hmac.Update(aBuf, aBufLength);
@@ -75,21 +75,21 @@ void otCryptoAesCcm(const uint8_t *aKey,
AesCcm aesCcm;
uint8_t tagLength;
assert((aKey != NULL) && (aNonce != NULL) && (aPlainText != NULL) && (aCipherText != NULL) && (aTag != NULL));
OT_ASSERT((aKey != NULL) && (aNonce != NULL) && (aPlainText != NULL) && (aCipherText != NULL) && (aTag != NULL));
aesCcm.SetKey(aKey, aKeyLength);
SuccessOrExit(aesCcm.Init(aHeaderLength, aLength, aTagLength, aNonce, aNonceLength));
if (aHeaderLength != 0)
{
assert(aHeader != NULL);
OT_ASSERT(aHeader != NULL);
aesCcm.Header(aHeader, aHeaderLength);
}
aesCcm.Payload(aPlainText, aCipherText, aLength, aEncrypt);
aesCcm.Finalize(aTag, &tagLength);
assert(aTagLength == tagLength);
OT_ASSERT(aTagLength == tagLength);
exit:
return;