Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libusbhid Fix sign extension broken by previous. dillo h...



details:   https://anonhg.NetBSD.org/src/rev/2fe70316a134
branches:  trunk
changeset: 586340:2fe70316a134
user:      wiz <wiz%NetBSD.org@localhost>
date:      Wed Dec 14 17:35:40 2005 +0000

description:
Fix sign extension broken by previous. dillo hacked here too.

diffstat:

 lib/libusbhid/data.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (31 lines):

diff -r 9a29497b04c5 -r 2fe70316a134 lib/libusbhid/data.c
--- a/lib/libusbhid/data.c      Wed Dec 14 16:21:55 2005 +0000
+++ b/lib/libusbhid/data.c      Wed Dec 14 17:35:40 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: data.c,v 1.4 2005/12/05 02:09:17 christos Exp $        */
+/*     $NetBSD: data.c,v 1.5 2005/12/14 17:35:40 wiz Exp $     */
 
 /*
  * Copyright (c) 1999 Lennart Augustsson <augustss%NetBSD.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: data.c,v 1.4 2005/12/05 02:09:17 christos Exp $");
+__RCSID("$NetBSD: data.c,v 1.5 2005/12/14 17:35:40 wiz Exp $");
 
 #include <assert.h>
 #include <stdlib.h>
@@ -58,10 +58,9 @@
                data |= buf[offs + i] << (i*8);
        data >>= hpos % 8;
        data &= (1 << hsize) - 1;
-       if (h->logical_minimum < 0) {
+       if (h->logical_minimum < 0 && (data & (1<<(hsize-1)))) {
                /* Need to sign extend */
-               hsize = sizeof data * 8 - hsize;
-               data = (data << hsize) >> hsize;
+               data |= 0xffffffff & ~((1<<hsize)-1);
        }
        return (int)(data);
 }



Home | Main Index | Thread Index | Old Index