[style] use C++-style casts (#3705)

This commit is contained in:
Jonathan Hui
2019-03-22 08:12:26 -07:00
committed by Jonathan Hui
parent 8ed382207d
commit 2ab9b49042
7 changed files with 20 additions and 19 deletions
+2 -2
View File
@@ -128,8 +128,8 @@ otError otCoapSecureSetPsk(otInstance * aInstance,
*/
otError otCoapSecureGetPeerCertificateBase64(otInstance * aInstance,
unsigned char *aPeerCert,
uint64_t * aCertLength,
uint64_t aCertBufferSize);
size_t * aCertLength,
size_t aCertBufferSize);
/**
* This method sets the authentication mode for the coap secure connection.
+2 -2
View File
@@ -1799,7 +1799,7 @@ void Interpreter::ProcessNetworkName(int argc, char *argv[])
if (argc == 0)
{
otStringPtr networkName(otThreadGetNetworkName(mInstance));
mServer->OutputFormat("%.*s\r\n", OT_NETWORK_NAME_MAX_SIZE, (const char *)networkName);
mServer->OutputFormat("%.*s\r\n", OT_NETWORK_NAME_MAX_SIZE, static_cast<const char *>(networkName));
}
else
{
@@ -3135,7 +3135,7 @@ void Interpreter::ProcessVersion(int argc, char *argv[])
OT_UNUSED_VARIABLE(argv);
otStringPtr version(otGetVersionString());
mServer->OutputFormat("%s\r\n", (const char *)version);
mServer->OutputFormat("%s\r\n", static_cast<const char *>(version));
AppendResult(OT_ERROR_NONE);
}
+3 -4
View File
@@ -127,14 +127,13 @@ otError otCoapSecureSetPsk(otInstance * aInstance,
otError otCoapSecureGetPeerCertificateBase64(otInstance * aInstance,
unsigned char *aPeerCert,
uint64_t * aCertLength,
uint64_t aCertBufferSize)
size_t * aCertLength,
size_t aCertBufferSize)
{
#ifdef MBEDTLS_BASE64_C
Instance &instance = *static_cast<Instance *>(aInstance);
return instance.GetApplicationCoapSecure().GetPeerCertificateBase64(aPeerCert, (size_t *)aCertLength,
(size_t)aCertBufferSize);
return instance.GetApplicationCoapSecure().GetPeerCertificateBase64(aPeerCert, aCertLength, aCertBufferSize);
#else
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aPeerCert);
+1 -1
View File
@@ -149,7 +149,7 @@ void otThreadSetNetworkIdTimeout(otInstance *aInstance, uint8_t aTimeout)
{
Instance &instance = *static_cast<Instance *>(aInstance);
instance.GetThreadNetif().GetMle().SetNetworkIdTimeout((uint8_t)aTimeout);
instance.GetThreadNetif().GetMle().SetNetworkIdTimeout(aTimeout);
}
uint8_t otThreadGetRouterUpgradeThreshold(otInstance *aInstance)
+10 -8
View File
@@ -121,7 +121,7 @@ int Dtls::HandleMbedtlsEntropyPoll(void *aData, unsigned char *aOutput, size_t a
otError error;
int rval = 0;
error = otPlatRandomGetTrue((uint8_t *)aOutput, (uint16_t)aInLen);
error = otPlatRandomGetTrue(static_cast<uint8_t *>(aOutput), static_cast<uint16_t>(aInLen));
SuccessOrExit(error);
if (aOutLen != NULL)
@@ -413,17 +413,19 @@ int Dtls::SetApplicationCoapSecureKeys(void)
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
if (mCaChainSrc != NULL)
{
rval = mbedtls_x509_crt_parse(&mCaChain, (const unsigned char *)mCaChainSrc, (size_t)mCaChainLength);
rval = mbedtls_x509_crt_parse(&mCaChain, static_cast<const unsigned char *>(mCaChainSrc),
static_cast<size_t>(mCaChainLength));
VerifyOrExit(rval == 0);
mbedtls_ssl_conf_ca_chain(&mConf, &mCaChain, NULL);
}
if (mOwnCertSrc != NULL && mPrivateKeySrc != NULL)
{
rval = mbedtls_x509_crt_parse(&mOwnCert, (const unsigned char *)mOwnCertSrc, (size_t)mOwnCertLength);
rval = mbedtls_x509_crt_parse(&mOwnCert, static_cast<const unsigned char *>(mOwnCertSrc),
static_cast<size_t>(mOwnCertLength));
VerifyOrExit(rval == 0);
rval = mbedtls_pk_parse_key(&mPrivateKey, (const unsigned char *)mPrivateKeySrc, (size_t)mPrivateKeyLength,
NULL, 0);
rval = mbedtls_pk_parse_key(&mPrivateKey, static_cast<const unsigned char *>(mPrivateKeySrc),
static_cast<size_t>(mPrivateKeyLength), NULL, 0);
VerifyOrExit(rval == 0);
rval = mbedtls_ssl_conf_own_cert(&mConf, &mOwnCert, &mPrivateKey);
VerifyOrExit(rval == 0);
@@ -433,8 +435,8 @@ int Dtls::SetApplicationCoapSecureKeys(void)
case MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8:
#ifdef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
rval = mbedtls_ssl_conf_psk(&mConf, (unsigned char *)mPreSharedKey, mPreSharedKeyLength,
(unsigned char *)mPreSharedKeyIdentity, mPreSharedKeyIdLength);
rval = mbedtls_ssl_conf_psk(&mConf, static_cast<const unsigned char *>(mPreSharedKey), mPreSharedKeyLength,
static_cast<const unsigned char *>(mPreSharedKeyIdentity), mPreSharedKeyIdLength);
VerifyOrExit(rval == 0);
#endif // MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
break;
@@ -706,7 +708,7 @@ int Dtls::HandleMbedtlsReceive(unsigned char *aBuf, size_t aLength)
aLength = mReceiveLength;
}
rval = (int)mReceiveMessage->Read(mReceiveOffset, (uint16_t)aLength, aBuf);
rval = mReceiveMessage->Read(mReceiveOffset, static_cast<uint16_t>(aLength), aBuf);
mReceiveOffset += static_cast<uint16_t>(rval);
mReceiveLength -= static_cast<uint16_t>(rval);
+1 -1
View File
@@ -1576,7 +1576,7 @@ template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_MAC_SCAN_STATE>(void)
VerifyOrExit(HasOnly1BitSet(mScanChannelMask), error = OT_ERROR_INVALID_ARGS);
scanChannel = IndexOfMSB(mScanChannelMask);
mCurScanChannel = (int8_t)scanChannel;
mCurScanChannel = static_cast<int8_t>(scanChannel);
error = otLinkRawEnergyScan(mInstance, scanChannel, mScanPeriod, LinkRawEnergyScanDone);
}
+1 -1
View File
@@ -777,7 +777,7 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
case SPINEL_DATATYPE_INT64_C:
case SPINEL_DATATYPE_UINT64_C:
{
uint64_t arg = (uint64_t)va_arg(args->obj, uint64_t);
uint64_t arg = va_arg(args->obj, uint64_t);
ret += sizeof(uint64_t);