Skip to content

Commit

Permalink
clang-tidy: Apply fixes "google-readability-casting" (#3034)
Browse files Browse the repository at this point in the history
  • Loading branch information
mspang authored and pull[bot] committed Oct 6, 2020
1 parent 7bef9e0 commit 1542487
Show file tree
Hide file tree
Showing 63 changed files with 388 additions and 363 deletions.
8 changes: 4 additions & 4 deletions examples/shell/shell_common/cmd_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static CHIP_ERROR ConfigGetDeviceCert(bool printHeader)
VerifyOrExit(certLen != 0, error = CHIP_ERROR_CERT_NOT_FOUND);

// Create a temporary buffer to hold the certificate.
certBuf = (uint8_t *) MemoryAlloc(certLen);
certBuf = static_cast<uint8_t *>(MemoryAlloc(certLen));
VerifyOrExit(certBuf != nullptr, error = CHIP_ERROR_NO_MEMORY);

// Read the certificate
Expand Down Expand Up @@ -220,7 +220,7 @@ static CHIP_ERROR ConfigGetDeviceCaCerts(bool printHeader)
VerifyOrExit(certLen != 0, error = CHIP_ERROR_CERT_NOT_FOUND);

// Create a temporary buffer to hold the certificate.
certBuf = (uint8_t *) MemoryAlloc(certLen);
certBuf = static_cast<uint8_t *>(MemoryAlloc(certLen));
VerifyOrExit(certBuf != nullptr, error = CHIP_ERROR_NO_MEMORY);

// Read the certificate
Expand Down Expand Up @@ -273,7 +273,7 @@ static CHIP_ERROR ConfigGetManufacturerDeviceCert(bool printHeader)
VerifyOrExit(certLen != 0, error = CHIP_ERROR_CERT_NOT_FOUND);

// Create a temporary buffer to hold the certificate.
certBuf = (uint8_t *) MemoryAlloc(certLen);
certBuf = static_cast<uint8_t *>(MemoryAlloc(certLen));
VerifyOrExit(certBuf != nullptr, error = CHIP_ERROR_NO_MEMORY);

// Read the certificate
Expand Down Expand Up @@ -309,7 +309,7 @@ static CHIP_ERROR ConfigGetManufacturerDeviceCaCerts(bool printHeader)
VerifyOrExit(certLen != 0, error = CHIP_ERROR_CERT_NOT_FOUND);

// Create a temporary buffer to hold the certificate.
certBuf = (uint8_t *) MemoryAlloc(certLen);
certBuf = static_cast<uint8_t *>(MemoryAlloc(certLen));
VerifyOrExit(certBuf != nullptr, error = CHIP_ERROR_NO_MEMORY);

// Read the certificate
Expand Down
2 changes: 1 addition & 1 deletion src/ble/BleLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class BleEndPointPool

if (i < BLE_LAYER_NUM_BLE_ENDPOINTS)
{
return (BLEEndPoint *) (sEndPointPool.Pool + (sizeof(BLEEndPoint) * i));
return reinterpret_cast<BLEEndPoint *>(sEndPointPool.Pool + (sizeof(BLEEndPoint) * i));
}

return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ CHIP_ERROR nl_Chip_DeviceController_DriveIO(uint32_t sleepTimeMS)

if (GetBleEventCB)
{
evu.ev = (const BleEventBase *) GetBleEventCB();
evu.ev = static_cast<const BleEventBase *>(GetBleEventCB());

if (evu.ev)
{
Expand Down
22 changes: 13 additions & 9 deletions src/crypto/CHIPCryptoPALOpenSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::InitInternal()
init_bn(tempbn);
init_bn(order);

error_openssl = EC_GROUP_get_order(context->curve, (BIGNUM *) order, context->bn_ctx);
error_openssl = EC_GROUP_get_order(context->curve, static_cast<BIGNUM *>(order), context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand Down Expand Up @@ -1210,7 +1210,7 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::FELoad(const uint8_t * in, size_t in_l
{
CHIP_ERROR error = CHIP_ERROR_INTERNAL;
int error_openssl = 0;
BIGNUM * bn_fe = (BIGNUM *) fe;
BIGNUM * bn_fe = static_cast<BIGNUM *>(fe);

Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

Expand Down Expand Up @@ -1243,7 +1243,7 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::FEGenerate(void * fe)
CHIP_ERROR error = CHIP_ERROR_INTERNAL;
int error_openssl = 0;

error_openssl = BN_rand_range((BIGNUM *) fe, (BIGNUM *) order);
error_openssl = BN_rand_range(static_cast<BIGNUM *>(fe), static_cast<BIGNUM *>(order));
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand All @@ -1258,7 +1258,8 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::FEMul(void * fer, const void * fe1, co

Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

error_openssl = BN_mod_mul((BIGNUM *) fer, (BIGNUM *) fe1, (BIGNUM *) fe2, (BIGNUM *) order, context->bn_ctx);
error_openssl =
BN_mod_mul(static_cast<BIGNUM *>(fer), (BIGNUM *) fe1, (BIGNUM *) fe2, static_cast<BIGNUM *>(order), context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand All @@ -1273,7 +1274,8 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::PointLoad(const uint8_t * in, size_t i

Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

error_openssl = EC_POINT_oct2point(context->curve, (EC_POINT *) R, Uint8::to_const_uchar(in), in_len, context->bn_ctx);
error_openssl =
EC_POINT_oct2point(context->curve, static_cast<EC_POINT *>(R), Uint8::to_const_uchar(in), in_len, context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand Down Expand Up @@ -1302,7 +1304,8 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::PointMul(void * R, const void * P1, co

Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

error_openssl = EC_POINT_mul(context->curve, (EC_POINT *) R, nullptr, (EC_POINT *) P1, (BIGNUM *) fe1, context->bn_ctx);
error_openssl =
EC_POINT_mul(context->curve, static_cast<EC_POINT *>(R), nullptr, (EC_POINT *) P1, (BIGNUM *) fe1, context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand All @@ -1328,7 +1331,8 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::PointAddMul(void * R, const void * P1,
error = PointMul(R, P2, fe2);
VerifyOrExit(error == CHIP_NO_ERROR, error = CHIP_ERROR_INTERNAL);

error_openssl = EC_POINT_add(context->curve, (EC_POINT *) R, (EC_POINT *) R, (const EC_POINT *) scratch, context->bn_ctx);
error_openssl = EC_POINT_add(context->curve, static_cast<EC_POINT *>(R), static_cast<EC_POINT *>(R), (const EC_POINT *) scratch,
context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand All @@ -1344,7 +1348,7 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::PointInvert(void * R)

Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

error_openssl = EC_POINT_invert(context->curve, (EC_POINT *) R, context->bn_ctx);
error_openssl = EC_POINT_invert(context->curve, static_cast<EC_POINT *>(R), context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand Down Expand Up @@ -1400,7 +1404,7 @@ CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::PointIsValid(void * R)

Spake2p_Context * context = to_inner_spake2p_context(&mSpake2pContext);

error_openssl = EC_POINT_is_on_curve(context->curve, (EC_POINT *) R, context->bn_ctx);
error_openssl = EC_POINT_is_on_curve(context->curve, static_cast<EC_POINT *>(R), context->bn_ctx);
VerifyOrExit(error_openssl == 1, error = CHIP_ERROR_INTERNAL);

error = CHIP_NO_ERROR;
Expand Down
32 changes: 17 additions & 15 deletions src/crypto/tests/CHIPCryptoPALTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,59 +602,61 @@ static void TestDRBG_Output(nlTestSuite * inSuite, void * inContext)
static void TestECDSA_Signing_SHA256(nlTestSuite * inSuite, void * inContext)
{
const char * msg = "Hello World!";
size_t msg_length = strlen((const char *) msg);
size_t msg_length = strlen(msg);

P256Keypair keypair;
NL_TEST_ASSERT(inSuite, keypair.Initialize() == CHIP_NO_ERROR);

P256ECDSASignature signature;
CHIP_ERROR signing_error = keypair.ECDSA_sign_msg((const uint8_t *) msg, msg_length, signature);
CHIP_ERROR signing_error = keypair.ECDSA_sign_msg(reinterpret_cast<const uint8_t *>(msg), msg_length, signature);
NL_TEST_ASSERT(inSuite, signing_error == CHIP_NO_ERROR);

CHIP_ERROR validation_error = keypair.Pubkey().ECDSA_validate_msg_signature((const uint8_t *) msg, msg_length, signature);
CHIP_ERROR validation_error =
keypair.Pubkey().ECDSA_validate_msg_signature(reinterpret_cast<const uint8_t *>(msg), msg_length, signature);
NL_TEST_ASSERT(inSuite, validation_error == CHIP_NO_ERROR);
}

static void TestECDSA_ValidationFailsDifferentMessage(nlTestSuite * inSuite, void * inContext)
{
const char * msg = "Hello World!";
size_t msg_length = strlen((const char *) msg);
size_t msg_length = strlen(msg);

P256Keypair keypair;
NL_TEST_ASSERT(inSuite, keypair.Initialize() == CHIP_NO_ERROR);

P256ECDSASignature signature;
CHIP_ERROR signing_error = keypair.ECDSA_sign_msg((const uint8_t *) msg, msg_length, signature);
CHIP_ERROR signing_error = keypair.ECDSA_sign_msg(reinterpret_cast<const uint8_t *>(msg), msg_length, signature);
NL_TEST_ASSERT(inSuite, signing_error == CHIP_NO_ERROR);

const char * diff_msg = "NOT Hello World!";
size_t diff_msg_length = strlen((const char *) msg);
size_t diff_msg_length = strlen(msg);
CHIP_ERROR validation_error =
keypair.Pubkey().ECDSA_validate_msg_signature((const uint8_t *) diff_msg, diff_msg_length, signature);
keypair.Pubkey().ECDSA_validate_msg_signature(reinterpret_cast<const uint8_t *>(diff_msg), diff_msg_length, signature);
NL_TEST_ASSERT(inSuite, validation_error != CHIP_NO_ERROR);
}

static void TestECDSA_ValidationFailIncorrectSignature(nlTestSuite * inSuite, void * inContext)
{
const char * msg = "Hello World!";
size_t msg_length = strlen((const char *) msg);
size_t msg_length = strlen(msg);

P256Keypair keypair;
NL_TEST_ASSERT(inSuite, keypair.Initialize() == CHIP_NO_ERROR);

P256ECDSASignature signature;
CHIP_ERROR signing_error = keypair.ECDSA_sign_msg((const uint8_t *) msg, msg_length, signature);
CHIP_ERROR signing_error = keypair.ECDSA_sign_msg(reinterpret_cast<const uint8_t *>(msg), msg_length, signature);
NL_TEST_ASSERT(inSuite, signing_error == CHIP_NO_ERROR);
signature[0] = static_cast<uint8_t>(~signature[0]); // Flipping bits should invalidate the signature.

CHIP_ERROR validation_error = keypair.Pubkey().ECDSA_validate_msg_signature((const uint8_t *) msg, msg_length, signature);
CHIP_ERROR validation_error =
keypair.Pubkey().ECDSA_validate_msg_signature(reinterpret_cast<const uint8_t *>(msg), msg_length, signature);
NL_TEST_ASSERT(inSuite, validation_error == CHIP_ERROR_INVALID_SIGNATURE);
}

static void TestECDSA_SigningInvalidParams(nlTestSuite * inSuite, void * inContext)
{
const uint8_t * msg = (uint8_t *) "Hello World!";
size_t msg_length = strlen((const char *) msg);
const uint8_t * msg = reinterpret_cast<const uint8_t *>("Hello World!");
size_t msg_length = strlen(reinterpret_cast<const char *>(msg));

P256Keypair keypair;
NL_TEST_ASSERT(inSuite, keypair.Initialize() == CHIP_NO_ERROR);
Expand All @@ -672,20 +674,20 @@ static void TestECDSA_SigningInvalidParams(nlTestSuite * inSuite, void * inConte
static void TestECDSA_ValidationInvalidParam(nlTestSuite * inSuite, void * inContext)
{
const char * msg = "Hello World!";
size_t msg_length = strlen((const char *) msg);
size_t msg_length = strlen(msg);

P256Keypair keypair;
NL_TEST_ASSERT(inSuite, keypair.Initialize() == CHIP_NO_ERROR);

P256ECDSASignature signature;
CHIP_ERROR signing_error = keypair.ECDSA_sign_msg((const uint8_t *) msg, msg_length, signature);
CHIP_ERROR signing_error = keypair.ECDSA_sign_msg(reinterpret_cast<const uint8_t *>(msg), msg_length, signature);
NL_TEST_ASSERT(inSuite, signing_error == CHIP_NO_ERROR);

CHIP_ERROR validation_error = keypair.Pubkey().ECDSA_validate_msg_signature(nullptr, msg_length, signature);
NL_TEST_ASSERT(inSuite, validation_error == CHIP_ERROR_INVALID_ARGUMENT);
validation_error = CHIP_NO_ERROR;

validation_error = keypair.Pubkey().ECDSA_validate_msg_signature((const uint8_t *) msg, 0, signature);
validation_error = keypair.Pubkey().ECDSA_validate_msg_signature(reinterpret_cast<const uint8_t *>(msg), 0, signature);
NL_TEST_ASSERT(inSuite, validation_error == CHIP_ERROR_INVALID_ARGUMENT);
validation_error = CHIP_NO_ERROR;
}
Expand Down
24 changes: 12 additions & 12 deletions src/crypto/tests/SPAKE2P_RFC_test_vectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ static const uint8_t chiptest_e4836c3b50dd_MAC_KcB_15[] = { 0x06, 0x60, 0xa6, 0x
0xb2, 0x2d, 0xff, 0x29, 0x8b, 0x1d, 0x07, 0xa5, 0x26, 0xcf, 0x3c,
0xc5, 0x91, 0xad, 0xfe, 0xcd, 0x1f, 0x6e, 0xf6, 0xe0, 0x2e };
static const struct spake2p_rfc_tv chiptest_e4836c3b50dd_test_vector_16 = {
.context = (const uint8_t *) "SPAKE2+-P256-SHA256-HKDF draft-01",
.context = reinterpret_cast<const uint8_t *>("SPAKE2+-P256-SHA256-HKDF draft-01"),
.context_len = 33,
.prover_identity = (const uint8_t *) "client",
.prover_identity = reinterpret_cast<const uint8_t *>("client"),
.prover_identity_len = 6,
.verifier_identity = (const uint8_t *) "server",
.verifier_identity = reinterpret_cast<const uint8_t *>("server"),
.verifier_identity_len = 6,
.w0 = chiptest_e4836c3b50dd_w0_1,
.w0_len = 32,
Expand Down Expand Up @@ -211,11 +211,11 @@ static const uint8_t chiptest_e4836c3b50dd_MAC_KcB_31[] = { 0xb9, 0xc3, 0x9d, 0x
0x9b, 0xed, 0xea, 0xca, 0x24, 0x48, 0xb9, 0x05, 0xbe, 0x19, 0xa4,
0x3b, 0x94, 0xee, 0x24, 0xb7, 0x70, 0x20, 0x81, 0x35, 0xe3 };
static const struct spake2p_rfc_tv chiptest_e4836c3b50dd_test_vector_32 = {
.context = (const uint8_t *) "SPAKE2+-P256-SHA256-HKDF draft-01",
.context = reinterpret_cast<const uint8_t *>("SPAKE2+-P256-SHA256-HKDF draft-01"),
.context_len = 33,
.prover_identity = (const uint8_t *) "client",
.prover_identity = reinterpret_cast<const uint8_t *>("client"),
.prover_identity_len = 6,
.verifier_identity = (const uint8_t *) "",
.verifier_identity = reinterpret_cast<const uint8_t *>(""),
.verifier_identity_len = 0,
.w0 = chiptest_e4836c3b50dd_w0_17,
.w0_len = 32,
Expand Down Expand Up @@ -305,11 +305,11 @@ static const uint8_t chiptest_e4836c3b50dd_MAC_KcB_47[] = { 0x07, 0x2a, 0x94, 0x
0x53, 0x4c, 0x23, 0x17, 0xca, 0xdf, 0x3e, 0xa3, 0x79, 0x28, 0x27,
0xf4, 0x79, 0xe8, 0x73, 0xf9, 0x3e, 0x90, 0xf2, 0x15, 0x52 };
static const struct spake2p_rfc_tv chiptest_e4836c3b50dd_test_vector_48 = {
.context = (const uint8_t *) "SPAKE2+-P256-SHA256-HKDF draft-01",
.context = reinterpret_cast<const uint8_t *>("SPAKE2+-P256-SHA256-HKDF draft-01"),
.context_len = 33,
.prover_identity = (const uint8_t *) "",
.prover_identity = reinterpret_cast<const uint8_t *>(""),
.prover_identity_len = 0,
.verifier_identity = (const uint8_t *) "server",
.verifier_identity = reinterpret_cast<const uint8_t *>("server"),
.verifier_identity_len = 6,
.w0 = chiptest_e4836c3b50dd_w0_33,
.w0_len = 32,
Expand Down Expand Up @@ -399,11 +399,11 @@ static const uint8_t chiptest_e4836c3b50dd_MAC_KcB_63[] = { 0x09, 0x5d, 0xc0, 0x
0x37, 0x81, 0x18, 0x15, 0xb3, 0xc1, 0x52, 0x4a, 0xae, 0x80, 0xfd,
0x4e, 0x68, 0x10, 0xcf, 0x53, 0x1c, 0xf1, 0x1d, 0x20, 0xe3 };
static const struct spake2p_rfc_tv chiptest_e4836c3b50dd_test_vector_64 = {
.context = (const uint8_t *) "SPAKE2+-P256-SHA256-HKDF draft-01",
.context = reinterpret_cast<const uint8_t *>("SPAKE2+-P256-SHA256-HKDF draft-01"),
.context_len = 33,
.prover_identity = (const uint8_t *) "",
.prover_identity = reinterpret_cast<const uint8_t *>(""),
.prover_identity_len = 0,
.verifier_identity = (const uint8_t *) "",
.verifier_identity = reinterpret_cast<const uint8_t *>(""),
.verifier_identity_len = 0,
.w0 = chiptest_e4836c3b50dd_w0_49,
.w0_len = 32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ extern template class Internal::GenericConfigurationManagerImpl<ConfigurationMan
template <class ImplClass>
inline CHIP_ERROR GenericConfigurationManagerImpl<ImplClass>::_GetVendorId(uint16_t & vendorId)
{
vendorId = (uint16_t) CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
vendorId = static_cast<uint16_t>(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID);
return CHIP_NO_ERROR;
}

template <class ImplClass>
inline CHIP_ERROR GenericConfigurationManagerImpl<ImplClass>::_GetProductId(uint16_t & productId)
{
productId = (uint16_t) CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
productId = static_cast<uint16_t>(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID);
return CHIP_NO_ERROR;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ inline CHIP_ERROR GenericConfigurationManagerImpl<ImplClass>::_GetProductRevisio
err = Impl()->ReadConfigValue(ImplClass::kConfigKey_ProductRevision, val);
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{
productRev = (uint16_t) CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_PRODUCT_REVISION;
productRev = static_cast<uint16_t>(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_PRODUCT_REVISION);
err = CHIP_NO_ERROR;
}
else
{
productRev = (uint16_t) val;
productRev = static_cast<uint16_t>(val);
}

return err;
Expand All @@ -260,7 +260,7 @@ inline CHIP_ERROR GenericConfigurationManagerImpl<ImplClass>::_GetProductRevisio
template <class ImplClass>
inline CHIP_ERROR GenericConfigurationManagerImpl<ImplClass>::_StoreProductRevision(uint16_t productRev)
{
return Impl()->WriteConfigValue(ImplClass::kConfigKey_ProductRevision, (uint32_t) productRev);
return Impl()->WriteConfigValue(ImplClass::kConfigKey_ProductRevision, static_cast<uint32_t>(productRev));
}

template <class ImplClass>
Expand Down Expand Up @@ -592,7 +592,7 @@ CHIP_ERROR GenericConfigurationManagerImpl<ImplClass>::_GetSetupDiscriminator(ui
#endif // defined(CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR) && CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR
SuccessOrExit(err);

setupDiscriminator = (uint16_t) val;
setupDiscriminator = static_cast<uint16_t>(val);

exit:
return err;
Expand All @@ -601,7 +601,7 @@ exit:
template <class ImplClass>
CHIP_ERROR GenericConfigurationManagerImpl<ImplClass>::_StoreSetupDiscriminator(uint16_t setupDiscriminator)
{
return Impl()->WriteConfigValue(ImplClass::kConfigKey_SetupDiscriminator, (uint32_t) setupDiscriminator);
return Impl()->WriteConfigValue(ImplClass::kConfigKey_SetupDiscriminator, static_cast<uint32_t>(setupDiscriminator));
}

template <class ImplClass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void GenericPlatformManagerImpl<ImplClass>::_DispatchEvent(const ChipDeviceEvent

// TODO: make this configurable
#if CHIP_PROGRESS_LOGGING
uint32_t delta = ((uint32_t)(System::Layer::GetClock_MonotonicHiRes() - startUS)) / 1000;
uint32_t delta = (static_cast<uint32_t>(System::Layer::GetClock_MonotonicHiRes() - startUS)) / 1000;
if (delta > 100)
{
ChipLogError(DeviceLayer, "Long dispatch time: %" PRId32 " ms", delta);
Expand Down
2 changes: 1 addition & 1 deletion src/inet/DNSResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ INET_ERROR DNSResolver::ProcessGetAddrInfoResult(int returnCode, struct addrinfo
// when attempting to communicate with the host.
if (numAddrs > MaxAddrs && MaxAddrs > 1 && numPrimaryAddrs > 0 && numSecondaryAddrs > 0)
{
numPrimaryAddrs = ::chip::min(numPrimaryAddrs, (uint8_t)(MaxAddrs - 1));
numPrimaryAddrs = ::chip::min(numPrimaryAddrs, static_cast<uint8_t>(MaxAddrs - 1));
}

// Copy the primary addresses into the beginning of the application's output array,
Expand Down
4 changes: 2 additions & 2 deletions src/inet/IPAddress-StringFuncts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ char * IPAddress::ToString(char * buf, uint32_t bufSize) const
#if INET_CONFIG_ENABLE_IPV4
if (IsIPv4())
{
buf = (char *) inet_ntop(AF_INET, (const void *) &Addr[3], buf, static_cast<socklen_t>(bufSize));
buf = const_cast<char *>(inet_ntop(AF_INET, (const void *) &Addr[3], buf, static_cast<socklen_t>(bufSize)));
}
else
#endif // INET_CONFIG_ENABLE_IPV4
{
buf = (char *) inet_ntop(AF_INET6, (const void *) Addr, buf, static_cast<socklen_t>(bufSize));
buf = const_cast<char *>(inet_ntop(AF_INET6, (const void *) Addr, buf, static_cast<socklen_t>(bufSize)));
}
#endif // !CHIP_SYSTEM_CONFIG_USE_LWIP

Expand Down
Loading

0 comments on commit 1542487

Please sign in to comment.