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

Unified Diff: device/hid/hid_report_descriptor.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_report_descriptor.h ('k') | device/hid/hid_report_descriptor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_report_descriptor.cc
diff --git a/device/hid/hid_report_descriptor.cc b/device/hid/hid_report_descriptor.cc
index d8031d382e16e6771a275a637ba46ce196ee2dc9..331186c26acbefddd4a3e4648fd69aa87f098dee 100644
--- a/device/hid/hid_report_descriptor.cc
+++ b/device/hid/hid_report_descriptor.cc
@@ -29,9 +29,9 @@ HidReportDescriptor::~HidReportDescriptor() {}
void HidReportDescriptor::GetDetails(
std::vector<HidCollectionInfo>* top_level_collections,
bool* has_report_id,
- uint16_t* max_input_report_size,
- uint16_t* max_output_report_size,
- uint16_t* max_feature_report_size) {
+ size_t* max_input_report_size,
+ size_t* max_output_report_size,
+ size_t* max_feature_report_size) {
DCHECK(top_level_collections);
DCHECK(max_input_report_size);
DCHECK(max_output_report_size);
@@ -45,16 +45,16 @@ void HidReportDescriptor::GetDetails(
// Global tags data:
HidUsageAndPage::Page current_usage_page = HidUsageAndPage::kPageUndefined;
- uint16_t current_report_count = 0;
- uint16_t cached_report_count = 0;
- uint16_t current_report_size = 0;
- uint16_t cached_report_size = 0;
- uint16_t current_input_report_size = 0;
- uint16_t current_output_report_size = 0;
- uint16_t current_feature_report_size = 0;
+ size_t current_report_count = 0;
+ size_t cached_report_count = 0;
+ size_t current_report_size = 0;
+ size_t cached_report_size = 0;
+ size_t current_input_report_size = 0;
+ size_t current_output_report_size = 0;
+ size_t current_feature_report_size = 0;
// Local tags data:
- uint16_t current_usage = 0;
+ uint32_t current_usage = 0;
for (std::vector<linked_ptr<HidReportDescriptorItem> >::const_iterator
items_iter = items().begin();
@@ -65,10 +65,12 @@ void HidReportDescriptor::GetDetails(
switch (current_item->tag()) {
// Main tags:
case HidReportDescriptorItem::kTagCollection:
- if (!current_item->parent()) {
+ if (!current_item->parent() &&
+ (current_usage <= std::numeric_limits<uint16_t>::max())) {
// This is a top-level collection.
HidCollectionInfo collection;
- collection.usage = HidUsageAndPage(current_usage, current_usage_page);
+ collection.usage = HidUsageAndPage(
+ static_cast<uint16_t>(current_usage), current_usage_page);
top_level_collections->push_back(collection);
}
break;
@@ -87,7 +89,7 @@ void HidReportDescriptor::GetDetails(
// Global tags:
case HidReportDescriptorItem::kTagUsagePage:
current_usage_page =
- (HidUsageAndPage::Page)current_item->GetShortData();
+ static_cast<HidUsageAndPage::Page>(current_item->GetShortData());
break;
case HidReportDescriptorItem::kTagReportId:
if (top_level_collections->size() > 0) {
« no previous file with comments | « device/hid/hid_report_descriptor.h ('k') | device/hid/hid_report_descriptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698