diff options
author | pkasting <pkasting@chromium.org> | 2014-10-17 19:13:01 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-18 02:13:24 +0000 |
commit | 4c3b672cc2c1515b7e16cb535e1cd6e69e326607 (patch) | |
tree | ec3b7a1c3da0362644ce8c9851bece97bc965002 /device/hid/hid_service_mac.cc | |
parent | f5c85cf69f46e8231da8d292cbae29d5241ddadf (diff) | |
download | chromium_src-4c3b672cc2c1515b7e16cb535e1cd6e69e326607.zip chromium_src-4c3b672cc2c1515b7e16cb535e1cd6e69e326607.tar.gz chromium_src-4c3b672cc2c1515b7e16cb535e1cd6e69e326607.tar.bz2 |
Fix type truncation warnings in HID code.
GetShortData() and IOHIDElementGetUsage() both return uint32s, so raise the size
of various containing types to uint32.
I tried to look in the USB HID spec to see if any of the affected fields here
were limited to e.g. <2^16, meaning that it'd be safe to just cast down to the
existing uint16s instead, but I couldn't find any limits.
BUG=81439
TEST=none
Review URL: https://codereview.chromium.org/656583003
Cr-Commit-Position: refs/heads/master@{#300201}
Diffstat (limited to 'device/hid/hid_service_mac.cc')
-rw-r--r-- | device/hid/hid_service_mac.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/device/hid/hid_service_mac.cc b/device/hid/hid_service_mac.cc index 4723668..6e091a85 100644 --- a/device/hid/hid_service_mac.cc +++ b/device/hid/hid_service_mac.cc @@ -106,8 +106,11 @@ void GetCollectionInfos(IOHIDDeviceRef device, HidCollectionInfo collection_info; HidUsageAndPage::Page page = static_cast<HidUsageAndPage::Page>( IOHIDElementGetUsagePage(collection)); - uint16_t usage = IOHIDElementGetUsage(collection); - collection_info.usage = HidUsageAndPage(usage, page); + uint32_t usage = IOHIDElementGetUsage(collection); + if (usage > std::numeric_limits<uint16_t>::max()) + continue; + collection_info.usage = + HidUsageAndPage(static_cast<uint16_t>(usage), page); // Explore children recursively and retrieve their report IDs GetReportIds(collection, &collection_info.report_ids); if (collection_info.report_ids.size() > 0) { |