Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libusbhid Improve usbhid(3) descriptor/report parsing:
details: https://anonhg.NetBSD.org/src/rev/ce977be3c64d
branches: trunk
changeset: 757077:ce977be3c64d
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Fri Aug 13 19:56:34 2010 +0000
description:
Improve usbhid(3) descriptor/report parsing:
Handle signed Physical Minimums
Handle signed Unit Exponents
diffstat:
lib/libusbhid/parse.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diffs (59 lines):
diff -r 1d05fb507d26 -r ce977be3c64d lib/libusbhid/parse.c
--- a/lib/libusbhid/parse.c Fri Aug 13 19:51:54 2010 +0000
+++ b/lib/libusbhid/parse.c Fri Aug 13 19:56:34 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.6 2010/01/05 17:57:06 jakllsch Exp $ */
+/* $NetBSD: parse.c,v 1.7 2010/08/13 19:56:34 jakllsch Exp $ */
/*
* Copyright (c) 1999, 2001 Lennart Augustsson <augustss%NetBSD.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: parse.c,v 1.6 2010/01/05 17:57:06 jakllsch Exp $");
+__RCSID("$NetBSD: parse.c,v 1.7 2010/08/13 19:56:34 jakllsch Exp $");
#include <assert.h>
#include <stdlib.h>
@@ -50,6 +50,7 @@
int nusage;
int minset;
int logminsize;
+ int phyminsize;
int multi;
int multimax;
int kindset;
@@ -174,6 +175,14 @@
else if (s->logminsize == 2)
c->logical_minimum =(int16_t)c->logical_minimum;
}
+ if (c->physical_minimum >= c->physical_maximum) {
+ if (s->phyminsize == 1)
+ c->physical_minimum =
+ (int8_t)c->physical_minimum;
+ else if (s->phyminsize == 2)
+ c->physical_minimum =
+ (int16_t)c->physical_minimum;
+ }
if (s->multi < s->multimax) {
c->usage = s->usages[min(s->multi, s->nusage-1)];
s->multi++;
@@ -334,12 +343,16 @@
break;
case 3:
c->physical_minimum = dval;
+ s->phyminsize = bSize;
break;
case 4:
c->physical_maximum = dval;
break;
case 5:
- c->unit_exponent = dval;
+ if ( dval > 7 && dval < 0x10)
+ c->unit_exponent = -16 + dval;
+ else
+ c->unit_exponent = dval;
break;
case 6:
c->unit = dval;
Home |
Main Index |
Thread Index |
Old Index