From 7fe84c59cdf6ce1070ac2d877d826779a04df140 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 27 Oct 2020 21:41:37 -0700 Subject: [PATCH] [clang-tidy] google-readability-casting (#5720) --- script/make-pretty | 1 + src/cli/cli_coap_secure.cpp | 7 ++++--- src/core/common/random_manager.cpp | 2 +- tests/unit/test_link_quality.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/script/make-pretty b/script/make-pretty index a2abf6d77..68f229cec 100755 --- a/script/make-pretty +++ b/script/make-pretty @@ -116,6 +116,7 @@ readonly OT_CLANG_TIDY_BUILD_OPTS=( readonly OT_CLANG_TIDY_CHECKS="\ -*,\ +google-readability-casting,\ modernize-use-bool-literals,\ modernize-use-equals-default,\ modernize-use-equals-delete,\ diff --git a/src/cli/cli_coap_secure.cpp b/src/cli/cli_coap_secure.cpp index 0f60e7251..2f1b586be 100644 --- a/src/cli/cli_coap_secure.cpp +++ b/src/cli/cli_coap_secure.cpp @@ -384,11 +384,12 @@ otError CoapSecure::ProcessX509(uint8_t aArgsLength, char *aArgs[]) OT_UNUSED_VARIABLE(aArgsLength); OT_UNUSED_VARIABLE(aArgs); - otCoapSecureSetCertificate(mInterpreter.mInstance, (const uint8_t *)OT_CLI_COAPS_X509_CERT, - sizeof(OT_CLI_COAPS_X509_CERT), (const uint8_t *)OT_CLI_COAPS_PRIV_KEY, + otCoapSecureSetCertificate(mInterpreter.mInstance, reinterpret_cast(OT_CLI_COAPS_X509_CERT), + sizeof(OT_CLI_COAPS_X509_CERT), reinterpret_cast(OT_CLI_COAPS_PRIV_KEY), sizeof(OT_CLI_COAPS_PRIV_KEY)); - otCoapSecureSetCaCertificateChain(mInterpreter.mInstance, (const uint8_t *)OT_CLI_COAPS_TRUSTED_ROOT_CERTIFICATE, + otCoapSecureSetCaCertificateChain(mInterpreter.mInstance, + reinterpret_cast(OT_CLI_COAPS_TRUSTED_ROOT_CERTIFICATE), sizeof(OT_CLI_COAPS_TRUSTED_ROOT_CERTIFICATE)); mUseCertificate = true; diff --git a/src/core/common/random_manager.cpp b/src/core/common/random_manager.cpp index 4e0d943ea..de7977e1e 100644 --- a/src/core/common/random_manager.cpp +++ b/src/core/common/random_manager.cpp @@ -126,7 +126,7 @@ uint32_t RandomManager::NonCryptoPrng::GetNext(void) uint32_t mlcg, p, q; uint64_t tmpstate; - tmpstate = (uint64_t)33614 * (uint64_t)mState; + tmpstate = static_cast(33614) * static_cast(mState); q = tmpstate & 0xffffffff; q = q >> 1; p = tmpstate >> 32; diff --git a/tests/unit/test_link_quality.cpp b/tests/unit/test_link_quality.cpp index c6bf83be3..5ec77b967 100644 --- a/tests/unit/test_link_quality.cpp +++ b/tests/unit/test_link_quality.cpp @@ -111,7 +111,7 @@ void TestLinkQualityData(RssTestData aRssData) VerifyOrQuit(ave >= min, "TestLinkQualityInfo failed - GetAverageRss() is smaller than min value."); VerifyOrQuit(ave <= max, "TestLinkQualityInfo failed - GetAverageRss() is larger than min value"); VerifyRawRssValue(linkInfo.GetAverageRss(), linkInfo.GetAverageRssRaw()); - printf("%02u) AddRss(%4d): ", (unsigned int)i, rss); + printf("%02u) AddRss(%4d): ", static_cast(i), rss); PrintOutcome(linkInfo); }