diff options
author | brettw <brettw@chromium.org> | 2015-02-13 13:17:38 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-13 21:18:03 +0000 |
commit | 669d47b1bf59279718ab6ef07e9eb69fb42c8aa4 (patch) | |
tree | b15811ec34801807c35d73a74f8ef6b72d10f768 | |
parent | fb2a760558d423c55722e2a6f36d9c805f4eb9b6 (diff) | |
download | chromium_src-669d47b1bf59279718ab6ef07e9eb69fb42c8aa4.zip chromium_src-669d47b1bf59279718ab6ef07e9eb69fb42c8aa4.tar.gz chromium_src-669d47b1bf59279718ab6ef07e9eb69fb42c8aa4.tar.bz2 |
Enable size_t to int truncation warnings in PPAPI
Also removed a few extra "-Wpedantic" warnings in ppapi_cpp. I don't see a good justification why this should be different than the rest of the project.
Fix GN error in media.
NOPRESUBMIT=true
Review URL: https://codereview.chromium.org/915403003
Cr-Commit-Position: refs/heads/master@{#316289}
59 files changed, 192 insertions, 201 deletions
diff --git a/media/BUILD.gn b/media/BUILD.gn index 9773484..d9e2399 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -650,8 +650,8 @@ test("media_unittests") { } if (is_win && cpu_arch == "x64") { - cflags += [ "/wd4267" ] # TODO(wolenetz): Fix size_t to int trunctaion in win64. See - # http://crbug.com/171009 + cflags = [ "/wd4267" ] # TODO(wolenetz): Fix size_t to int trunctaion in win64. See + # http://crbug.com/171009 } if (is_mac || is_ios) { diff --git a/ppapi/BUILD.gn b/ppapi/BUILD.gn index dd722c1..24827ab 100644 --- a/ppapi/BUILD.gn +++ b/ppapi/BUILD.gn @@ -29,15 +29,6 @@ source_set("ppapi_macros") { source_set("ppapi_cpp_objects") { sources = gypi_values.cpp_source_files - - if (is_win) { - cflags = [ "/we4244" ] # Implicit conversion, possible loss of data. - } else { - cflags = [ - "-Wextra", - "-pedantic", - ] - } } source_set("ppapi_cpp") { @@ -46,13 +37,6 @@ source_set("ppapi_cpp") { "cpp/ppp_entrypoints.cc", ] - if (is_posix) { - cflags = [ - "-Wextra", - "-pedantic", - ] - } - deps = [ ":ppapi_c", ":ppapi_cpp_objects", @@ -433,8 +417,6 @@ component("ppapi_shared") { if (is_mac) { libs = [ "QuartzCore.framework" ] - } else if (is_win) { - cflags = [ "/wd4267" ] # size_t to int truncation. } } @@ -750,10 +732,6 @@ component("ppapi_proxy") { "//ui/surface", blink_target, ] - - if (is_win) { - cflags = [ "/wd4267" ] # size_t to int truncation. - } } component("ppapi_host") { diff --git a/ppapi/cpp/dev/file_chooser_dev.cc b/ppapi/cpp/dev/file_chooser_dev.cc index b7124a1..2efb346 100644 --- a/ppapi/cpp/dev/file_chooser_dev.cc +++ b/ppapi/cpp/dev/file_chooser_dev.cc @@ -82,7 +82,7 @@ void FileChooser_Dev::CallbackConverter(void* user_data, int32_t result) { // number of items is 0. void* output_buf = data->output.GetDataBuffer( data->output.user_data, - selected_files.size(), sizeof(PP_Resource)); + static_cast<uint32_t>(selected_files.size()), sizeof(PP_Resource)); if (output_buf) { if (!selected_files.empty()) { memcpy(output_buf, &selected_files[0], diff --git a/ppapi/cpp/dev/ime_input_event_dev.cc b/ppapi/cpp/dev/ime_input_event_dev.cc index 9ddc16e..3396a39 100644 --- a/ppapi/cpp/dev/ime_input_event_dev.cc +++ b/ppapi/cpp/dev/ime_input_event_dev.cc @@ -61,7 +61,8 @@ IMEInputEvent_Dev::IMEInputEvent_Dev( uint32_t dummy = 0; PassRefFromConstructor(get_interface<PPB_IMEInputEvent_Dev_0_2>()->Create( instance.pp_instance(), type, time_stamp, text.pp_var(), - segment_offsets.empty() ? 0 : segment_offsets.size() - 1, + segment_offsets.empty() ? 0u : + static_cast<uint32_t>(segment_offsets.size() - 1), segment_offsets.empty() ? &dummy : &segment_offsets[0], target_segment, selection.first, selection.second)); } diff --git a/ppapi/cpp/dev/scriptable_object_deprecated.cc b/ppapi/cpp/dev/scriptable_object_deprecated.cc index 1b701cb..19c4738 100644 --- a/ppapi/cpp/dev/scriptable_object_deprecated.cc +++ b/ppapi/cpp/dev/scriptable_object_deprecated.cc @@ -73,8 +73,8 @@ void GetAllPropertyNames(void* object, const PPB_Memory_Dev* memory_if = static_cast<const PPB_Memory_Dev*>( pp::Module::Get()->GetBrowserInterface(PPB_MEMORY_DEV_INTERFACE)); - *properties = static_cast<PP_Var*>( - memory_if->MemAlloc(sizeof(PP_Var) * props.size())); + *properties = static_cast<PP_Var*>(memory_if->MemAlloc( + static_cast<uint32_t>(sizeof(PP_Var) * props.size()))); for (size_t i = 0; i < props.size(); ++i) (*properties)[i] = props[i].Detach(); diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc index dcc3b5d..df34986 100644 --- a/ppapi/cpp/dev/video_decoder_dev.cc +++ b/ppapi/cpp/dev/video_decoder_dev.cc @@ -42,7 +42,7 @@ void VideoDecoder_Dev::AssignPictureBuffers( if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) return; get_interface<PPB_VideoDecoder_Dev>()->AssignPictureBuffers( - pp_resource(), buffers.size(), &buffers[0]); + pp_resource(), static_cast<uint32_t>(buffers.size()), &buffers[0]); } int32_t VideoDecoder_Dev::Decode( diff --git a/ppapi/cpp/input_event.cc b/ppapi/cpp/input_event.cc index 93385bf..90f41fa 100644 --- a/ppapi/cpp/input_event.cc +++ b/ppapi/cpp/input_event.cc @@ -364,7 +364,8 @@ IMEInputEvent::IMEInputEvent( uint32_t dummy = 0; PassRefFromConstructor(get_interface<PPB_IMEInputEvent_1_0>()->Create( instance.pp_instance(), type, time_stamp, text.pp_var(), - segment_offsets.empty() ? 0 : segment_offsets.size() - 1, + segment_offsets.empty() ? 0u : + static_cast<uint32_t>(segment_offsets.size() - 1), segment_offsets.empty() ? &dummy : &segment_offsets[0], target_segment, selection.first, selection.second)); } diff --git a/ppapi/cpp/private/content_decryptor_private.cc b/ppapi/cpp/private/content_decryptor_private.cc index 76dc2f3..1e26661 100644 --- a/ppapi/cpp/private/content_decryptor_private.cc +++ b/ppapi/cpp/private/content_decryptor_private.cc @@ -329,7 +329,8 @@ void ContentDecryptor_Private::SessionKeysChange( pp::Var session_id_var(session_id); get_interface<PPB_ContentDecryptor_Private>()->SessionKeysChange( associated_instance_.pp_instance(), session_id_var.pp_var(), - PP_FromBool(has_additional_usable_key), key_information.size(), + PP_FromBool(has_additional_usable_key), + static_cast<uint32_t>(key_information.size()), key_information.empty() ? NULL : &key_information[0]); } } diff --git a/ppapi/cpp/private/flash_clipboard.cc b/ppapi/cpp/private/flash_clipboard.cc index 77e68ba..1fb5288 100644 --- a/ppapi/cpp/private/flash_clipboard.cc +++ b/ppapi/cpp/private/flash_clipboard.cc @@ -133,7 +133,7 @@ bool Clipboard::WriteData( rv = (get_interface<PPB_Flash_Clipboard_5_1>()->WriteData( instance.pp_instance(), clipboard_type, - data_items.size(), + static_cast<uint32_t>(data_items.size()), formats_ptr, data_items_ptr) == PP_OK); } else if (has_interface<PPB_Flash_Clipboard_5_0>()) { @@ -155,7 +155,7 @@ bool Clipboard::WriteData( rv = (get_interface<PPB_Flash_Clipboard_5_0>()->WriteData( instance.pp_instance(), clipboard_type, - data_items.size(), + static_cast<uint32_t>(data_items.size()), formats_ptr, data_items_ptr) == PP_OK); } else if (has_interface<PPB_Flash_Clipboard_4_0>()) { @@ -180,7 +180,7 @@ bool Clipboard::WriteData( rv = (get_interface<PPB_Flash_Clipboard_4_0>()->WriteData( instance.pp_instance(), clipboard_type, - data_items.size(), + static_cast<uint32_t>(data_items.size()), formats_ptr, data_items_ptr) == PP_OK); } diff --git a/ppapi/examples/gamepad/gamepad.cc b/ppapi/examples/gamepad/gamepad.cc index a94ccd4..d7f0053 100644 --- a/ppapi/examples/gamepad/gamepad.cc +++ b/ppapi/examples/gamepad/gamepad.cc @@ -108,7 +108,7 @@ class MyInstance : public pp::Instance { for (size_t i = 0; i < gamepad_data.items[0].buttons_length; ++i) { float button_val = gamepad_data.items[0].buttons[i]; uint32_t colour = static_cast<uint32_t>((button_val * 192) + 63) << 24; - int x = i * 8 + 10; + int x = static_cast<int>(i) * 8 + 10; int y = 10; FillRect(&image, x - 3, y - 3, 7, 7, colour); } diff --git a/ppapi/examples/ime/ime.cc b/ppapi/examples/ime/ime.cc index 26c2f42..805d140 100644 --- a/ppapi/examples/ime/ime.cc +++ b/ppapi/examples/ime/ime.cc @@ -112,7 +112,8 @@ class TextFieldStatusNotifyingHandler : public TextFieldStatusHandler { textinput_control_.SetTextInputType(PP_TEXTINPUT_TYPE_NONE); } virtual void UpdateSelection(const std::string& text) { - textinput_control_.UpdateSurroundingText(text, 0, text.size()); + textinput_control_.UpdateSurroundingText( + text, 0, static_cast<uint32_t>(text.size())); } private: diff --git a/ppapi/examples/printing/printing.cc b/ppapi/examples/printing/printing.cc index b87fc4f..37a7273 100644 --- a/ppapi/examples/printing/printing.cc +++ b/ppapi/examples/printing/printing.cc @@ -67,7 +67,7 @@ class MyInstance : public pp::Instance, public pp::Printing_Dev { const PP_PrintPageNumberRange_Dev* page_ranges, uint32_t page_range_count) { size_t pdf_len = strlen(pdf_data); - pp::Buffer_Dev buffer(this, pdf_len); + pp::Buffer_Dev buffer(this, static_cast<uint32_t>(pdf_len)); memcpy(buffer.data(), pdf_data, pdf_len); return buffer; diff --git a/ppapi/examples/video_decode/video_decode.cc b/ppapi/examples/video_decode/video_decode.cc index ebfb80e..10e0536 100644 --- a/ppapi/examples/video_decode/video_decode.cc +++ b/ppapi/examples/video_decode/video_decode.cc @@ -662,11 +662,12 @@ Shader MyInstance::CreateProgram(const char* vertex_shader, // Create shader program. shader.program = gles2_if_->CreateProgram(context_->pp_resource()); CreateShader( - shader.program, GL_VERTEX_SHADER, vertex_shader, strlen(vertex_shader)); + shader.program, GL_VERTEX_SHADER, vertex_shader, + static_cast<uint32_t>(strlen(vertex_shader))); CreateShader(shader.program, GL_FRAGMENT_SHADER, fragment_shader, - strlen(fragment_shader)); + static_cast<int>(strlen(fragment_shader))); gles2_if_->LinkProgram(context_->pp_resource(), shader.program); gles2_if_->UseProgram(context_->pp_resource(), shader.program); gles2_if_->Uniform1i( diff --git a/ppapi/examples/video_decode/video_decode_dev.cc b/ppapi/examples/video_decode/video_decode_dev.cc index d054e36..1cacb1b 100644 --- a/ppapi/examples/video_decode/video_decode_dev.cc +++ b/ppapi/examples/video_decode/video_decode_dev.cc @@ -341,11 +341,12 @@ void VideoDecodeDemoInstance::DecoderClient::DecodeNextNALU() { size_t start_pos = encoded_data_next_pos_to_decode_; size_t end_pos; GetNextNALUBoundary(start_pos, &end_pos); - pp::Buffer_Dev* buffer = new pp::Buffer_Dev(gles2_, end_pos - start_pos); + pp::Buffer_Dev* buffer = new pp::Buffer_Dev( + gles2_, static_cast<uint32_t>(end_pos - start_pos)); PP_VideoBitstreamBuffer_Dev bitstream_buffer; int id = ++next_bitstream_buffer_id_; bitstream_buffer.id = id; - bitstream_buffer.size = end_pos - start_pos; + bitstream_buffer.size = static_cast<uint32_t>(end_pos - start_pos); bitstream_buffer.data = buffer->pp_resource(); memcpy(buffer->data(), kData + start_pos, end_pos - start_pos); assert(bitstream_buffers_by_id_.insert(std::make_pair(id, buffer)).second); @@ -637,9 +638,9 @@ Shader VideoDecodeDemoInstance::CreateProgram(const char* vertex_shader, // Create shader program. shader.program = gles2_if_->CreateProgram(context_->pp_resource()); CreateShader(shader.program, GL_VERTEX_SHADER, vertex_shader, - strlen(vertex_shader)); + static_cast<int>(strlen(vertex_shader))); CreateShader(shader.program, GL_FRAGMENT_SHADER, fragment_shader, - strlen(fragment_shader)); + static_cast<int>(strlen(fragment_shader))); gles2_if_->LinkProgram(context_->pp_resource(), shader.program); gles2_if_->UseProgram(context_->pp_resource(), shader.program); gles2_if_->Uniform1i( diff --git a/ppapi/ppapi_cpp.gypi b/ppapi/ppapi_cpp.gypi index bf4d225..04d0d41 100644 --- a/ppapi/ppapi_cpp.gypi +++ b/ppapi/ppapi_cpp.gypi @@ -36,26 +36,6 @@ 'sources': [ '<@(cpp_source_files)', ], - 'conditions': [ - ['OS=="win"', { - 'msvs_settings': { - 'VCCLCompilerTool': { - 'AdditionalOptions': ['/we4244'], # implicit conversion, possible loss of data - }, - }, - 'msvs_disabled_warnings': [ - 4267, - ], - }], - ['OS=="linux"', { - 'cflags': ['-Wextra', '-pedantic'], - }], - ['OS=="mac"', { - 'xcode_settings': { - 'WARNING_CFLAGS': ['-Wextra', '-pedantic'], - }, - }], - ], }, { # GN version: //ppapi:ppapi_cpp @@ -72,16 +52,6 @@ 'cpp/module_embedder.h', 'cpp/ppp_entrypoints.cc', ], - 'conditions': [ - ['OS=="linux"', { - 'cflags': ['-Wextra', '-pedantic'], - }], - ['OS=="mac"', { - 'xcode_settings': { - 'WARNING_CFLAGS': ['-Wextra', '-pedantic'], - }, - }] - ], }, { # GN version: //ppapi:ppapi_internal_module diff --git a/ppapi/ppapi_internal.gyp b/ppapi/ppapi_internal.gyp index d96770e..4370640 100644 --- a/ppapi/ppapi_internal.gyp +++ b/ppapi/ppapi_internal.gyp @@ -85,8 +85,6 @@ ], }], ], - # Disable c4267 warnings until we fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, ], 'conditions': [ @@ -144,8 +142,6 @@ '..', ], }, - # Disable c4267 warnings until we fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], 'conditions': [ ['chrome_multiple_dll==1', { 'dependencies': [ @@ -195,8 +191,6 @@ '..', ], }, - # Disable c4267 warnings until we fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], 'conditions': [ ['chrome_multiple_dll==1', { 'dependencies': [ diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi index d7bf047..63c3370 100644 --- a/ppapi/ppapi_tests.gypi +++ b/ppapi/ppapi_tests.gypi @@ -55,8 +55,6 @@ '_CRT_NONSTDC_NO_DEPRECATE', '_SCL_SECURE_NO_DEPRECATE', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }], ['OS=="mac"', { 'mac_bundle': 1, @@ -64,8 +62,6 @@ 'product_extension': 'plugin', }], ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], # TODO(dmichael): Figure out what is wrong with the script on Windows and add # it as an automated action. # 'actions': [ @@ -200,8 +196,6 @@ ], }], ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { 'target_name': 'ppapi_example_skeleton', @@ -262,8 +256,6 @@ 'sources': [ 'examples/gamepad/gamepad.cc', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { @@ -345,8 +337,6 @@ 'sources': [ 'examples/ime/ime.cc', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { 'target_name': 'ppapi_example_paint_manager', @@ -456,8 +446,6 @@ 'examples/video_decode/video_decode.cc', 'examples/video_decode/testdata.h', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { 'target_name': 'ppapi_example_video_decode_dev', @@ -473,8 +461,6 @@ 'examples/video_decode/video_decode_dev.cc', 'examples/video_decode/testdata.h', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { 'target_name': 'ppapi_example_vc', @@ -529,8 +515,6 @@ 'sources': [ 'examples/printing/printing.cc', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, { 'target_name': 'ppapi_example_media_stream_audio', diff --git a/ppapi/proxy/audio_input_resource.cc b/ppapi/proxy/audio_input_resource.cc index 7f1f819..4a24255 100644 --- a/ppapi/proxy/audio_input_resource.cc +++ b/ppapi/proxy/audio_input_resource.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "ipc/ipc_platform_file.h" #include "media/audio/audio_parameters.h" #include "media/base/audio_bus.h" @@ -249,7 +250,8 @@ void AudioInputResource::Run() { media::AudioInputBuffer* buffer = static_cast<media::AudioInputBuffer*>(shared_memory_->memory()); const uint32_t audio_bus_size_bytes = - shared_memory_size_ - sizeof(media::AudioInputBufferParameters); + base::checked_cast<uint32_t>(shared_memory_size_ - + sizeof(media::AudioInputBufferParameters)); while (true) { int pending_data = 0; diff --git a/ppapi/proxy/device_enumeration_resource_helper.cc b/ppapi/proxy/device_enumeration_resource_helper.cc index 18b1939..32a4e1db 100644 --- a/ppapi/proxy/device_enumeration_resource_helper.cc +++ b/ppapi/proxy/device_enumeration_resource_helper.cc @@ -146,7 +146,7 @@ void DeviceEnumerationResourceHelper::OnPluginMsgNotifyDeviceChange( CHECK(monitor_callback_.get()); scoped_ptr<PP_Resource[]> elements; - uint32_t size = devices.size(); + uint32_t size = static_cast<uint32_t>(devices.size()); if (size > 0) { elements.reset(new PP_Resource[size]); for (size_t index = 0; index < size; ++index) { diff --git a/ppapi/proxy/file_ref_resource.cc b/ppapi/proxy/file_ref_resource.cc index 098ef5f..ee56969 100644 --- a/ppapi/proxy/file_ref_resource.cc +++ b/ppapi/proxy/file_ref_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/file_ref_resource.h" +#include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_directory_entry.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -29,7 +30,7 @@ FileRefResource::FileRefResource( if (uses_internal_paths()) { // If path ends with a slash, then normalize it away unless path is // the root path. - int path_size = create_info_.internal_path.size(); + int path_size = base::checked_cast<int>(create_info_.internal_path.size()); if (path_size > 1 && create_info_.internal_path.at(path_size - 1) == '/') create_info_.internal_path.erase(path_size - 1, 1); diff --git a/ppapi/proxy/flash_clipboard_resource.cc b/ppapi/proxy/flash_clipboard_resource.cc index 2b665bf..28df94c 100644 --- a/ppapi/proxy/flash_clipboard_resource.cc +++ b/ppapi/proxy/flash_clipboard_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/flash_clipboard_resource.h" +#include "base/numerics/safe_conversions.h" #include "ipc/ipc_message.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/ppapi_messages.h" @@ -53,7 +54,7 @@ PP_Var ClipboardStringToPPVar(int32_t format, } else { // All other formats are expected to be array buffers. return PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( - string.size(), string.data()); + base::checked_cast<uint32_t>(string.size()), string.data()); } } } // namespace diff --git a/ppapi/proxy/pdf_resource.cc b/ppapi/proxy/pdf_resource.cc index 7d20d91..e9d3ae8 100644 --- a/ppapi/proxy/pdf_resource.cc +++ b/ppapi/proxy/pdf_resource.cc @@ -89,7 +89,7 @@ void PDFResource::SearchString(const unsigned short* input_string, std::vector<PP_PrivateFindResult> pp_results; while (match_start != USEARCH_DONE) { - size_t matched_length = usearch_getMatchedLength(searcher); + int32_t matched_length = usearch_getMatchedLength(searcher); PP_PrivateFindResult result; result.start_index = match_start; result.length = matched_length; @@ -98,7 +98,7 @@ void PDFResource::SearchString(const unsigned short* input_string, DCHECK(status == U_ZERO_ERROR); } - *count = pp_results.size(); + *count = static_cast<uint32_t>(pp_results.size()); if (*count) { *results = reinterpret_cast<PP_PrivateFindResult*>(malloc( *count * sizeof(PP_PrivateFindResult))); diff --git a/ppapi/proxy/platform_verification_private_resource.cc b/ppapi/proxy/platform_verification_private_resource.cc index 76d5148..27804d3 100644 --- a/ppapi/proxy/platform_verification_private_resource.cc +++ b/ppapi/proxy/platform_verification_private_resource.cc @@ -88,10 +88,11 @@ void PlatformVerificationPrivateResource::OnChallengePlatformReply( if (params.result() == PP_OK) { *(output_params.signed_data) = (PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( - raw_signed_data.size(), &raw_signed_data.front()))->GetPPVar(); + static_cast<uint32_t>(raw_signed_data.size()), + &raw_signed_data.front()))->GetPPVar(); *(output_params.signed_data_signature) = (PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( - raw_signed_data_signature.size(), + static_cast<uint32_t>(raw_signed_data_signature.size()), &raw_signed_data_signature.front()))->GetPPVar(); *(output_params.platform_key_certificate) = (new StringVar(raw_platform_key_certificate))->GetPPVar(); diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc index 571210e..644e79e 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.cc +++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/ppapi_command_buffer_proxy.h" +#include "base/numerics/safe_conversions.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/proxy_channel.h" #include "ppapi/shared_impl/api_id.h" @@ -122,7 +123,8 @@ scoped_refptr<gpu::Buffer> PpapiCommandBufferProxy::CreateTransferBuffer( ppapi::proxy::SerializedHandle handle( ppapi::proxy::SerializedHandle::SHARED_MEMORY); if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer( - ppapi::API_ID_PPB_GRAPHICS_3D, resource_, size, id, &handle))) { + ppapi::API_ID_PPB_GRAPHICS_3D, resource_, + base::checked_cast<uint32_t>(size), id, &handle))) { return NULL; } diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index 7cd2b88..6b49914 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/ppb_graphics_3d_proxy.h" +#include "base/numerics/safe_conversions.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/common/command_buffer.h" #include "ppapi/c/pp_errors.h" @@ -315,7 +316,7 @@ void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer( DCHECK(backing && backing->shared_memory()); transfer_buffer->set_shmem( TransportSHMHandle(dispatcher(), backing->shared_memory()->handle()), - buffer->size()); + base::checked_cast<uint32_t>(buffer->size())); } else { *id = -1; } diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index f8b8ac9..2897757 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/ppb_instance_proxy.h" #include "base/memory/ref_counted.h" +#include "base/numerics/safe_conversions.h" #include "base/stl_util.h" #include "build/build_config.h" #include "media/base/limits.h" @@ -1302,7 +1303,8 @@ void PPB_Instance_Proxy::OnHostMsgSessionKeysChange( StringVar::StringToPPVar(session_id)); enter.functions()->SessionKeysChange( instance, session_id_var.get(), has_additional_usable_key, - key_information.size(), vector_as_array(&key_information)); + base::checked_cast<uint32_t>(key_information.size()), + vector_as_array(&key_information)); } } diff --git a/ppapi/proxy/ppb_testing_proxy.cc b/ppapi/proxy/ppb_testing_proxy.cc index 0dbab0b..606cdc31 100644 --- a/ppapi/proxy/ppb_testing_proxy.cc +++ b/ppapi/proxy/ppb_testing_proxy.cc @@ -112,7 +112,7 @@ uint32_t GetLiveVars(PP_Var live_vars[], uint32_t array_size) { i < std::min(static_cast<size_t>(array_size), vars.size()); ++i) live_vars[i] = vars[i]; - return vars.size(); + return static_cast<uint32_t>(vars.size()); } void SetMinimumArrayBufferSizeForShmem(PP_Instance instance, diff --git a/ppapi/proxy/ppb_var_unittest.cc b/ppapi/proxy/ppb_var_unittest.cc index 5e25379..98b6428 100644 --- a/ppapi/proxy/ppb_var_unittest.cc +++ b/ppapi/proxy/ppb_var_unittest.cc @@ -33,7 +33,7 @@ class PPB_VarTest : public PluginProxyTest { ppb_var_(ppapi::PPB_Var_Shared::GetVarInterface1_2()) { // Set the value of test_strings_[i] to "i". for (size_t i = 0; i < kNumStrings; ++i) - test_strings_[i] = base::IntToString(i); + test_strings_[i] = base::IntToString(static_cast<int>(i)); } protected: std::vector<std::string> test_strings_; @@ -44,8 +44,9 @@ class PPB_VarTest : public PluginProxyTest { // Test basic String operations. TEST_F(PPB_VarTest, Strings) { for (size_t i = 0; i < kNumStrings; ++i) { - vars_[i] = ppb_var_->VarFromUtf8(test_strings_[i].c_str(), - test_strings_[i].length()); + vars_[i] = ppb_var_->VarFromUtf8( + test_strings_[i].c_str(), + static_cast<uint32_t>(test_strings_[i].length())); EXPECT_EQ(test_strings_[i], VarToString(vars_[i], ppb_var_)); } // At this point, they should each have a ref count of 1. Add some more. @@ -104,8 +105,9 @@ class CreateVarThreadDelegate : public base::PlatformThread::Delegate { virtual void ThreadMain() { const PPB_Var* ppb_var = ppapi::PPB_Var_Shared::GetVarInterface1_2(); for (size_t i = 0; i < size_; ++i) { - vars_out_[i] = ppb_var->VarFromUtf8(strings_in_[i].c_str(), - strings_in_[i].length()); + vars_out_[i] = ppb_var->VarFromUtf8( + strings_in_[i].c_str(), + static_cast<uint32_t>(strings_in_[i].length())); strings_out_[i] = VarToString(vars_out_[i], ppb_var); } } diff --git a/ppapi/proxy/ppb_video_decoder_proxy.cc b/ppapi/proxy/ppb_video_decoder_proxy.cc index 7699c84..779294f 100644 --- a/ppapi/proxy/ppb_video_decoder_proxy.cc +++ b/ppapi/proxy/ppb_video_decoder_proxy.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "ppapi/proxy/enter_proxy.h" #include "ppapi/proxy/plugin_dispatcher.h" @@ -247,7 +248,8 @@ void PPB_VideoDecoder_Proxy::OnMsgAssignPictureBuffers( EnterHostFromHostResource<PPB_VideoDecoder_Dev_API> enter(decoder); if (enter.succeeded() && !buffers.empty()) { const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); - enter.object()->AssignPictureBuffers(buffers.size(), buffer_array); + enter.object()->AssignPictureBuffers( + base::checked_cast<uint32_t>(buffers.size()), buffer_array); } } diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc index 91ea370..329714b 100644 --- a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc +++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc @@ -544,8 +544,9 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgSetServerCertificate( ScopedPPVar::PassRef(), PpapiGlobals::Get() ->GetVarTracker() - ->MakeArrayBufferPPVar(server_certificate.size(), - &server_certificate[0])); + ->MakeArrayBufferPPVar( + static_cast<uint32_t>(server_certificate.size()), + &server_certificate[0])); CallWhileUnlocked(ppp_decryptor_impl_->SetServerCertificate, instance, promise_id, diff --git a/ppapi/proxy/ppp_instance_proxy_unittest.cc b/ppapi/proxy/ppp_instance_proxy_unittest.cc index e2df26e..18ec919 100644 --- a/ppapi/proxy/ppp_instance_proxy_unittest.cc +++ b/ppapi/proxy/ppp_instance_proxy_unittest.cc @@ -140,7 +140,7 @@ TEST_F(PPP_Instance_ProxyTest, PPPInstance1_0) { argn_to_pass.push_back(expected_argn[i].c_str()); argv_to_pass.push_back(expected_argv[i].c_str()); } - uint32_t expected_argc = expected_argn.size(); + uint32_t expected_argc = static_cast<uint32_t>(expected_argn.size()); bool_to_return = PP_TRUE; ResetReceived(); // Tell the host resource tracker about the instance. diff --git a/ppapi/proxy/ppp_printing_proxy.cc b/ppapi/proxy/ppp_printing_proxy.cc index 7b2ae55..780b91f 100644 --- a/ppapi/proxy/ppp_printing_proxy.cc +++ b/ppapi/proxy/ppp_printing_proxy.cc @@ -6,6 +6,7 @@ #include <string.h> +#include "base/numerics/safe_conversions.h" #include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" @@ -180,7 +181,7 @@ void PPP_Printing_Proxy::OnPluginMsgPrintPages( PP_Resource plugin_resource = CallWhileUnlocked( ppp_printing_impl_->PrintPages, - instance, &pages[0], pages.size()); + instance, &pages[0], base::checked_cast<uint32_t>(pages.size())); ResourceTracker* resource_tracker = PpapiGlobals::Get()->GetResourceTracker(); Resource* resource_object = resource_tracker->GetResource(plugin_resource); if (!resource_object) diff --git a/ppapi/proxy/raw_var_data_unittest.cc b/ppapi/proxy/raw_var_data_unittest.cc index 7dba345..3539d675 100644 --- a/ppapi/proxy/raw_var_data_unittest.cc +++ b/ppapi/proxy/raw_var_data_unittest.cc @@ -96,7 +96,7 @@ TEST_F(RawVarDataTest, StringTest) { TEST_F(RawVarDataTest, ArrayBufferTest) { std::string data = "hello world!"; PP_Var var = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( - data.size(), data.data()); + static_cast<uint32_t>(data.size()), data.data()); EXPECT_TRUE(WriteReadAndCompare(var)); var = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 0, static_cast<void*>(NULL)); @@ -113,25 +113,25 @@ TEST_F(RawVarDataTest, DictionaryArrayTest) { size_t index = 0; // Array with primitives. - array->Set(index++, PP_MakeUndefined()); - array->Set(index++, PP_MakeNull()); - array->Set(index++, PP_MakeInt32(100)); - array->Set(index++, PP_MakeBool(PP_FALSE)); - array->Set(index++, PP_MakeDouble(0.123)); + array->Set(static_cast<uint32_t>(index++), PP_MakeUndefined()); + array->Set(static_cast<uint32_t>(index++), PP_MakeNull()); + array->Set(static_cast<uint32_t>(index++), PP_MakeInt32(100)); + array->Set(static_cast<uint32_t>(index++), PP_MakeBool(PP_FALSE)); + array->Set(static_cast<uint32_t>(index++), PP_MakeDouble(0.123)); EXPECT_TRUE(WriteReadAndCompare(array->GetPPVar())); // Array with 2 references to the same string. ScopedPPVar release_string( ScopedPPVar::PassRef(), StringVar::StringToPPVar("abc")); - array->Set(index++, release_string.get()); - array->Set(index++, release_string.get()); + array->Set(static_cast<uint32_t>(index++), release_string.get()); + array->Set(static_cast<uint32_t>(index++), release_string.get()); EXPECT_TRUE(WriteReadAndCompare(array->GetPPVar())); // Array with nested array that references the same string. scoped_refptr<ArrayVar> array2(new ArrayVar); ScopedPPVar release_array2(ScopedPPVar::PassRef(), array2->GetPPVar()); array2->Set(0, release_string.get()); - array->Set(index++, release_array2.get()); + array->Set(static_cast<uint32_t>(index++), release_array2.get()); EXPECT_TRUE(WriteReadAndCompare(array->GetPPVar())); // Empty dictionary. @@ -162,7 +162,7 @@ TEST_F(RawVarDataTest, DictionaryArrayTest) { EXPECT_TRUE(WriteReadAndCompare(dictionary->GetPPVar())); // Array with dictionary. - array->Set(index++, release_dictionary.get()); + array->Set(static_cast<uint32_t>(index++), release_dictionary.get()); EXPECT_TRUE(WriteReadAndCompare(array->GetPPVar())); // Array with dictionary with array. @@ -180,10 +180,10 @@ TEST_F(RawVarDataTest, DictionaryArrayTest) { dictionary->DeleteWithStringKey("10"); // Array with self references. - array->Set(index, release_array.get()); + array->Set(static_cast<uint32_t>(index), release_array.get()); ASSERT_FALSE(WriteAndRead(release_array.get(), &result)); // Break the self reference. - array->Set(index, PP_MakeUndefined()); + array->Set(static_cast<uint32_t>(index), PP_MakeUndefined()); } TEST_F(RawVarDataTest, ResourceTest) { diff --git a/ppapi/proxy/serialized_var_unittest.cc b/ppapi/proxy/serialized_var_unittest.cc index 206830e..d88c848 100644 --- a/ppapi/proxy/serialized_var_unittest.cc +++ b/ppapi/proxy/serialized_var_unittest.cc @@ -258,7 +258,7 @@ TEST_F(SerializedVarTest, PluginVectorReceiveInput) { // Take a reference to a string and then release it. Make sure no messages // are sent. - uint32_t old_message_count = sink().message_count(); + uint32_t old_message_count = static_cast<uint32_t>(sink().message_count()); var_tracker().AddRefVar(plugin_objects[1]); EXPECT_EQ(2, var_tracker().GetRefCountForObject(plugin_objects[1])); var_tracker().ReleaseVar(plugin_objects[1]); diff --git a/ppapi/proxy/url_loader_resource.cc b/ppapi/proxy/url_loader_resource.cc index 73bdb23..0697e90 100644 --- a/ppapi/proxy/url_loader_resource.cc +++ b/ppapi/proxy/url_loader_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/url_loader_resource.h" #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_url_loader.h" @@ -374,7 +375,7 @@ void URLLoaderResource::SaveResponseInfo(const URLResponseInfoData& data) { connection(), pp_instance(), data, body_as_file_ref); } -size_t URLLoaderResource::FillUserBuffer() { +int32_t URLLoaderResource::FillUserBuffer() { DCHECK(user_buffer_); DCHECK(user_buffer_size_); @@ -393,7 +394,7 @@ size_t URLLoaderResource::FillUserBuffer() { // Reset for next time. user_buffer_ = NULL; user_buffer_size_ = 0; - return bytes_to_copy; + return base::checked_cast<int32_t>(bytes_to_copy); } } // namespace proxy diff --git a/ppapi/proxy/url_loader_resource.h b/ppapi/proxy/url_loader_resource.h index 4986932..457dd4a 100644 --- a/ppapi/proxy/url_loader_resource.h +++ b/ppapi/proxy/url_loader_resource.h @@ -114,7 +114,7 @@ class PPAPI_PROXY_EXPORT URLLoaderResource // necessary. This does not issue any callbacks. void SaveResponseInfo(const URLResponseInfoData& data); - size_t FillUserBuffer(); + int32_t FillUserBuffer(); Mode mode_; URLRequestInfoData request_data_; diff --git a/ppapi/proxy/video_capture_resource.cc b/ppapi/proxy/video_capture_resource.cc index 5c95ed8..ca69d38 100644 --- a/ppapi/proxy/video_capture_resource.cc +++ b/ppapi/proxy/video_capture_resource.cc @@ -166,7 +166,7 @@ void VideoCaptureResource::OnPluginMsgOnDeviceInfo( pp_instance(), pp_resource(), &info, - buffers.size(), + static_cast<uint32_t>(buffers.size()), resources.get()); for (size_t i = 0; i < buffers.size(); ++i) diff --git a/ppapi/proxy/websocket_resource.cc b/ppapi/proxy/websocket_resource.cc index d03121a..bc4e853 100644 --- a/ppapi/proxy/websocket_resource.cc +++ b/ppapi/proxy/websocket_resource.cc @@ -9,6 +9,7 @@ #include <vector> #include "base/bind.h" +#include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/dispatch_reply_message.h" #include "ppapi/proxy/ppapi_messages.h" @@ -424,7 +425,7 @@ void WebSocketResource::OnPluginMsgReceiveBinaryReply( // Append received data to queue. scoped_refptr<Var> message_var( PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( - message.size(), + base::checked_cast<uint32_t>(message.size()), &message.front())); received_messages_.push(message_var); diff --git a/ppapi/proxy/websocket_resource_unittest.cc b/ppapi/proxy/websocket_resource_unittest.cc index 8c300ce..f65c2a5 100644 --- a/ppapi/proxy/websocket_resource_unittest.cc +++ b/ppapi/proxy/websocket_resource_unittest.cc @@ -47,7 +47,8 @@ PP_CompletionCallback MakeCallback() { PP_Var MakeStringVar(const std::string& string) { if (!ppb_var_) ppb_var_ = ppapi::PPB_Var_Shared::GetVarInterface1_2(); - return ppb_var_->VarFromUtf8(string.c_str(), string.length()); + return ppb_var_->VarFromUtf8(string.c_str(), + static_cast<uint32_t>(string.length())); } } // namespace diff --git a/ppapi/shared_impl/array_writer.h b/ppapi/shared_impl/array_writer.h index fce10e4..1d2608a 100644 --- a/ppapi/shared_impl/array_writer.h +++ b/ppapi/shared_impl/array_writer.h @@ -74,7 +74,8 @@ class PPAPI_SHARED_EXPORT ArrayWriter { // comment of StoreArray() for detail. template <typename T> bool StoreVector(const std::vector<T>& input) { - return StoreArray(input.size() ? &input[0] : NULL, input.size()); + return StoreArray(input.size() ? &input[0] : NULL, + static_cast<uint32_t>(input.size())); } // Stores the given vector of resources as PP_Resources to the output vector, diff --git a/ppapi/shared_impl/flash_clipboard_format_registry.cc b/ppapi/shared_impl/flash_clipboard_format_registry.cc index 89a051e..fa43478 100644 --- a/ppapi/shared_impl/flash_clipboard_format_registry.cc +++ b/ppapi/shared_impl/flash_clipboard_format_registry.cc @@ -6,6 +6,8 @@ #include <cctype> +#include "base/numerics/safe_conversions.h" + namespace ppapi { namespace { @@ -43,7 +45,8 @@ uint32_t FlashClipboardFormatRegistry::RegisterFormat( custom_formats_.size() > kMaxNumFormats) { return PP_FLASH_CLIPBOARD_FORMAT_INVALID; } - uint32_t key = kFirstCustomFormat + custom_formats_.size(); + uint32_t key = kFirstCustomFormat + + base::checked_cast<uint32_t>(custom_formats_.size()); custom_formats_[key] = format_name; return key; } diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc index 5b26804..8783905 100644 --- a/ppapi/tests/test_file_io.cc +++ b/ppapi/tests/test_file_io.cc @@ -150,7 +150,7 @@ int32_t WriteEntireBuffer(PP_Instance instance, TestCompletionCallback callback(instance, callback_type); int32_t write_offset = offset; const char* buf = data.c_str(); - int32_t size = data.size(); + int32_t size = static_cast<int32_t>(data.size()); while (write_offset < offset + size) { callback.WaitForResult(file_io->Write(write_offset, @@ -781,7 +781,7 @@ std::string TestFileIO::TestParallelReads() { // Parallel read operations. const char* border = "__border__"; - const int32_t border_size = strlen(border); + const int32_t border_size = static_cast<int32_t>(strlen(border)); TestCompletionCallback callback_1(instance_->pp_instance(), callback_type()); int32_t read_offset_1 = 0; @@ -865,12 +865,12 @@ std::string TestFileIO::TestParallelWrites() { TestCompletionCallback callback_1(instance_->pp_instance(), callback_type()); int32_t write_offset_1 = 0; const char* buf_1 = "abc"; - int32_t size_1 = strlen(buf_1); + int32_t size_1 = static_cast<int32_t>(strlen(buf_1)); TestCompletionCallback callback_2(instance_->pp_instance(), callback_type()); int32_t write_offset_2 = size_1; const char* buf_2 = "defghijkl"; - int32_t size_2 = strlen(buf_2); + int32_t size_2 = static_cast<int32_t>(strlen(buf_2)); int32_t rv_1 = PP_OK; int32_t rv_2 = PP_OK; @@ -879,7 +879,8 @@ std::string TestFileIO::TestParallelWrites() { // Copy the buffer so we can erase it below. std::string str_1(buf_1); rv_1 = file_io.Write( - write_offset_1, &str_1[0], str_1.size(), callback_1.GetCallback()); + write_offset_1, &str_1[0], static_cast<int32_t>(str_1.size()), + callback_1.GetCallback()); // Erase the buffer to test that async writes copy it. std::fill(str_1.begin(), str_1.end(), 0); } @@ -887,7 +888,8 @@ std::string TestFileIO::TestParallelWrites() { // Copy the buffer so we can erase it below. std::string str_2(buf_2); rv_2 = file_io.Write( - write_offset_2, &str_2[0], str_2.size(), callback_2.GetCallback()); + write_offset_2, &str_2[0], static_cast<int32_t>(str_2.size()), + callback_2.GetCallback()); // Erase the buffer to test that async writes copy it. std::fill(str_2.begin(), str_2.end(), 0); } @@ -951,7 +953,8 @@ std::string TestFileIO::TestNotAllowMixedReadWrite() { TestCompletionCallback callback_1(instance_->pp_instance(), PP_REQUIRED); int32_t write_offset_1 = 0; const char* buf_1 = "mnopqrstuvw"; - int32_t rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), + int32_t rv_1 = file_io.Write(write_offset_1, buf_1, + static_cast<int32_t>(strlen(buf_1)), callback_1.GetCallback()); ASSERT_EQ(PP_OK_COMPLETIONPENDING, rv_1); @@ -966,7 +969,8 @@ std::string TestFileIO::TestNotAllowMixedReadWrite() { CHECK_CALLBACK_BEHAVIOR(callback_1); // Cannot query while a write is pending. - rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), + rv_1 = file_io.Write(write_offset_1, buf_1, + static_cast<int32_t>(strlen(buf_1)), callback_1.GetCallback()); ASSERT_EQ(PP_OK_COMPLETIONPENDING, rv_1); PP_FileInfo info; @@ -977,7 +981,8 @@ std::string TestFileIO::TestNotAllowMixedReadWrite() { CHECK_CALLBACK_BEHAVIOR(callback_1); // Cannot touch while a write is pending. - rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), + rv_1 = file_io.Write(write_offset_1, buf_1, + static_cast<int32_t>(strlen(buf_1)), callback_1.GetCallback()); ASSERT_EQ(PP_OK_COMPLETIONPENDING, rv_1); callback_2.WaitForResult(file_io.Touch(1234.0, 5678.0, @@ -988,7 +993,8 @@ std::string TestFileIO::TestNotAllowMixedReadWrite() { CHECK_CALLBACK_BEHAVIOR(callback_1); // Cannot set length while a write is pending. - rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), + rv_1 = file_io.Write(write_offset_1, buf_1, + static_cast<int32_t>(strlen(buf_1)), callback_1.GetCallback()); ASSERT_EQ(PP_OK_COMPLETIONPENDING, rv_1); callback_2.WaitForResult(file_io.SetLength(123, callback_2.GetCallback())); @@ -1038,7 +1044,7 @@ std::string TestFileIO::TestRequestOSFileHandle() { // Check write(2) for the native FD. const std::string msg = "foobar"; - ssize_t cnt = write(fd, msg.data(), msg.size()); + ssize_t cnt = write(fd, msg.data(), static_cast<unsigned>(msg.size())); if (cnt < 0) return ReportError("write for native FD returned error", errno); if (cnt != static_cast<ssize_t>(msg.size())) @@ -1059,7 +1065,7 @@ std::string TestFileIO::TestRequestOSFileHandle() { // Check read(2) for the native FD. std::string buf(msg.size(), '\0'); - cnt = read(fd, &buf[0], msg.size()); + cnt = read(fd, &buf[0], static_cast<unsigned>(msg.size())); if (cnt < 0) return ReportError("read for native FD returned error", errno); if (cnt != static_cast<ssize_t>(msg.size())) @@ -1274,8 +1280,8 @@ std::string TestFileIO::TestMmap() { } std::string TestFileIO::MatchOpenExpectations(pp::FileSystem* file_system, - size_t open_flags, - size_t expectations) { + int32_t open_flags, + int32_t expectations) { std::string bad_argument = "TestFileIO::MatchOpenExpectations has invalid input arguments."; bool invalid_combination = !!(expectations & INVALID_FLAG_COMBINATION); diff --git a/ppapi/tests/test_file_io.h b/ppapi/tests/test_file_io.h index 3cc0095..e01abcf 100644 --- a/ppapi/tests/test_file_io.h +++ b/ppapi/tests/test_file_io.h @@ -57,8 +57,8 @@ class TestFileIO : public TestCase { // 2) (DONT_)?CREATE_IF_DOESNT_EXIST | (DONT_)?OPEN_IF_EXISTS | // (DONT_)?TRUNCATE_IF_EXISTS std::string MatchOpenExpectations(pp::FileSystem* file_system, - size_t open_flags, - size_t expectations); + int32_t open_flags, + int32_t expectations); }; #endif // PAPPI_TESTS_TEST_FILE_IO_H_ diff --git a/ppapi/tests/test_file_mapping.cc b/ppapi/tests/test_file_mapping.cc index 4e879b5..ee10e18 100644 --- a/ppapi/tests/test_file_mapping.cc +++ b/ppapi/tests/test_file_mapping.cc @@ -55,7 +55,7 @@ int32_t WriteEntireBuffer(PP_Instance instance, TestCompletionCallback callback(instance, callback_type); int32_t write_offset = offset; const char* buf = data.c_str(); - int32_t size = data.size(); + int32_t size = static_cast<int32_t>(data.size()); while (write_offset < offset + size) { callback.WaitForResult(file_io->Write(write_offset, diff --git a/ppapi/tests/test_flash_clipboard.cc b/ppapi/tests/test_flash_clipboard.cc index 505399d..e94cb7f 100644 --- a/ppapi/tests/test_flash_clipboard.cc +++ b/ppapi/tests/test_flash_clipboard.cc @@ -151,7 +151,7 @@ std::string TestFlashClipboard::TestReadWriteRTF() { "{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\n" "This is some {\\b bold} text.\\par\n" "}"; - pp::VarArrayBuffer array_buffer(rtf_string.size()); + pp::VarArrayBuffer array_buffer(static_cast<uint32_t>(rtf_string.size())); char* bytes = static_cast<char*>(array_buffer.Map()); std::copy(rtf_string.data(), rtf_string.data() + rtf_string.size(), bytes); std::vector<uint32_t> formats_vector(1, PP_FLASH_CLIPBOARD_FORMAT_RTF); @@ -182,7 +182,7 @@ std::string TestFlashClipboard::TestReadWriteRTF() { std::string TestFlashClipboard::TestReadWriteCustomData() { std::string custom_data = "custom_data"; - pp::VarArrayBuffer array_buffer(custom_data.size()); + pp::VarArrayBuffer array_buffer(static_cast<uint32_t>(custom_data.size())); char* bytes = static_cast<char*>(array_buffer.Map()); std::copy(custom_data.begin(), custom_data.end(), bytes); uint32_t format_id = @@ -311,7 +311,7 @@ std::string TestFlashClipboard::TestGetSequenceNumber() { // Test the sequence number changes after writing some custom data. std::string custom_data = "custom_data"; - pp::VarArrayBuffer array_buffer(custom_data.size()); + pp::VarArrayBuffer array_buffer(static_cast<uint32_t>(custom_data.size())); char* bytes = static_cast<char*>(array_buffer.Map()); std::copy(custom_data.begin(), custom_data.end(), bytes); uint32_t format_id = diff --git a/ppapi/tests/test_flash_file.cc b/ppapi/tests/test_flash_file.cc index 8e8db30..b252940 100644 --- a/ppapi/tests/test_flash_file.cc +++ b/ppapi/tests/test_flash_file.cc @@ -36,7 +36,8 @@ void CloseFileHandle(PP_FileHandle file_handle) { bool WriteFile(PP_FileHandle file_handle, const std::string& contents) { #if defined(PPAPI_OS_WIN) DWORD bytes_written = 0; - BOOL result = ::WriteFile(file_handle, contents.c_str(), contents.size(), + BOOL result = ::WriteFile(file_handle, contents.c_str(), + static_cast<DWORD>(contents.size()), &bytes_written, NULL); return result && bytes_written == static_cast<DWORD>(contents.size()); #else diff --git a/ppapi/tests/test_host_resolver.cc b/ppapi/tests/test_host_resolver.cc index 2bb5012..27ecae1 100644 --- a/ppapi/tests/test_host_resolver.cc +++ b/ppapi/tests/test_host_resolver.cc @@ -85,10 +85,12 @@ std::string TestHostResolver::CheckHTTPResponse(pp::TCPSocket* socket, const std::string& response) { int32_t rv = 0; ASSERT_SUBTEST_SUCCESS( - SyncWrite(socket, request.c_str(), request.size(), &rv)); + SyncWrite(socket, request.c_str(), static_cast<int32_t>(request.size()), + &rv)); std::vector<char> response_buffer(response.size()); ASSERT_SUBTEST_SUCCESS( - SyncRead(socket, &response_buffer[0], response.size(), &rv)); + SyncRead(socket, &response_buffer[0], + static_cast<int32_t>(response.size()), &rv)); std::string actual_response(&response_buffer[0], rv); if (response != actual_response) { return "CheckHTTPResponse failed, expected: " + response + @@ -121,7 +123,7 @@ std::string TestHostResolver::ParameterizedTestResolve( pp::NetAddress address; for (size_t i = 0; i < size; ++i) { - address = host_resolver.GetNetAddress(i); + address = host_resolver.GetNetAddress(static_cast<uint32_t>(i)); ASSERT_NE(0, address.pp_resource()); pp::TCPSocket socket(instance_); @@ -132,7 +134,7 @@ std::string TestHostResolver::ParameterizedTestResolve( socket.Close(); } - address = host_resolver.GetNetAddress(size); + address = host_resolver.GetNetAddress(static_cast<uint32_t>(size)); ASSERT_EQ(0, address.pp_resource()); pp::Var canonical_name = host_resolver.GetCanonicalName(); ASSERT_TRUE(canonical_name.is_string()); diff --git a/ppapi/tests/test_host_resolver_private.cc b/ppapi/tests/test_host_resolver_private.cc index 88429ed..e13cb99 100644 --- a/ppapi/tests/test_host_resolver_private.cc +++ b/ppapi/tests/test_host_resolver_private.cc @@ -100,10 +100,12 @@ std::string TestHostResolverPrivate::CheckHTTPResponse( const std::string& response) { int32_t rv = 0; ASSERT_SUBTEST_SUCCESS( - SyncWrite(socket, request.c_str(), request.size(), &rv)); + SyncWrite(socket, request.c_str(), static_cast<int32_t>(request.size()), + &rv)); std::vector<char> response_buffer(response.size()); ASSERT_SUBTEST_SUCCESS( - SyncRead(socket, &response_buffer[0], response.size(), &rv)); + SyncRead(socket, &response_buffer[0], + static_cast<int32_t>(response.size()), &rv)); std::string actual_response(&response_buffer[0], rv); if (response != actual_response) { return "CheckHTTPResponse failed, expected: " + response + @@ -144,7 +146,8 @@ std::string TestHostResolverPrivate::ParametrizedTestResolve( PP_NetAddress_Private address; for (size_t i = 0; i < size; ++i) { - ASSERT_TRUE(host_resolver.GetNetAddress(i, &address)); + ASSERT_TRUE(host_resolver.GetNetAddress( + static_cast<uint32_t>(i), &address)); pp::TCPSocketPrivate socket(instance_); ASSERT_SUBTEST_SUCCESS(SyncConnect(&socket, address)); @@ -154,7 +157,8 @@ std::string TestHostResolverPrivate::ParametrizedTestResolve( socket.Disconnect(); } - ASSERT_FALSE(host_resolver.GetNetAddress(size, &address)); + ASSERT_FALSE(host_resolver.GetNetAddress( + static_cast<uint32_t>(size), &address)); pp::Var canonical_name = host_resolver.GetCanonicalName(); ASSERT_TRUE(canonical_name.is_string()); pp::TCPSocketPrivate socket(instance_); diff --git a/ppapi/tests/test_memory.cc b/ppapi/tests/test_memory.cc index 9073227..d4db7c2 100644 --- a/ppapi/tests/test_memory.cc +++ b/ppapi/tests/test_memory.cc @@ -30,7 +30,7 @@ void TestMemory::RunTests(const std::string& filter) { std::string TestMemory::TestMemAlloc() { char* buffer = static_cast<char*>( - memory_dev_interface_->MemAlloc(kTestBufferSize)); + memory_dev_interface_->MemAlloc(static_cast<uint32_t>(kTestBufferSize))); // Touch a couple of locations. Failure will crash the test. buffer[0] = '1'; buffer[kTestBufferSize - 1] = '1'; diff --git a/ppapi/tests/test_network_monitor.cc b/ppapi/tests/test_network_monitor.cc index 2d46f90..dcb712c 100644 --- a/ppapi/tests/test_network_monitor.cc +++ b/ppapi/tests/test_network_monitor.cc @@ -64,7 +64,7 @@ std::string TestNetworkMonitor::VerifyNetworkList( for (size_t iface = 0; iface < count; ++iface) { // Verify that the first interface has at least one address. std::vector<pp::NetAddress> addresses; - network_list.GetIpAddresses(iface, &addresses); + network_list.GetIpAddresses(static_cast<uint32_t>(iface), &addresses); ASSERT_TRUE(addresses.size() >= 1U); // Verify that the addresses are valid. for (size_t i = 0; i < addresses.size(); ++i) { @@ -115,14 +115,17 @@ std::string TestNetworkMonitor::VerifyNetworkList( } // Verify that each interface has a unique name and a display name. - ASSERT_FALSE(network_list.GetName(iface).empty()); - ASSERT_FALSE(network_list.GetDisplayName(iface).empty()); + ASSERT_FALSE(network_list.GetName(static_cast<uint32_t>(iface)).empty()); + ASSERT_FALSE(network_list.GetDisplayName( + static_cast<uint32_t>(iface)).empty()); - PP_NetworkList_Type type = network_list.GetType(iface); + PP_NetworkList_Type type = + network_list.GetType(static_cast<uint32_t>(iface)); ASSERT_TRUE(type >= PP_NETWORKLIST_TYPE_UNKNOWN); ASSERT_TRUE(type <= PP_NETWORKLIST_TYPE_CELLULAR); - PP_NetworkList_State state = network_list.GetState(iface); + PP_NetworkList_State state = + network_list.GetState(static_cast<uint32_t>(iface)); ASSERT_TRUE(state >= PP_NETWORKLIST_STATE_DOWN); ASSERT_TRUE(state <= PP_NETWORKLIST_STATE_UP); } diff --git a/ppapi/tests/test_post_message.cc b/ppapi/tests/test_post_message.cc index 8e7be05..da560cf 100644 --- a/ppapi/tests/test_post_message.cc +++ b/ppapi/tests/test_post_message.cc @@ -294,7 +294,7 @@ int TestPostMessage::WaitForMessages() { // Now that the FINISHED_WAITING_MESSAGE has been echoed back to us, we know // that all pending messages have been slurped up. Return the number we // received (which may be zero). - return message_data_.size() - message_size_before; + return static_cast<int>(message_data_.size() - message_size_before); } std::string TestPostMessage::CheckMessageProperties( @@ -594,7 +594,7 @@ std::string TestPostMessage::TestSendingResource() { std::string file_path("/"); file_path += kTestFilename; - int content_length = strlen(kTestString); + int content_length = static_cast<int>(strlen(kTestString)); // Create a file in the HTML5 temporary file system, in the Pepper plugin. TestCompletionCallback callback(instance_->pp_instance(), callback_type()); diff --git a/ppapi/tests/test_tcp_server_socket_private.cc b/ppapi/tests/test_tcp_server_socket_private.cc index 2465d51..64b5402 100644 --- a/ppapi/tests/test_tcp_server_socket_private.cc +++ b/ppapi/tests/test_tcp_server_socket_private.cc @@ -77,7 +77,8 @@ std::string TestTCPServerSocketPrivate::SyncRead(TCPSocketPrivate* socket, while (num_bytes > 0) { TestCompletionCallback callback(instance_->pp_instance(), callback_type()); callback.WaitForResult( - socket->Read(buffer, num_bytes, callback.GetCallback())); + socket->Read(buffer, static_cast<int32_t>(num_bytes), + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_TRUE(callback.result() >= 0); buffer += callback.result(); @@ -92,7 +93,8 @@ std::string TestTCPServerSocketPrivate::SyncWrite(TCPSocketPrivate* socket, while (num_bytes > 0) { TestCompletionCallback callback(instance_->pp_instance(), callback_type()); callback.WaitForResult( - socket->Write(buffer, num_bytes, callback.GetCallback())); + socket->Write(buffer, static_cast<int32_t>(num_bytes), + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_TRUE(callback.result() >= 0); buffer += callback.result(); @@ -236,7 +238,7 @@ std::string TestTCPServerSocketPrivate::TestBacklog() { } for (size_t i = 0; i < kBacklog; ++i) { - const char byte = 'a' + i; + const char byte = static_cast<char>('a' + i); ASSERT_SUBTEST_SUCCESS(SyncWrite(client_sockets[i], &byte, sizeof(byte))); } diff --git a/ppapi/tests/test_tcp_socket.cc b/ppapi/tests/test_tcp_socket.cc index a3164de..877b469 100644 --- a/ppapi/tests/test_tcp_socket.cc +++ b/ppapi/tests/test_tcp_socket.cc @@ -285,7 +285,7 @@ std::string TestTCPSocket::TestBacklog() { } for (size_t i = 0; i < kBacklog; ++i) { - const char byte = 'a' + i; + const char byte = static_cast<char>('a' + i); ASSERT_SUBTEST_SUCCESS(WriteToSocket(client_sockets[i], std::string(1, byte))); } @@ -384,7 +384,8 @@ std::string TestTCPSocket::ReadFromSocket(pp::TCPSocket* socket, while (num_bytes > 0) { TestCompletionCallback callback(instance_->pp_instance(), callback_type()); callback.WaitForResult( - socket->Read(buffer, num_bytes, callback.GetCallback())); + socket->Read(buffer, static_cast<int32_t>(num_bytes), + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_GT(callback.result(), 0); buffer += callback.result(); @@ -401,7 +402,9 @@ std::string TestTCPSocket::WriteToSocket(pp::TCPSocket* socket, while (written < s.size()) { TestCompletionCallback cb(instance_->pp_instance(), callback_type()); cb.WaitForResult( - socket->Write(buffer + written, s.size() - written, cb.GetCallback())); + socket->Write(buffer + written, + static_cast<int32_t>(s.size() - written), + cb.GetCallback())); CHECK_CALLBACK_BEHAVIOR(cb); ASSERT_GT(cb.result(), 0); written += cb.result(); @@ -418,7 +421,8 @@ std::string TestTCPSocket::WriteToSocket_1_0( while (written < s.size()) { TestCompletionCallback cb(instance_->pp_instance(), callback_type()); cb.WaitForResult(socket_interface_1_0_->Write( - socket, buffer + written, s.size() - written, + socket, buffer + written, + static_cast<int32_t>(s.size() - written), cb.GetCallback().pp_completion_callback())); CHECK_CALLBACK_BEHAVIOR(cb); ASSERT_GT(cb.result(), 0); diff --git a/ppapi/tests/test_tcp_socket_private.cc b/ppapi/tests/test_tcp_socket_private.cc index d3efbe3..0d43a76 100644 --- a/ppapi/tests/test_tcp_socket_private.cc +++ b/ppapi/tests/test_tcp_socket_private.cc @@ -246,7 +246,8 @@ int32_t TestTCPSocketPrivate::WriteStringToSocket(pp::TCPSocketPrivate* socket, size_t written = 0; while (written < s.size()) { TestCompletionCallback cb(instance_->pp_instance(), callback_type()); - int32_t rv = socket->Write(buffer + written, s.size() - written, + int32_t rv = socket->Write(buffer + written, + static_cast<int32_t>(s.size() - written), cb.GetCallback()); if (callback_type() == PP_REQUIRED && rv != PP_OK_COMPLETIONPENDING) return PP_ERROR_FAILED; diff --git a/ppapi/tests/test_udp_socket.cc b/ppapi/tests/test_udp_socket.cc index 2b05682..89ea036 100644 --- a/ppapi/tests/test_udp_socket.cc +++ b/ppapi/tests/test_udp_socket.cc @@ -156,7 +156,8 @@ std::string TestUDPSocket::ReadSocket(pp::UDPSocket* socket, TestCompletionCallbackWithOutput<pp::NetAddress> callback( instance_->pp_instance(), callback_type()); callback.WaitForResult( - socket->RecvFrom(&buffer[0], size, callback.GetCallback())); + socket->RecvFrom(&buffer[0], static_cast<int32_t>(size), + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_FALSE(callback.result() < 0); ASSERT_EQ(size, static_cast<size_t>(callback.result())); @@ -171,7 +172,8 @@ std::string TestUDPSocket::PassMessage(pp::UDPSocket* target, const std::string& message, pp::NetAddress* recvfrom_address) { TestCompletionCallback callback(instance_->pp_instance(), callback_type()); - int32_t rv = source->SendTo(message.c_str(), message.size(), + int32_t rv = source->SendTo(message.c_str(), + static_cast<int32_t>(message.size()), target_address, callback.GetCallback()); std::string str; @@ -341,7 +343,7 @@ std::string TestUDPSocket::TestParallelSend() { new TestCompletionCallback(instance_->pp_instance(), callback_type()); sendto_results[i] = client_socket.SendTo(message.c_str(), - message.size(), + static_cast<int32_t>(message.size()), server_address, sendto_callbacks[i]->GetCallback()); @@ -356,7 +358,7 @@ std::string TestUDPSocket::TestParallelSend() { // Try to send the message again. sendto_results[i] = client_socket.SendTo(message.c_str(), - message.size(), + static_cast<int32_t>(message.size()), server_address, sendto_callbacks[i]->GetCallback()); ASSERT_NE(PP_ERROR_INPROGRESS, sendto_results[i]); diff --git a/ppapi/tests/test_udp_socket_private.cc b/ppapi/tests/test_udp_socket_private.cc index ae1b978..74dd8ba 100644 --- a/ppapi/tests/test_udp_socket_private.cc +++ b/ppapi/tests/test_udp_socket_private.cc @@ -138,7 +138,8 @@ std::string TestUDPSocketPrivate::ReadSocket(pp::UDPSocketPrivate* socket, std::vector<char> buffer(size); TestCompletionCallback callback(instance_->pp_instance(), callback_type()); callback.WaitForResult( - socket->RecvFrom(&buffer[0], size, callback.GetCallback())); + socket->RecvFrom(&buffer[0], static_cast<int32_t>(size), + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_FALSE(callback.result() < 0); ASSERT_EQ(size, static_cast<size_t>(callback.result())); @@ -151,7 +152,8 @@ std::string TestUDPSocketPrivate::PassMessage(pp::UDPSocketPrivate* target, PP_NetAddress_Private* address, const std::string& message) { TestCompletionCallback callback(instance_->pp_instance(), callback_type()); - int32_t rv = source->SendTo(message.c_str(), message.size(), address, + int32_t rv = source->SendTo(message.c_str(), + static_cast<int32_t>(message.size()), address, callback.GetCallback()); std::string str; ASSERT_SUBTEST_SUCCESS(ReadSocket(target, address, message.size(), &str)); diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc index 0d78efa..d3a210e 100644 --- a/ppapi/tests/test_url_loader.cc +++ b/ppapi/tests/test_url_loader.cc @@ -37,7 +37,7 @@ int32_t WriteEntireBuffer(PP_Instance instance, TestCompletionCallback callback(instance, callback_type); int32_t write_offset = offset; const char* buf = data.c_str(); - int32_t size = data.size(); + int32_t size = static_cast<int32_t>(data.size()); while (write_offset < offset + size) { callback.WaitForResult(file_io->Write(write_offset, @@ -343,7 +343,8 @@ std::string TestURLLoader::TestBasicPOST() { request.SetURL("/echo"); request.SetMethod("POST"); std::string postdata("postdata"); - request.AppendDataToBody(postdata.data(), postdata.length()); + request.AppendDataToBody(postdata.data(), + static_cast<uint32_t>(postdata.length())); return LoadAndCompareBody(request, postdata); } @@ -394,9 +395,11 @@ std::string TestURLLoader::TestCompoundBodyPOST() { request.SetURL("/echo"); request.SetMethod("POST"); std::string postdata1("post"); - request.AppendDataToBody(postdata1.data(), postdata1.length()); + request.AppendDataToBody(postdata1.data(), + static_cast<uint32_t>(postdata1.length())); std::string postdata2("data"); - request.AppendDataToBody(postdata2.data(), postdata2.length()); + request.AppendDataToBody(postdata2.data(), + static_cast<uint32_t>(postdata2.length())); return LoadAndCompareBody(request, postdata1 + postdata2); } @@ -416,7 +419,8 @@ std::string TestURLLoader::TestBinaryDataPOST() { "\x00\x01\x02\x03\x04\x05postdata\xfa\xfb\xfc\xfd\xfe\xff"; std::string postdata(postdata_chars, sizeof(postdata_chars) / sizeof(postdata_chars[0])); - request.AppendDataToBody(postdata.data(), postdata.length()); + request.AppendDataToBody(postdata.data(), + static_cast<uint32_t>(postdata.length())); return LoadAndCompareBody(request, postdata); } @@ -433,7 +437,8 @@ std::string TestURLLoader::TestFailsBogusContentLength() { request.SetMethod("POST"); request.SetHeaders("Content-Length: 400"); std::string postdata("postdata"); - request.AppendDataToBody(postdata.data(), postdata.length()); + request.AppendDataToBody(postdata.data(), + static_cast<uint32_t>(postdata.length())); int32_t rv; rv = OpenUntrusted(request); diff --git a/ppapi/tests/test_url_request.cc b/ppapi/tests/test_url_request.cc index 22b0629..7c9847b 100644 --- a/ppapi/tests/test_url_request.cc +++ b/ppapi/tests/test_url_request.cc @@ -77,7 +77,7 @@ void TestURLRequest::RunTests(const std::string& filter) { } PP_Var TestURLRequest::PP_MakeString(const char* s) { - return ppb_var_interface_->VarFromUtf8(s, strlen(s)); + return ppb_var_interface_->VarFromUtf8(s, static_cast<int32_t>(strlen(s))); } // Tests @@ -357,7 +357,8 @@ std::string TestURLRequest::TestAppendDataToBody() { // Invalid resource should fail. ASSERT_EQ(PP_FALSE, ppb_url_request_interface_->AppendDataToBody( - kInvalidResource, postdata.data(), postdata.length())); + kInvalidResource, postdata.data(), + static_cast<uint32_t>(postdata.length()))); // Append data and POST to echoing web server. ASSERT_EQ(PP_TRUE, ppb_url_request_interface_->SetProperty( @@ -367,7 +368,8 @@ std::string TestURLRequest::TestAppendDataToBody() { // Append data to body and verify the body is what we expect. ASSERT_EQ(PP_TRUE, ppb_url_request_interface_->AppendDataToBody( - url_request, postdata.data(), postdata.length())); + url_request, postdata.data(), + static_cast<uint32_t>(postdata.length()))); std::string error = LoadAndCompareBody(url_request, postdata); ppb_var_interface_->Release(post_string_var); @@ -399,7 +401,7 @@ std::string TestURLRequest::TestAppendFileToBody() { std::string append_data = "hello\n"; callback.WaitForResult(io.Write(0, append_data.c_str(), - append_data.size(), + static_cast<int32_t>(append_data.size()), callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(static_cast<int32_t>(append_data.size()), callback.result()); diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc index e0a54aa..91046f2 100644 --- a/ppapi/tests/test_websocket.cc +++ b/ppapi/tests/test_websocket.cc @@ -259,11 +259,13 @@ std::string TestWebSocket::GetFullURL(const char* url) { } PP_Var TestWebSocket::CreateVarString(const std::string& string) { - return var_interface_->VarFromUtf8(string.c_str(), string.size()); + return var_interface_->VarFromUtf8(string.c_str(), + static_cast<uint32_t>(string.size())); } PP_Var TestWebSocket::CreateVarBinary(const std::vector<uint8_t>& binary) { - PP_Var var = arraybuffer_interface_->Create(binary.size()); + PP_Var var = + arraybuffer_interface_->Create(static_cast<uint32_t>(binary.size())); uint8_t* var_data = static_cast<uint8_t*>(arraybuffer_interface_->Map(var)); std::copy(binary.begin(), binary.end(), var_data); return var; |