Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Fix hid_get_data() for negative or 32-bit report data.
details: https://anonhg.NetBSD.org/src/rev/ca279937077e
branches: trunk
changeset: 342624:ca279937077e
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Fri Jan 01 22:59:12 2016 +0000
description:
Fix hid_get_data() for negative or 32-bit report data.
diffstat:
lib/libusbhid/data.c | 14 ++++++++------
tests/lib/libusbhid/t_usbhid.c | 7 ++-----
2 files changed, 10 insertions(+), 11 deletions(-)
diffs (63 lines):
diff -r 789fd14cf37b -r ca279937077e lib/libusbhid/data.c
--- a/lib/libusbhid/data.c Fri Jan 01 22:47:34 2016 +0000
+++ b/lib/libusbhid/data.c Fri Jan 01 22:59:12 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: data.c,v 1.6 2010/05/12 18:28:20 plunky Exp $ */
+/* $NetBSD: data.c,v 1.7 2016/01/01 22:59:12 jakllsch Exp $ */
/*
* Copyright (c) 1999 Lennart Augustsson <augustss%NetBSD.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: data.c,v 1.6 2010/05/12 18:28:20 plunky Exp $");
+__RCSID("$NetBSD: data.c,v 1.7 2016/01/01 22:59:12 jakllsch Exp $");
#include <assert.h>
#include <stdlib.h>
@@ -57,10 +57,12 @@
for (i = 0; i < end; i++)
data |= buf[offs + i] << (i*8);
data >>= hpos % 8;
- data &= (1 << hsize) - 1;
- if (h->logical_minimum < 0 && (data & (1<<(hsize-1)))) {
- /* Need to sign extend */
- data |= 0xffffffff & ~((1<<hsize)-1);
+ if (hsize < 32) {
+ data &= (1 << hsize) - 1;
+ if (h->logical_minimum < 0 && (data & (1<<(hsize-1)))) {
+ /* Need to sign extend */
+ data |= 0xffffffff & ~((1<<hsize)-1);
+ }
}
return (int)(data);
}
diff -r 789fd14cf37b -r ca279937077e tests/lib/libusbhid/t_usbhid.c
--- a/tests/lib/libusbhid/t_usbhid.c Fri Jan 01 22:47:34 2016 +0000
+++ b/tests/lib/libusbhid/t_usbhid.c Fri Jan 01 22:59:12 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_usbhid.c,v 1.2 2016/01/01 22:47:34 jakllsch Exp $ */
+/* $NetBSD: t_usbhid.c,v 1.3 2016/01/01 22:59:12 jakllsch Exp $ */
/*
* Copyright (c) 2016 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_usbhid.c,v 1.2 2016/01/01 22:47:34 jakllsch Exp $");
+__RCSID("$NetBSD: t_usbhid.c,v 1.3 2016/01/01 22:59:12 jakllsch Exp $");
#include <atf-c.h>
@@ -326,9 +326,6 @@
int32_t data;
uint32_t udat;
- atf_tc_expect_fail("all negative data doesn't work, "
- "all 32-bit data doesn't work");
-
ATF_REQUIRE((hrd = hid_use_report_desc(
range_test_report_descriptor,
__arraycount(range_test_report_descriptor))) != NULL);
Home |
Main Index |
Thread Index |
Old Index