Replacing NULL with nullptr in core/
[ Merge of http://go/wvgerrit/84647 ] [ Merge of http://go/wvgerrit/84648 ] Replacing most instances of C's NULL with C++'s nullptr. Also changed how a NULL check is performed on smart pointers. They provided an implicit boolean operator for null checks, meaning the underlying pointer does not need to be compared directly (as it was in some places before). Note that clang-format has performed additional changes to some of the test files that have not yet been formatted. Bug: 120602075 Test: Linux and Android unittests Change-Id: I06ddebe34b0ea6dfecedb5527e7e808e32f5269a
This commit is contained in:
@@ -101,14 +101,14 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||
const CdmSessionId& forced_session_id,
|
||||
WvCdmEventListener* event_listener) {
|
||||
return OpenSession(key_system, property_set, event_listener,
|
||||
&forced_session_id, NULL);
|
||||
&forced_session_id, nullptr);
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||
CdmClientPropertySet* property_set,
|
||||
WvCdmEventListener* event_listener,
|
||||
CdmSessionId* session_id) {
|
||||
return OpenSession(key_system, property_set, event_listener, NULL,
|
||||
return OpenSession(key_system, property_set, event_listener, nullptr,
|
||||
session_id);
|
||||
}
|
||||
|
||||
@@ -182,8 +182,9 @@ CdmResponseType CdmEngine::OpenKeySetSession(
|
||||
if (key_set_in_use) CloseKeySetSession(key_set_id);
|
||||
|
||||
CdmSessionId session_id;
|
||||
CdmResponseType sts = OpenSession(KEY_SYSTEM, property_set, event_listener,
|
||||
NULL /* forced_session_id */, &session_id);
|
||||
CdmResponseType sts =
|
||||
OpenSession(KEY_SYSTEM, property_set, event_listener,
|
||||
nullptr /* forced_session_id */, &session_id);
|
||||
|
||||
if (sts != NO_ERROR) return sts;
|
||||
|
||||
@@ -882,7 +883,7 @@ CdmResponseType CdmEngine::GetProvisioningRequest(
|
||||
|
||||
DeleteAllUsageReportsUponFactoryReset();
|
||||
|
||||
if (NULL == cert_provisioning_.get()) {
|
||||
if (!cert_provisioning_) {
|
||||
cert_provisioning_.reset(
|
||||
new CertificateProvisioning(metrics_->GetCryptoMetrics()));
|
||||
CdmResponseType status = cert_provisioning_->Init(service_certificate);
|
||||
@@ -892,7 +893,7 @@ CdmResponseType CdmEngine::GetProvisioningRequest(
|
||||
cert_provisioning_requested_security_level_, cert_type, cert_authority,
|
||||
file_system_->origin(), spoid_, request, default_url);
|
||||
if (ret != NO_ERROR) {
|
||||
cert_provisioning_.reset(NULL); // Release resources.
|
||||
cert_provisioning_.reset(); // Release resources.
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -910,20 +911,20 @@ CdmResponseType CdmEngine::HandleProvisioningResponse(
|
||||
LOGI("Handling provision request");
|
||||
if (response.empty()) {
|
||||
LOGE("Empty provisioning response");
|
||||
cert_provisioning_.reset(NULL);
|
||||
cert_provisioning_.reset();
|
||||
return EMPTY_PROVISIONING_RESPONSE;
|
||||
}
|
||||
if (cert == NULL) {
|
||||
if (cert == nullptr) {
|
||||
LOGE("Invalid certificate destination");
|
||||
cert_provisioning_.reset(NULL);
|
||||
cert_provisioning_.reset();
|
||||
return INVALID_PROVISIONING_PARAMETERS_1;
|
||||
}
|
||||
if (wrapped_key == NULL) {
|
||||
if (wrapped_key == nullptr) {
|
||||
LOGE("Invalid wrapped key destination");
|
||||
cert_provisioning_.reset(NULL);
|
||||
cert_provisioning_.reset();
|
||||
return INVALID_PROVISIONING_PARAMETERS_2;
|
||||
}
|
||||
if (NULL == cert_provisioning_.get()) {
|
||||
if (!cert_provisioning_) {
|
||||
// Certificate provisioning object has been released. Check if a concurrent
|
||||
// provisioning attempt has succeeded before declaring failure.
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
@@ -951,7 +952,7 @@ CdmResponseType CdmEngine::HandleProvisioningResponse(
|
||||
// attempt was made after this one was requested but before the response was
|
||||
// received, which will cause this attempt to fail. Not releasing will
|
||||
// allow for the possibility that the later attempt succeeds.
|
||||
if (NO_ERROR == ret) cert_provisioning_.reset(NULL);
|
||||
if (NO_ERROR == ret) cert_provisioning_.reset();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1184,7 +1185,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("Getting usage info: app_id = %s, ssid = %s", app_id.c_str(),
|
||||
ssid.c_str());
|
||||
if (NULL == usage_property_set_.get()) {
|
||||
if (!usage_property_set_) {
|
||||
usage_property_set_.reset(new UsagePropertySet());
|
||||
}
|
||||
if (!usage_info) {
|
||||
@@ -1289,7 +1290,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("Getting usage info: app_id = %s, security_level = %d", app_id.c_str(),
|
||||
static_cast<int>(requested_security_level));
|
||||
if (NULL == usage_property_set_.get()) {
|
||||
if (!usage_property_set_) {
|
||||
usage_property_set_.reset(new UsagePropertySet());
|
||||
}
|
||||
usage_property_set_->set_security_level(requested_security_level);
|
||||
@@ -1362,7 +1363,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
|
||||
const std::string& app_id, CdmSecurityLevel cdm_security_level) {
|
||||
LOGI("Removing all usage info: app_id = %s, security_level = %d",
|
||||
app_id.c_str(), static_cast<int>(cdm_security_level));
|
||||
if (usage_property_set_.get() == nullptr) {
|
||||
if (!usage_property_set_) {
|
||||
usage_property_set_.reset(new UsagePropertySet());
|
||||
}
|
||||
usage_property_set_->set_app_id(app_id);
|
||||
@@ -1436,7 +1437,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
|
||||
break;
|
||||
}
|
||||
}
|
||||
usage_session_.reset(NULL);
|
||||
usage_session_.reset();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1453,7 +1454,7 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
||||
const std::string& app_id, const CdmSecureStopId& provider_session_token) {
|
||||
LOGI("Removing usage info: app_id = %s, pst = %s", app_id.c_str(),
|
||||
provider_session_token.c_str());
|
||||
if (NULL == usage_property_set_.get()) {
|
||||
if (!usage_property_set_) {
|
||||
usage_property_set_.reset(new UsagePropertySet());
|
||||
}
|
||||
usage_property_set_->set_app_id(app_id);
|
||||
@@ -1492,7 +1493,7 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
||||
provider_session_token)) {
|
||||
status = REMOVE_USAGE_INFO_ERROR_1;
|
||||
}
|
||||
usage_session_.reset(NULL);
|
||||
usage_session_.reset();
|
||||
return status;
|
||||
}
|
||||
case kUsageTableSupport: {
|
||||
@@ -1522,20 +1523,20 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
||||
status = REMOVE_USAGE_INFO_ERROR_2;
|
||||
}
|
||||
}
|
||||
usage_session_.reset(NULL);
|
||||
usage_session_.reset();
|
||||
return REMOVE_USAGE_INFO_ERROR_3;
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::ReleaseUsageInfo(
|
||||
const CdmUsageInfoReleaseMessage& message) {
|
||||
LOGI("Releasing usage info");
|
||||
if (NULL == usage_session_.get()) {
|
||||
if (!usage_session_) {
|
||||
LOGE("CDM session not initialized");
|
||||
return RELEASE_USAGE_INFO_ERROR;
|
||||
}
|
||||
|
||||
CdmResponseType status = usage_session_->ReleaseKey(message);
|
||||
usage_session_.reset(NULL);
|
||||
usage_session_.reset();
|
||||
if (NO_ERROR != status) {
|
||||
LOGE("ReleaseKey failed: status = %d", status);
|
||||
}
|
||||
@@ -1617,22 +1618,22 @@ CdmResponseType CdmEngine::LoadUsageSession(const CdmKeySetId& key_set_id,
|
||||
|
||||
CdmResponseType CdmEngine::Decrypt(const CdmSessionId& session_id,
|
||||
const CdmDecryptionParameters& parameters) {
|
||||
if (parameters.key_id == NULL) {
|
||||
if (parameters.key_id == nullptr) {
|
||||
LOGE("No key ID");
|
||||
return INVALID_DECRYPT_PARAMETERS_ENG_1;
|
||||
}
|
||||
|
||||
if (parameters.encrypt_buffer == NULL) {
|
||||
if (parameters.encrypt_buffer == nullptr) {
|
||||
LOGE("No src encrypt buffer");
|
||||
return INVALID_DECRYPT_PARAMETERS_ENG_2;
|
||||
}
|
||||
|
||||
if (parameters.iv == NULL) {
|
||||
if (parameters.iv == nullptr) {
|
||||
LOGE("No IV");
|
||||
return INVALID_DECRYPT_PARAMETERS_ENG_3;
|
||||
}
|
||||
|
||||
if (parameters.decrypt_buffer == NULL) {
|
||||
if (parameters.decrypt_buffer == nullptr) {
|
||||
if (!parameters.is_secure &&
|
||||
!Properties::Properties::oem_crypto_use_fifo()) {
|
||||
LOGE("No dest decrypt buffer");
|
||||
@@ -1660,7 +1661,7 @@ CdmResponseType CdmEngine::Decrypt(const CdmSessionId& session_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (session.get() == NULL) {
|
||||
if (!session) {
|
||||
LOGE("Session not found: Empty session ID");
|
||||
return SESSION_NOT_FOUND_FOR_DECRYPT;
|
||||
}
|
||||
@@ -1680,7 +1681,7 @@ CdmResponseType CdmEngine::GenericEncrypt(const std::string& session_id,
|
||||
const std::string& iv,
|
||||
CdmEncryptionAlgorithm algorithm,
|
||||
std::string* out_buffer) {
|
||||
if (out_buffer == NULL) {
|
||||
if (out_buffer == nullptr) {
|
||||
LOGE("No out buffer provided");
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
@@ -1698,7 +1699,7 @@ CdmResponseType CdmEngine::GenericDecrypt(const std::string& session_id,
|
||||
const std::string& iv,
|
||||
CdmEncryptionAlgorithm algorithm,
|
||||
std::string* out_buffer) {
|
||||
if (out_buffer == NULL) {
|
||||
if (out_buffer == nullptr) {
|
||||
LOGE("No out buffer provided");
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
@@ -1715,7 +1716,7 @@ CdmResponseType CdmEngine::GenericSign(const std::string& session_id,
|
||||
const std::string& key_id,
|
||||
CdmSigningAlgorithm algorithm,
|
||||
std::string* signature) {
|
||||
if (signature == NULL) {
|
||||
if (signature == nullptr) {
|
||||
LOGE("No signature buffer provided");
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
@@ -1833,7 +1834,7 @@ bool CdmEngine::IsKeyLoaded(const KeyId& key_id) {
|
||||
|
||||
bool CdmEngine::FindSessionForKey(const KeyId& key_id,
|
||||
CdmSessionId* session_id) {
|
||||
if (NULL == session_id) {
|
||||
if (session_id == nullptr) {
|
||||
LOGE("No session ID destination provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user