Date: Thu, 28 Jul 2011 17:31:49 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r224481 - projects/hid/lib/libusbhid Message-ID: <201107281731.p6SHVn7D012648@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Thu Jul 28 17:31:49 2011 New Revision: 224481 URL: http://svn.freebsd.org/changeset/base/224481 Log: Make hid_report_size() handle negative id argument value as wildcard. Modified: projects/hid/lib/libusbhid/parse.c Modified: projects/hid/lib/libusbhid/parse.c ============================================================================== --- projects/hid/lib/libusbhid/parse.c Thu Jul 28 13:49:32 2011 (r224480) +++ projects/hid/lib/libusbhid/parse.c Thu Jul 28 17:31:49 2011 (r224481) @@ -512,13 +512,14 @@ hid_report_size(report_desc_t r, enum hi uint32_t temp; uint32_t hpos; uint32_t lpos; + int report_id = 0; hpos = 0; lpos = 0xFFFFFFFF; memset(&h, 0, sizeof h); for (d = hid_start_parse(r, 1 << k, id); hid_get_item(d, &h); ) { - if (h.report_ID == id && h.kind == k) { + if ((h.report_ID == id || id < 0) && h.kind == k) { /* compute minimum */ if (lpos > h.pos) lpos = h.pos; @@ -527,6 +528,8 @@ hid_report_size(report_desc_t r, enum hi /* compute maximum */ if (hpos < temp) hpos = temp; + if (h.report_ID != 0) + report_id = 1; } } hid_end_parse(d); @@ -537,11 +540,8 @@ hid_report_size(report_desc_t r, enum hi else temp = hpos - lpos; - if (id) - temp += 8; - /* return length in bytes rounded up */ - return ((temp + 7) / 8); + return ((temp + 7) / 8 + report_id); } int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107281731.p6SHVn7D012648>