summaryrefslogtreecommitdiff
path: root/chromium/device
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-08 13:13:08 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-10-04 10:18:09 +0200
commit86e861c8d425225667dacc9e8402ad2a33d7b1bd (patch)
treec04d17ce009ad8b6df1ccc341503398a4494044b /chromium/device
parent94f8cf16432dcc5f3ed06e2f7821fc5574888a81 (diff)
downloadqtwebengine-chromium-86e861c8d425225667dacc9e8402ad2a33d7b1bd.tar.gz
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>
Diffstat (limited to 'chromium/device')
-rw-r--r--chromium/device/fido/public_key_credential_params.cc3
-rw-r--r--chromium/device/fido/win/type_conversions.cc4
-rw-r--r--chromium/device/fido/win/webauthn_api.cc4
-rw-r--r--chromium/device/gamepad/dualshock4_controller.cc8
-rw-r--r--chromium/device/gamepad/gamepad_device_linux.cc2
-rw-r--r--chromium/device/gamepad/gamepad_uma.cc2
-rw-r--r--chromium/device/gamepad/nintendo_controller.cc16
-rw-r--r--chromium/device/gamepad/raw_input_gamepad_device_win.cc6
-rw-r--r--chromium/device/gamepad/raw_input_gamepad_device_win.h2
9 files changed, 24 insertions, 23 deletions
diff --git a/chromium/device/fido/public_key_credential_params.cc b/chromium/device/fido/public_key_credential_params.cc
index cd0ec5701e5..ab6da5d26cd 100644
--- a/chromium/device/fido/public_key_credential_params.cc
+++ b/chromium/device/fido/public_key_credential_params.cc
@@ -39,7 +39,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/fido/win/type_conversions.cc b/chromium/device/fido/win/type_conversions.cc
index 9b7f74420ba..e8458fbb863 100644
--- a/chromium/device/fido/win/type_conversions.cc
+++ b/chromium/device/fido/win/type_conversions.cc
@@ -172,7 +172,7 @@ std::vector<WEBAUTHN_CREDENTIAL> ToWinCredentialVector(
}
result.push_back(WEBAUTHN_CREDENTIAL{
WEBAUTHN_CREDENTIAL_CURRENT_VERSION,
- credential.id().size(),
+ DWORD(credential.id().size()),
const_cast<unsigned char*>(credential.id().data()),
WEBAUTHN_CREDENTIAL_TYPE_PUBLIC_KEY,
});
@@ -188,7 +188,7 @@ std::vector<WEBAUTHN_CREDENTIAL_EX> ToWinCredentialExVector(
continue;
}
result.push_back(WEBAUTHN_CREDENTIAL_EX{
- WEBAUTHN_CREDENTIAL_EX_CURRENT_VERSION, credential.id().size(),
+ WEBAUTHN_CREDENTIAL_EX_CURRENT_VERSION, DWORD(credential.id().size()),
const_cast<unsigned char*>(credential.id().data()),
WEBAUTHN_CREDENTIAL_TYPE_PUBLIC_KEY,
ToWinTransportsMask(credential.transports())});
diff --git a/chromium/device/fido/win/webauthn_api.cc b/chromium/device/fido/win/webauthn_api.cc
index cfd5a2090b6..2c83fcc4a15 100644
--- a/chromium/device/fido/win/webauthn_api.cc
+++ b/chromium/device/fido/win/webauthn_api.cc
@@ -310,7 +310,7 @@ AuthenticatorMakeCredentialBlocking(WinWebAuthnApi* webauthn_api,
kWinWebAuthnTimeoutMilliseconds,
WEBAUTHN_CREDENTIALS{
0, nullptr}, // Ignored because pExcludeCredentialList is set.
- WEBAUTHN_EXTENSIONS{extensions.size(), extensions.data()},
+ WEBAUTHN_EXTENSIONS{DWORD(extensions.size()), extensions.data()},
authenticator_attachment,
request.resident_key_required,
ToWinUserVerificationRequirement(request.user_verification),
@@ -421,7 +421,7 @@ AuthenticatorGetAssertionBlocking(WinWebAuthnApi* webauthn_api,
// As a workaround, MS tells us to also set the CredentialList
// parameter with an accurate cCredentials count and some arbitrary
// pCredentials data.
- WEBAUTHN_CREDENTIALS{legacy_credentials.size(),
+ WEBAUTHN_CREDENTIALS{DWORD(legacy_credentials.size()),
legacy_credentials.data()},
WEBAUTHN_EXTENSIONS{0, nullptr},
authenticator_attachment,
diff --git a/chromium/device/gamepad/dualshock4_controller.cc b/chromium/device/gamepad/dualshock4_controller.cc
index 63fc079d377..3ee4c38abe2 100644
--- a/chromium/device/gamepad/dualshock4_controller.cc
+++ b/chromium/device/gamepad/dualshock4_controller.cc
@@ -233,8 +233,8 @@ void Dualshock4Controller::SetVibrationUsb(double strong_magnitude,
control_report.fill(0);
control_report[0] = kReportId05;
control_report[1] = 0x01; // motor only, don't update LEDs
- control_report[4] = uint8_t{weak_magnitude * kRumbleMagnitudeMax};
- control_report[5] = uint8_t{strong_magnitude * kRumbleMagnitudeMax};
+ control_report[4] = uint8_t(weak_magnitude * kRumbleMagnitudeMax);
+ control_report[5] = uint8_t(strong_magnitude * kRumbleMagnitudeMax);
writer_->WriteOutputReport(control_report);
}
@@ -252,8 +252,8 @@ void Dualshock4Controller::SetVibrationBluetooth(double strong_magnitude,
control_report[2] = 0x20; // unknown
control_report[3] = 0xf1; // motor only, don't update LEDs
control_report[4] = 0x04; // unknown
- control_report[6] = uint8_t{weak_magnitude * kRumbleMagnitudeMax};
- control_report[7] = uint8_t{strong_magnitude * kRumbleMagnitudeMax};
+ control_report[6] = uint8_t(weak_magnitude * kRumbleMagnitudeMax);
+ control_report[7] = uint8_t(strong_magnitude * kRumbleMagnitudeMax);
control_report[21] = 0x43; // volume left
control_report[22] = 0x43; // volume right
control_report[24] = 0x4d; // volume speaker
diff --git a/chromium/device/gamepad/gamepad_device_linux.cc b/chromium/device/gamepad/gamepad_device_linux.cc
index 087744dbe6e..a6e20831e18 100644
--- a/chromium/device/gamepad/gamepad_device_linux.cc
+++ b/chromium/device/gamepad/gamepad_device_linux.cc
@@ -393,7 +393,7 @@ bool GamepadDeviceLinux::ReadEvdevSpecialKeys(Gamepad* pad) {
ssize_t bytes_read;
while ((bytes_read = HANDLE_EINTR(
read(evdev_fd_.get(), &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 eea53e55bd3..9fb930a1f41 100644
--- a/chromium/device/gamepad/gamepad_uma.cc
+++ b/chromium/device/gamepad/gamepad_uma.cc
@@ -19,7 +19,7 @@ void RecordConnectedGamepad(GamepadId gamepad_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/nintendo_controller.cc b/chromium/device/gamepad/nintendo_controller.cc
index e9205a69468..963e3db28a9 100644
--- a/chromium/device/gamepad/nintendo_controller.cc
+++ b/chromium/device/gamepad/nintendo_controller.cc
@@ -1554,7 +1554,7 @@ void NintendoController::SubCommand(uint8_t sub_command,
// Serial subcommands also carry vibration data. Configure the vibration
// portion of the report for a neutral vibration effect (zero amplitude).
// https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_notes.md#output-0x12
- report_bytes[0] = uint8_t{output_report_counter_++ & 0xff};
+ report_bytes[0] = uint8_t(output_report_counter_++ & 0xff);
report_bytes[1] = 0x00;
report_bytes[2] = 0x01;
report_bytes[3] = 0x40;
@@ -1608,7 +1608,7 @@ void NintendoController::RequestVibration(double left_frequency,
FrequencyToHex(left_frequency, left_magnitude, &lhf, &llf, &lhfa, &llfa);
FrequencyToHex(right_frequency, right_magnitude, &rhf, &rlf, &rhfa, &rlfa);
std::vector<uint8_t> report_bytes(output_report_size_bytes_ - 1);
- uint8_t counter = uint8_t{output_report_counter_++ & 0x0f};
+ uint8_t counter = uint8_t(output_report_counter_++ & 0x0f);
report_bytes[0] = counter;
report_bytes[1] = lhf & 0xff;
report_bytes[2] = lhfa + ((lhf >> 8) & 0xff);
@@ -1635,11 +1635,11 @@ void NintendoController::RequestEnableUsbTimeout(bool enable) {
}
void NintendoController::RequestEnableImu(bool enable) {
- SubCommand(kSubCommandEnableImu, {enable ? 0x01 : 0x00});
+ SubCommand(kSubCommandEnableImu, {uint8_t(enable ? 0x01 : 0x00)});
}
void NintendoController::RequestEnableVibration(bool enable) {
- SubCommand(kSubCommandEnableVibration, {enable ? 0x01 : 0x00});
+ SubCommand(kSubCommandEnableVibration, {uint8_t(enable ? 0x01 : 0x00)});
}
void NintendoController::RequestSetPlayerLights(uint8_t light_pattern) {
@@ -1658,8 +1658,8 @@ void NintendoController::RequestSetHomeLight(
DCHECK_LE(cycle_count, 0xf);
if ((cycle_count > 0 && minicycle_count == 1) || minicycle_duration == 0)
minicycle_count = 0;
- std::vector<uint8_t> bytes = {(minicycle_count << 4) | minicycle_duration,
- (start_intensity << 4) | cycle_count};
+ std::vector<uint8_t> bytes = {uint8_t((minicycle_count << 4) | minicycle_duration),
+ uint8_t((start_intensity << 4) | cycle_count)};
bytes.insert(bytes.end(), minicycle_data.begin(), minicycle_data.end());
SubCommand(kSubCommandSetHomeLight, bytes);
}
@@ -1676,7 +1676,7 @@ void NintendoController::RequestSetHomeLightIntensity(double intensity) {
// 1x minicycle duration. Because |minicycle_count| and |cycle_count| are
// both zero, the device will transition to the 1st minicycle and then stay at
// |led_intensity|.
- RequestSetHomeLight(0, 1, led_intensity, 0, {led_intensity << 4, 0x00});
+ RequestSetHomeLight(0, 1, led_intensity, 0, {uint8_t(led_intensity << 4), 0x00});
}
void NintendoController::RequestSetImuSensitivity(
@@ -1699,7 +1699,7 @@ void NintendoController::ReadSpi(uint16_t address, size_t length) {
uint8_t address_high = (address >> 8) & 0xff;
uint8_t address_low = address & 0xff;
SubCommand(kSubCommandReadSpi,
- {address_low, address_high, 0x00, 0x00, uint8_t{length}});
+ {address_low, address_high, 0x00, 0x00, uint8_t(length)});
}
void NintendoController::RequestImuCalibration() {
diff --git a/chromium/device/gamepad/raw_input_gamepad_device_win.cc b/chromium/device/gamepad/raw_input_gamepad_device_win.cc
index 29a681276e6..a186b39d3b3 100644
--- a/chromium/device/gamepad/raw_input_gamepad_device_win.cc
+++ b/chromium/device/gamepad/raw_input_gamepad_device_win.cc
@@ -156,7 +156,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 &&
@@ -445,8 +445,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/device/gamepad/raw_input_gamepad_device_win.h b/chromium/device/gamepad/raw_input_gamepad_device_win.h
index 25ea942b762..c0898853f6f 100644
--- a/chromium/device/gamepad/raw_input_gamepad_device_win.h
+++ b/chromium/device/gamepad/raw_input_gamepad_device_win.h
@@ -124,7 +124,7 @@ class RawInputGamepadDeviceWin final : public AbstractHapticGamepad {
bool buttons_[Gamepad::kButtonsLengthCap];
// Keep track of which button indices are in use.
- std::vector<bool> button_indices_used_{Gamepad::kButtonsLengthCap, false};
+ std::vector<bool> button_indices_used_{(Gamepad::kButtonsLengthCap != 0), false};
// Bitfield to keep track of which axes indices are in use.
uint32_t axes_used_ = 0;