Replace deprecated scoped_array<T> with scoped_ptr<T[]> BUG=chromium:338610 TEST=Build and run unit tests. Change-Id: If124895f42c5a5de9f86d301e748e08efc0e2381 Reviewed-on: https://chromium-review.googlesource.com/184081 Reviewed-by: Darren Krahn <dkrahn@chromium.org> Commit-Queue: Ben Chan <benchan@chromium.org> Tested-by: Ben Chan <benchan@chromium.org>
diff --git a/attributes.cc b/attributes.cc index f896848..ffb3663 100644 --- a/attributes.cc +++ b/attributes.cc
@@ -134,7 +134,7 @@ LOG(ERROR) << "Failed to parse proto-buffer."; return false; } - scoped_array<CK_ATTRIBUTE> attribute_array( + scoped_ptr<CK_ATTRIBUTE[]> attribute_array( new CK_ATTRIBUTE[attribute_list.attribute_size()]); CHECK(attribute_array.get()); for (int i = 0; i < attribute_list.attribute_size(); ++i) {
diff --git a/chaps_service_redirect.cc b/chaps_service_redirect.cc index 9ee28d3..351b69e 100644 --- a/chaps_service_redirect.cc +++ b/chaps_service_redirect.cc
@@ -99,7 +99,7 @@ // First, call with NULL to retrieve the slot count. CK_RV result = functions_->C_GetSlotList(token_present, NULL, &count); LOG_CK_RV_AND_RETURN_IF_ERR(result); - scoped_array<CK_SLOT_ID> slot_array(new CK_SLOT_ID[count]); + scoped_ptr<CK_SLOT_ID[]> slot_array(new CK_SLOT_ID[count]); CHECK(slot_array.get()) << "GetSlotList out of memory."; // Now, query the actual list. result = functions_->C_GetSlotList(token_present, slot_array.get(), &count); @@ -216,7 +216,7 @@ // First, call with NULL to retrieve the mechanism count. CK_RV result = functions_->C_GetMechanismList(slot_id, NULL, &count); LOG_CK_RV_AND_RETURN_IF_ERR(result); - scoped_array<CK_MECHANISM_TYPE> mech_array(new CK_MECHANISM_TYPE[count]); + scoped_ptr<CK_MECHANISM_TYPE[]> mech_array(new CK_MECHANISM_TYPE[count]); LOG_CK_RV_AND_RETURN_IF(!mech_array.get(), CKR_HOST_MEMORY); // Now, query the actual list. result = functions_->C_GetMechanismList(slot_id, mech_array.get(), &count); @@ -360,7 +360,7 @@ // First, call with NULL to retrieve the state size. CK_RV result = functions_->C_GetOperationState(session_id, NULL, &size); LOG_CK_RV_AND_RETURN_IF_ERR(result); - scoped_array<CK_BYTE> buffer(new CK_BYTE[size]); + scoped_ptr<CK_BYTE[]> buffer(new CK_BYTE[size]); LOG_CK_RV_AND_RETURN_IF(!buffer.get(), CKR_HOST_MEMORY); // Now, get the actual state data. result = functions_->C_GetOperationState(session_id, buffer.get(), &size); @@ -532,7 +532,7 @@ LOG_CK_RV_AND_RETURN_IF(!Init2(), CKR_GENERAL_ERROR); if (!object_list || object_list->size() > 0) LOG_CK_RV_AND_RETURN(CKR_ARGUMENTS_BAD); - scoped_array<CK_OBJECT_HANDLE> object_handles( + scoped_ptr<CK_OBJECT_HANDLE[]> object_handles( new CK_OBJECT_HANDLE[max_object_count]); CHECK(object_handles.get()); CK_ULONG object_count = 0; @@ -585,7 +585,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -615,7 +615,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -642,7 +642,7 @@ vector<uint8_t>* data_out) { LOG_CK_RV_AND_RETURN_IF(!Init2(), CKR_GENERAL_ERROR); LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -688,7 +688,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -719,7 +719,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -746,7 +746,7 @@ vector<uint8_t>* data_out) { LOG_CK_RV_AND_RETURN_IF(!Init2(), CKR_GENERAL_ERROR); LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -788,7 +788,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !digest, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -837,7 +837,7 @@ vector<uint8_t>* digest) { LOG_CK_RV_AND_RETURN_IF(!Init2(), CKR_GENERAL_ERROR); LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !digest, CKR_ARGUMENTS_BAD); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -880,7 +880,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !signature, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -919,7 +919,7 @@ vector<uint8_t>* signature) { LOG_CK_RV_AND_RETURN_IF(!Init2(), CKR_GENERAL_ERROR); LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !signature, CKR_ARGUMENTS_BAD); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -964,7 +964,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !signature, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -1075,7 +1075,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&signature.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -1105,7 +1105,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -1135,7 +1135,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -1165,7 +1165,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -1195,7 +1195,7 @@ LOG_CK_RV_AND_RETURN_IF(!actual_out_length || !data_out, CKR_ARGUMENTS_BAD); CK_BYTE_PTR in_bytes = static_cast<CK_BYTE_PTR>(const_cast<uint8_t*>(&data_in.front())); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -1292,7 +1292,7 @@ mechanism.mechanism = static_cast<CK_MECHANISM_TYPE>(mechanism_type); mechanism.pParameter = const_cast<uint8_t*>(&mechanism_parameter.front()); mechanism.ulParameterLen = mechanism_parameter.size(); - scoped_array<CK_BYTE> out_bytes(NULL); + scoped_ptr<CK_BYTE[]> out_bytes; if (max_out_length) { out_bytes.reset(new CK_BYTE[max_out_length]); CHECK(out_bytes.get()); @@ -1390,7 +1390,7 @@ vector<uint8_t>* random_data) { LOG_CK_RV_AND_RETURN_IF(!Init2(), CKR_GENERAL_ERROR); LOG_CK_RV_AND_RETURN_IF(!random_data || num_bytes == 0, CKR_ARGUMENTS_BAD); - scoped_array<CK_BYTE> out_bytes(new CK_BYTE[num_bytes]); + scoped_ptr<CK_BYTE[]> out_bytes(new CK_BYTE[num_bytes]); CHECK(out_bytes.get()); uint32_t result = functions_->C_GenerateRandom(session_id, out_bytes.get(),