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

Side by Side Diff: device/hid/hid_service_mac.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 unified diff | Download patch
« no previous file with comments | « device/hid/hid_report_descriptor_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/hid/hid_service_mac.h" 5 #include "device/hid/hid_service_mac.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 #include <IOKit/hid/IOHIDDevice.h> 8 #include <IOKit/hid/IOHIDDevice.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 CFIndex collectionsCount = CFArrayGetCount(collections); 99 CFIndex collectionsCount = CFArrayGetCount(collections);
100 *has_report_id = false; 100 *has_report_id = false;
101 for (CFIndex i = 0; i < collectionsCount; i++) { 101 for (CFIndex i = 0; i < collectionsCount; i++) {
102 const IOHIDElementRef collection = static_cast<IOHIDElementRef>( 102 const IOHIDElementRef collection = static_cast<IOHIDElementRef>(
103 const_cast<void*>(CFArrayGetValueAtIndex(collections, i))); 103 const_cast<void*>(CFArrayGetValueAtIndex(collections, i)));
104 // Top-Level Collection has no parent 104 // Top-Level Collection has no parent
105 if (IOHIDElementGetParent(collection) == 0) { 105 if (IOHIDElementGetParent(collection) == 0) {
106 HidCollectionInfo collection_info; 106 HidCollectionInfo collection_info;
107 HidUsageAndPage::Page page = static_cast<HidUsageAndPage::Page>( 107 HidUsageAndPage::Page page = static_cast<HidUsageAndPage::Page>(
108 IOHIDElementGetUsagePage(collection)); 108 IOHIDElementGetUsagePage(collection));
109 uint16_t usage = IOHIDElementGetUsage(collection); 109 uint32_t usage = IOHIDElementGetUsage(collection);
110 collection_info.usage = HidUsageAndPage(usage, page); 110 if (usage > std::numeric_limits<uint16_t>::max())
111 continue;
112 collection_info.usage =
113 HidUsageAndPage(static_cast<uint16_t>(usage), page);
111 // Explore children recursively and retrieve their report IDs 114 // Explore children recursively and retrieve their report IDs
112 GetReportIds(collection, &collection_info.report_ids); 115 GetReportIds(collection, &collection_info.report_ids);
113 if (collection_info.report_ids.size() > 0) { 116 if (collection_info.report_ids.size() > 0) {
114 *has_report_id = true; 117 *has_report_id = true;
115 } 118 }
116 top_level_collections->push_back(collection_info); 119 top_level_collections->push_back(collection_info);
117 } 120 }
118 } 121 }
119 } 122 }
120 123
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 294 }
292 295
293 task_runner_->PostTask( 296 task_runner_->PostTask(
294 FROM_HERE, 297 FROM_HERE,
295 base::Bind(callback, 298 base::Bind(callback,
296 make_scoped_refptr(new HidConnectionMac( 299 make_scoped_refptr(new HidConnectionMac(
297 hid_device.release(), device_info, file_task_runner_)))); 300 hid_device.release(), device_info, file_task_runner_))));
298 } 301 }
299 302
300 } // namespace device 303 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_report_descriptor_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698