diff --git a/frameworks/js/napi/src/napi_cert_chain_validator.cpp b/frameworks/js/napi/src/napi_cert_chain_validator.cpp index ea223ce29a0b54e6c846e3a5270ce3cee44ab6f7..403befbd1ec98da0aa8740dc634893aa20b8c2d4 100644 --- a/frameworks/js/napi/src/napi_cert_chain_validator.cpp +++ b/frameworks/js/napi/src/napi_cert_chain_validator.cpp @@ -74,7 +74,6 @@ static void FreeCryptoFwkCtx(napi_env env, CfCtx *context) } HcfFree(context); - context = nullptr; } static void ReturnCallbackResult(napi_env env, CfCtx *context, napi_value result) @@ -139,7 +138,7 @@ napi_value NapiCertChainValidator::Validate(napi_env env, napi_callback_info inf if (!CheckArgsCount(env, argc, ARGS_SIZE_TWO, false)) { return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; diff --git a/frameworks/js/napi/src/napi_x509_certificate.cpp b/frameworks/js/napi/src/napi_x509_certificate.cpp index 32cd39542c8f69e535ceb1d9dfb363e0a5502c73..7ef9b47b922fc6b7577b9f51fa8b617383f2181c 100644 --- a/frameworks/js/napi/src/napi_x509_certificate.cpp +++ b/frameworks/js/napi/src/napi_x509_certificate.cpp @@ -82,7 +82,6 @@ static void FreeCryptoFwkCtx(napi_env env, CfCtx *context) context->encoded = nullptr; HcfFree(context); - context = nullptr; } static void ReturnCallbackResult(napi_env env, CfCtx *context, napi_value result) @@ -248,7 +247,7 @@ napi_value NapiX509Certificate::Verify(napi_env env, napi_callback_info info) return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -295,7 +294,7 @@ napi_value NapiX509Certificate::GetEncoded(napi_env env, napi_callback_info info return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -332,7 +331,7 @@ napi_value NapiX509Certificate::GetPublicKey(napi_env env, napi_callback_info in return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -369,7 +368,7 @@ napi_value NapiX509Certificate::CheckValidityWithDate(napi_env env, napi_callbac return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -1095,7 +1094,7 @@ napi_value NapiX509Certificate::NapiCreateX509Cert(napi_env env, napi_callback_i return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; diff --git a/frameworks/js/napi/src/napi_x509_crl.cpp b/frameworks/js/napi/src/napi_x509_crl.cpp index 2788c8c6db03381d8e384a73794ade51c58d3d08..66edb5383190295597d69f64b6d469bfb3e95c2f 100644 --- a/frameworks/js/napi/src/napi_x509_crl.cpp +++ b/frameworks/js/napi/src/napi_x509_crl.cpp @@ -89,7 +89,6 @@ static void FreeCryptoFwkCtx(napi_env env, CfCtx *context) } HcfFree(context); - context = nullptr; } static void ReturnCallbackResult(napi_env env, CfCtx *context, napi_value result) @@ -400,7 +399,7 @@ napi_value NapiX509Crl::IsRevoked(napi_env env, napi_callback_info info) LOGE("x509Cert is null!"); return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -453,7 +452,7 @@ napi_value NapiX509Crl::GetEncoded(napi_env env, napi_callback_info info) return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -498,7 +497,7 @@ napi_value NapiX509Crl::Verify(napi_env env, napi_callback_info info) return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -640,7 +639,7 @@ napi_value NapiX509Crl::GetRevokedCertificate(napi_env env, napi_callback_info i return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -691,7 +690,7 @@ napi_value NapiX509Crl::GetRevokedCertificateWithCert(napi_env env, napi_callbac return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -729,7 +728,7 @@ napi_value NapiX509Crl::GetRevokedCertificates(napi_env env, napi_callback_info return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -766,7 +765,7 @@ napi_value NapiX509Crl::GetTBSCertList(napi_env env, napi_callback_info info) return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -1160,7 +1159,7 @@ napi_value NapiX509Crl::NapiCreateX509Crl(napi_env env, napi_callback_info info) return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; diff --git a/frameworks/js/napi/src/napi_x509_crl_entry.cpp b/frameworks/js/napi/src/napi_x509_crl_entry.cpp index 0ab47975e75be3931074c509455089c857534bc1..dd18f27b386f590d57dadd203f04108f647e89df 100644 --- a/frameworks/js/napi/src/napi_x509_crl_entry.cpp +++ b/frameworks/js/napi/src/napi_x509_crl_entry.cpp @@ -67,7 +67,6 @@ static void FreeCryptoFwkCtx(napi_env env, CfCtx *context) context->blob = nullptr; HcfFree(context); - context = nullptr; } static void ReturnCallbackResult(napi_env env, CfCtx *context, napi_value result) @@ -240,7 +239,7 @@ napi_value NapiX509CrlEntry::GetEncoded(napi_env env, napi_callback_info info) return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -292,7 +291,7 @@ napi_value NapiX509CrlEntry::GetCertificateIssuer(napi_env env, napi_callback_in return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); return nullptr; @@ -329,7 +328,7 @@ napi_value NapiX509CrlEntry::GetRevocationDate(napi_env env, napi_callback_info return nullptr; } - CfCtx *context = (CfCtx *)HcfMalloc(sizeof(CfCtx), 0); + CfCtx *context = static_cast(HcfMalloc(sizeof(CfCtx), 0)); if (context == nullptr) { LOGE("malloc context failed!"); FreeCryptoFwkCtx(env, context);