diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-08 13:13:08 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-21 12:06:23 +0000 |
commit | a37ea01163f8b96b251cbc7a6a9d2809b2f2a6ae (patch) | |
tree | 6ea4c4576840365703cac354451f08024e72f4aa | |
parent | dd48ed42ae55a3360ae81fd088e5cd79dfc953b0 (diff) |
Fix misuse of {} initialization
Narrowing is supposed to be forbidden in {} initialization, but Chromium
doesn't appear to care upstream.
Change-Id: Ia3d1dac6ef19ef86afcbeee4ed11d807c53faaaa
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
23 files changed, 38 insertions, 36 deletions
diff --git a/chromium/base/task/sequence_manager/task_queue_selector.h b/chromium/base/task/sequence_manager/task_queue_selector.h index f76422d837a..6d8a24d7685 100644 --- a/chromium/base/task/sequence_manager/task_queue_selector.h +++ b/chromium/base/task/sequence_manager/task_queue_selector.h @@ -192,13 +192,13 @@ class BASE_EXPORT TaskQueueSelector : public WorkQueueSets::Observer { 0, // kHighPriority - kMaxHighPriorityStarvationScore, + int64_t(kMaxHighPriorityStarvationScore), // kNormalPriority - kMaxNormalPriorityStarvationScore, + int64_t(kMaxNormalPriorityStarvationScore), // kLowPriority - kMaxLowPriorityStarvationScore, + int64_t(kMaxLowPriorityStarvationScore), // kBestEffortPriority (unused) std::numeric_limits<int64_t>::max()}; diff --git a/chromium/cc/paint/paint_op_buffer.h b/chromium/cc/paint/paint_op_buffer.h index 028a476ce87..40d39e7a9e9 100644 --- a/chromium/cc/paint/paint_op_buffer.h +++ b/chromium/cc/paint/paint_op_buffer.h @@ -968,7 +968,7 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt { uint16_t skip = static_cast<uint16_t>(ComputeOpSkip(sizeof(T))); T* op = reinterpret_cast<T*>(AllocatePaintOp(skip)); - new (op) T{std::forward<Args>(args)...}; + new (op) T(std::forward<Args>(args)...); DCHECK_EQ(op->type, static_cast<uint32_t>(T::kType)); op->skip = skip; AnalyzeAddedOp(op); diff --git a/chromium/components/crx_file/crx_creator.cc b/chromium/components/crx_file/crx_creator.cc index 8ec6bb3691e..c37b680071f 100644 --- a/chromium/components/crx_file/crx_creator.cc +++ b/chromium/components/crx_file/crx_creator.cc @@ -74,8 +74,8 @@ CreatorResult Create(const base::FilePath& output_path, signed_header_data.SerializeAsString(); const int signed_header_size = signed_header_data_str.size(); const uint8_t signed_header_size_octets[] = { - signed_header_size, signed_header_size >> 8, signed_header_size >> 16, - signed_header_size >> 24}; + uint8_t(signed_header_size), uint8_t(signed_header_size >> 8), + uint8_t(signed_header_size >> 16), uint8_t(signed_header_size >> 24)}; // Create a signer, init with purpose, SignedData length, run SignedData // through, run ZIP through. @@ -104,8 +104,9 @@ CreatorResult Create(const base::FilePath& output_path, header.set_signed_header_data(signed_header_data_str); const std::string header_str = header.SerializeAsString(); const int header_size = header_str.size(); - const uint8_t header_size_octets[] = {header_size, header_size >> 8, - header_size >> 16, header_size >> 24}; + const uint8_t header_size_octets[] = { + uint8_t(header_size), uint8_t(header_size >> 8), + uint8_t(header_size >> 16), uint8_t(header_size >> 24)}; // Write CRX. const uint8_t format_version_octets[] = {3, 0, 0, 0}; diff --git a/chromium/components/crx_file/crx_verifier.cc b/chromium/components/crx_file/crx_verifier.cc index 7aef7810c50..8db27dcf6a6 100644 --- a/chromium/components/crx_file/crx_verifier.cc +++ b/chromium/components/crx_file/crx_verifier.cc @@ -124,8 +124,8 @@ VerifierResult VerifyCrx3( // Create a little-endian representation of [signed-header-size]. const int signed_header_size = signed_header_data_str.size(); const uint8_t header_size_octets[] = { - signed_header_size, signed_header_size >> 8, signed_header_size >> 16, - signed_header_size >> 24}; + uint8_t(signed_header_size), uint8_t(signed_header_size >> 8), + uint8_t(signed_header_size >> 16), uint8_t(signed_header_size >> 24)}; // Create a set of all required key hashes. std::set<std::vector<uint8_t>> required_key_set(required_key_hashes.begin(), diff --git a/chromium/components/viz/common/gl_scaler.cc b/chromium/components/viz/common/gl_scaler.cc index 417b83d412b..e6aae560b39 100644 --- a/chromium/components/viz/common/gl_scaler.cc +++ b/chromium/components/viz/common/gl_scaler.cc @@ -1420,8 +1420,8 @@ void GLScaler::ScalerStage::ScaleToMultipleOutputs( gfx::RectF GLScaler::ScalerStage::ToSourceRect( const gfx::Rect& output_rect) const { return gfx::ScaleRect(gfx::RectF(output_rect), - float{scale_from_.x()} / scale_to_.x(), - float{scale_from_.y()} / scale_to_.y()); + float(scale_from_.x()) / scale_to_.x(), + float(scale_from_.y()) / scale_to_.y()); } gfx::Rect GLScaler::ScalerStage::ToInputRect(gfx::RectF source_rect) const { diff --git a/chromium/content/renderer/media/stream/media_stream_constraints_util.cc b/chromium/content/renderer/media/stream/media_stream_constraints_util.cc index 5d48859668f..d5c2d4af884 100644 --- a/chromium/content/renderer/media/stream/media_stream_constraints_util.cc +++ b/chromium/content/renderer/media/stream/media_stream_constraints_util.cc @@ -344,8 +344,8 @@ blink::WebMediaStreamSource::Capabilities ComputeCapabilitiesForVideoSource( max_height = std::max(max_height, format.frame_size.height()); max_frame_rate = std::max(max_frame_rate, format.frame_rate); } - capabilities.width = {1, max_width}; - capabilities.height = {1, max_height}; + capabilities.width = {1U, uint32_t(max_width)}; + capabilities.height = {1U, uint32_t(max_height)}; capabilities.aspect_ratio = {1.0 / max_height, static_cast<double>(max_width)}; capabilities.frame_rate = {min_frame_rate, max_frame_rate}; diff --git a/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc b/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc index d876857f133..f207d217517 100644 --- a/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -2010,7 +2010,7 @@ void PepperPluginInstanceImpl::PrintPage(int page_number, metafile_ = metafile; } - PP_PrintPageNumberRange_Dev page_range = {page_number, page_number}; + PP_PrintPageNumberRange_Dev page_range = {uint32_t(page_number), uint32_t(page_number)}; ranges_.push_back(page_range); #endif } diff --git a/chromium/device/fido/public_key_credential_params.cc b/chromium/device/fido/public_key_credential_params.cc index d5070898820..c4d334de33c 100644 --- a/chromium/device/fido/public_key_credential_params.cc +++ b/chromium/device/fido/public_key_credential_params.cc @@ -34,7 +34,8 @@ PublicKeyCredentialParams::CreateFromCBORValue(const cbor::Value& cbor_value) { } credential_params.push_back(PublicKeyCredentialParams::CredentialInfo{ - CredentialType::kPublicKey, algorithm_type_it->second.GetInteger()}); + CredentialType::kPublicKey, + static_cast<int>(algorithm_type_it->second.GetInteger())}); } return PublicKeyCredentialParams(std::move(credential_params)); diff --git a/chromium/device/gamepad/gamepad_device_linux.cc b/chromium/device/gamepad/gamepad_device_linux.cc index 49896059eb5..6ce341538a1 100644 --- a/chromium/device/gamepad/gamepad_device_linux.cc +++ b/chromium/device/gamepad/gamepad_device_linux.cc @@ -326,7 +326,7 @@ bool GamepadDeviceLinux::ReadEvdevSpecialKeys(Gamepad* pad) { ssize_t bytes_read; while ((bytes_read = HANDLE_EINTR(read(evdev_fd_, &ev, sizeof(input_event)))) > 0) { - if (size_t{bytes_read} < sizeof(input_event)) + if (size_t(bytes_read) < sizeof(input_event)) break; if (ev.type != EV_KEY) continue; diff --git a/chromium/device/gamepad/gamepad_uma.cc b/chromium/device/gamepad/gamepad_uma.cc index 5faccb5e1f6..1b0ba541da7 100644 --- a/chromium/device/gamepad/gamepad_uma.cc +++ b/chromium/device/gamepad/gamepad_uma.cc @@ -21,7 +21,7 @@ void RecordConnectedGamepad(uint16_t vendor_id, uint16_t product_id) { auto gamepad_id_as_underlying_type = static_cast<std::underlying_type<GamepadId>::type>(gamepad_id); base::UmaHistogramSparse("Gamepad.KnownGamepadConnectedWithId", - int32_t{gamepad_id_as_underlying_type}); + int32_t(gamepad_id_as_underlying_type)); } void RecordUnknownGamepad(GamepadSource source) { diff --git a/chromium/device/gamepad/raw_input_gamepad_device_win.cc b/chromium/device/gamepad/raw_input_gamepad_device_win.cc index 3af6923feed..c9260bcae78 100644 --- a/chromium/device/gamepad/raw_input_gamepad_device_win.cc +++ b/chromium/device/gamepad/raw_input_gamepad_device_win.cc @@ -140,7 +140,7 @@ void RawInputGamepadDeviceWin::UpdateGamepad(RAWINPUT* input) { uint16_t usage_page = usages[j].UsagePage; uint16_t usage = usages[j].Usage; if (usage_page == kButtonUsagePage && usage > 0) { - size_t button_index = size_t{usage - 1}; + size_t button_index = size_t(usage - 1); if (button_index < Gamepad::kButtonsLengthCap) buttons_[button_index] = true; } else if (usage_page != kButtonUsagePage && @@ -415,8 +415,8 @@ void RawInputGamepadDeviceWin::QueryNormalButtonCapabilities( uint16_t usage_max = button_caps[i].Range.UsageMax; if (usage_min == 0 || usage_max == 0) continue; - size_t button_index_min = size_t{usage_min - 1}; - size_t button_index_max = size_t{usage_max - 1}; + size_t button_index_min = size_t(usage_min - 1); + size_t button_index_max = size_t(usage_max - 1); if (usage_page == kButtonUsagePage && button_index_min < Gamepad::kButtonsLengthCap) { button_index_max = diff --git a/chromium/extensions/browser/blob_reader.cc b/chromium/extensions/browser/blob_reader.cc index f4f4156b1dd..07c9e9e2c98 100644 --- a/chromium/extensions/browser/blob_reader.cc +++ b/chromium/extensions/browser/blob_reader.cc @@ -32,7 +32,7 @@ void BlobReader::SetByteRange(int64_t offset, int64_t length) { CHECK_GT(length, 0); CHECK_LE(offset, std::numeric_limits<int64_t>::max() - length); - read_range_ = Range{offset, length}; + read_range_ = Range{uint64_t(offset), uint64_t(length)}; } void BlobReader::Start() { diff --git a/chromium/gpu/command_buffer/service/gles2_cmd_decoder.cc b/chromium/gpu/command_buffer/service/gles2_cmd_decoder.cc index b37c234a22b..1a7df470855 100644 --- a/chromium/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/chromium/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -14473,7 +14473,7 @@ error::Error GLES2DecoderImpl::HandleTexImage2D(uint32_t immediate_data_size, texture_state_.tex_image_failed = true; GLenum target = static_cast<GLenum>(c.target); GLint level = static_cast<GLint>(c.level); - GLint internal_format = static_cast<GLint>(c.internalformat); + GLenum internal_format = static_cast<GLenum>(c.internalformat); GLsizei width = static_cast<GLsizei>(c.width); GLsizei height = static_cast<GLsizei>(c.height); GLint border = static_cast<GLint>(c.border); @@ -14570,7 +14570,7 @@ error::Error GLES2DecoderImpl::HandleTexImage3D(uint32_t immediate_data_size, texture_state_.tex_image_failed = true; GLenum target = static_cast<GLenum>(c.target); GLint level = static_cast<GLint>(c.level); - GLint internal_format = static_cast<GLint>(c.internalformat); + GLenum internal_format = static_cast<GLenum>(c.internalformat); GLsizei width = static_cast<GLsizei>(c.width); GLsizei height = static_cast<GLsizei>(c.height); GLsizei depth = static_cast<GLsizei>(c.depth); diff --git a/chromium/third_party/blink/renderer/modules/animationworklet/worklet_animation.cc b/chromium/third_party/blink/renderer/modules/animationworklet/worklet_animation.cc index 966439c6dda..b447efeac8d 100644 --- a/chromium/third_party/blink/renderer/modules/animationworklet/worklet_animation.cc +++ b/chromium/third_party/blink/renderer/modules/animationworklet/worklet_animation.cc @@ -601,7 +601,7 @@ void WorkletAnimation::UpdateInputState( input_state->Add( {id_, std::string(animator_name_.Ascii().data(), animator_name_.length()), - current_time_ms, CloneOptions(), effects_.size()}); + current_time_ms, CloneOptions(), int(effects_.size())}); } else if (was_active && is_active) { // Skip if the input time is not changed. if (did_time_change) diff --git a/chromium/third_party/blink/renderer/modules/encoding/text_encoder_stream.cc b/chromium/third_party/blink/renderer/modules/encoding/text_encoder_stream.cc index 5d827fc2781..f829f171517 100644 --- a/chromium/third_party/blink/renderer/modules/encoding/text_encoder_stream.cc +++ b/chromium/third_party/blink/renderer/modules/encoding/text_encoder_stream.cc @@ -94,7 +94,7 @@ class TextEncoderStream::Transformer final : public TransformStreamTransformer { private: static CString ReplacementCharacterInUtf8() { - constexpr char kRawBytes[] = {0xEF, 0xBF, 0xBD}; + constexpr char kRawBytes[] = {(char)0xEF, (char)0xBF, (char)0xBD}; return CString(kRawBytes, sizeof(kRawBytes)); } diff --git a/chromium/third_party/blink/renderer/modules/mediastream/input_device_info.cc b/chromium/third_party/blink/renderer/modules/mediastream/input_device_info.cc index a746278a953..b0e830b4f40 100644 --- a/chromium/third_party/blink/renderer/modules/mediastream/input_device_info.cc +++ b/chromium/third_party/blink/renderer/modules/mediastream/input_device_info.cc @@ -67,8 +67,8 @@ void InputDeviceInfo::SetVideoInputCapabilities( max_height = std::max(max_height, format->frame_size.height); max_frame_rate = std::max(max_frame_rate, format->frame_rate); } - platform_capabilities_.width = {1, max_width}; - platform_capabilities_.height = {1, max_height}; + platform_capabilities_.width = {1U, uint32_t(max_width)}; + platform_capabilities_.height = {1U, uint32_t(max_height)}; platform_capabilities_.aspect_ratio = {1.0 / max_height, static_cast<double>(max_width)}; platform_capabilities_.frame_rate = {min_frame_rate, max_frame_rate}; diff --git a/chromium/third_party/blink/renderer/platform/fonts/shaping/shape_result_view.cc b/chromium/third_party/blink/renderer/platform/fonts/shaping/shape_result_view.cc index fad054902a6..cd260f2ee24 100644 --- a/chromium/third_party/blink/renderer/platform/fonts/shaping/shape_result_view.cc +++ b/chromium/third_party/blink/renderer/platform/fonts/shaping/shape_result_view.cc @@ -308,7 +308,7 @@ void ShapeResultView::GetRunFontData( Vector<ShapeResult::RunFontData>* font_data) const { for (const auto& part : parts_) { font_data->push_back(ShapeResult::RunFontData( - {part->run_->font_data_.get(), part->end() - part->begin()})); + {part->run_->font_data_.get(), WTF::wtf_size_t(part->end() - part->begin())})); } } diff --git a/chromium/third_party/ced/src/compact_enc_det/compact_enc_det.cc b/chromium/third_party/ced/src/compact_enc_det/compact_enc_det.cc index 61d5ee47bee..eb3fffdb08e 100644 --- a/chromium/third_party/ced/src/compact_enc_det/compact_enc_det.cc +++ b/chromium/third_party/ced/src/compact_enc_det/compact_enc_det.cc @@ -1482,7 +1482,7 @@ void InitDetectEncodingState(DetectEncodingState* destatep) { // {{0x6e,0x6c,0x5f,0x5f, 0x05,0xb2,0xae,0xa0,0x32,0xa1,0x36,0x31,0x42,0x39,0x3b,0x33,0x45,0x11,0x6f,0x00,}}, // "nl__" // // ASCII-7-bit=178 Latin1=174 UTF8=160 GB=50 CP1252=161 BIG5=49 Latin2=66 CP1251=57 CP1256=59 CP1250=51 Latin5=69 ISO-8859-15=111 [top ASCII-7-bit] -int ApplyCompressedProb(const char* iprob, int len, +int ApplyCompressedProb(const unsigned char* iprob, int len, int weight, DetectEncodingState* destatep) { int* dst = &destatep->enc_prob[0]; int* dst2 = &destatep->hint_weight[0]; @@ -1531,7 +1531,7 @@ int ApplyCompressedProb(const char* iprob, int len, // Returns subscript of largest (most probable) value [for unit test] -int TopCompressedProb(const char* iprob, int len) { +int TopCompressedProb(const unsigned char* iprob, int len) { const uint8* prob = reinterpret_cast<const uint8*>(iprob); const uint8* problimit = prob + len; int next_prob_sub = 0; diff --git a/chromium/third_party/ced/src/compact_enc_det/compact_enc_det_generated_tables.h b/chromium/third_party/ced/src/compact_enc_det/compact_enc_det_generated_tables.h index 317afb66f48..471a20c6d17 100644 --- a/chromium/third_party/ced/src/compact_enc_det/compact_enc_det_generated_tables.h +++ b/chromium/third_party/ced/src/compact_enc_det/compact_enc_det_generated_tables.h @@ -165,7 +165,7 @@ static const Encoding kMapToEncoding[NUM_RANKEDENCODING] = { // Massaged TLD or charset, followed by packed encoding probs typedef struct { - char key_prob[20]; + unsigned char key_prob[20]; } HintEntry; static const HintEntry kLangHintProbs[] = { // MaxRange 192 diff --git a/chromium/ui/display/win/screen_win.cc b/chromium/ui/display/win/screen_win.cc index 755e64edf27..0ef6168ceca 100644 --- a/chromium/ui/display/win/screen_win.cc +++ b/chromium/ui/display/win/screen_win.cc @@ -63,7 +63,7 @@ int GetPerMonitorDPI(HMONITOR monitor) { } DCHECK_EQ(dpi_x, dpi_y); - return int{dpi_x}; + return int(dpi_x); } // Gets the raw monitor scale factor. diff --git a/chromium/ui/display/win/uwp_text_scale_factor.cc b/chromium/ui/display/win/uwp_text_scale_factor.cc index 6b661bdbed8..d3acaded0a8 100644 --- a/chromium/ui/display/win/uwp_text_scale_factor.cc +++ b/chromium/ui/display/win/uwp_text_scale_factor.cc @@ -162,7 +162,7 @@ class UwpTextScaleFactorImpl : public UwpTextScaleFactor { // equal to 1. Let's make sure that's the case - if we don't, we could get // bizarre behavior and divide-by-zeros later on. DCHECK_GE(result, 1.0); - return float{result}; + return float(result); } private: diff --git a/chromium/ui/gfx/color_utils.cc b/chromium/ui/gfx/color_utils.cc index c868cd54bac..16cf83b63f3 100644 --- a/chromium/ui/gfx/color_utils.cc +++ b/chromium/ui/gfx/color_utils.cc @@ -295,7 +295,7 @@ SkColor AlphaBlend(SkColor foreground, SkColor background, float alpha) { SkColor GetResultingPaintColor(SkColor foreground, SkColor background) { return AlphaBlend(SkColorSetA(foreground, SK_AlphaOPAQUE), background, - SkAlpha{SkColorGetA(foreground)}); + SkAlpha(SkColorGetA(foreground))); } bool IsDark(SkColor color) { diff --git a/chromium/ui/gfx/platform_font_win.cc b/chromium/ui/gfx/platform_font_win.cc index a904ec3a219..4f5f82bedd0 100644 --- a/chromium/ui/gfx/platform_font_win.cc +++ b/chromium/ui/gfx/platform_font_win.cc @@ -739,7 +739,7 @@ void PlatformFontWin::AdjustLOGFONT( LOGFONT* logfont) { DCHECK_GT(font_adjustment.font_scale, 0.0); LONG new_height = - LONG{std::round(logfont->lfHeight * font_adjustment.font_scale)}; + LONG(std::round(logfont->lfHeight * font_adjustment.font_scale)); if (logfont->lfHeight && !new_height) new_height = logfont->lfHeight > 0 ? 1 : -1; logfont->lfHeight = new_height; |