Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: device/hid/hid_connection_win.cc

Issue 656583003: Fix type truncation warnings in HID code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/hid/hid_connection_unittest.cc ('k') | device/hid/hid_device_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_connection_win.cc
diff --git a/device/hid/hid_connection_win.cc b/device/hid/hid_connection_win.cc
index a8414dafe642dcbfb4e3ed943a44e0efaa68de6a..1783092a0310e9b6d9f0638fc65d06ed37ea67a2 100644
--- a/device/hid/hid_connection_win.cc
+++ b/device/hid/hid_connection_win.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/files/file.h"
#include "base/message_loop/message_loop.h"
+#include "base/numerics/safe_conversions.h"
#include "base/profiler/scoped_profile.h"
#include "base/win/object_watcher.h"
@@ -135,8 +136,8 @@ void HidConnectionWin::PlatformRead(
const HidConnection::ReadCallback& callback) {
// Windows will always include the report ID (including zero if report IDs
// are not in use) in the buffer.
- scoped_refptr<net::IOBufferWithSize> buffer =
- new net::IOBufferWithSize(device_info().max_input_report_size + 1);
+ scoped_refptr<net::IOBufferWithSize> buffer = new net::IOBufferWithSize(
+ base::checked_cast<int>(device_info().max_input_report_size + 1));
scoped_refptr<PendingHidTransfer> transfer(new PendingHidTransfer(
buffer,
base::Bind(&HidConnectionWin::OnReadComplete, this, buffer, callback)));
@@ -167,8 +168,8 @@ void HidConnectionWin::PlatformWrite(scoped_refptr<net::IOBuffer> buffer,
void HidConnectionWin::PlatformGetFeatureReport(uint8_t report_id,
const ReadCallback& callback) {
// The first byte of the destination buffer is the report ID being requested.
- scoped_refptr<net::IOBufferWithSize> buffer =
- new net::IOBufferWithSize(device_info().max_feature_report_size + 1);
+ scoped_refptr<net::IOBufferWithSize> buffer = new net::IOBufferWithSize(
+ base::checked_cast<int>(device_info().max_feature_report_size + 1));
buffer->data()[0] = report_id;
scoped_refptr<PendingHidTransfer> transfer(new PendingHidTransfer(
« no previous file with comments | « device/hid/hid_connection_unittest.cc ('k') | device/hid/hid_device_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698