From owner-freebsd-audit Thu May 16 7:24: 7 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.musha.org (daemon.musha.org [218.44.187.2]) by hub.freebsd.org (Postfix) with ESMTP id 8398F37B4F3; Thu, 16 May 2002 07:22:01 -0700 (PDT) Received: from archon.local.idaemons.org (archon.local.idaemons.org [192.168.1.32]) by mail.musha.org (Postfix) with ESMTP id 3136B4D801; Thu, 16 May 2002 23:21:59 +0900 (JST) Date: Thu, 16 May 2002 23:21:59 +0900 Message-ID: <86it5o896g.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: Bruce Evans Cc: Bill Fenner , , , , Subject: Re: moused(8): char signed-ness problem with gcc 3.1 In-Reply-To: <20020516215731.K499-100000@gamplex.bde.org> References: <86k7q48h2w.wl@archon.local.idaemons.org> <20020516215731.K499-100000@gamplex.bde.org> User-Agent: Wanderlust/2.9.11 (Unchained Melody) SEMI/1.14.3 (Ushinoya) LIMIT/1.14.7 (Fujiidera) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At Thu, 16 May 2002 21:58:56 +1000 (EST), Bruce Evans wrote: > > Somehow, specifying -fsigned-char, which I thought was the default, > > fixed the problem. So, the cause may be in our configuration of gcc? > > -fsigned-char doesn't fix it for me. Neither does repacling "char" by > "signed char". Oops, I was testing on a different box. Sorry. > moused is broken too. It assumes that plain chars are signed. How about this? Index: moused.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/moused/moused.c,v retrieving revision 1.55 diff -u -r1.55 moused.c --- moused.c 28 Apr 2002 11:59:30 -0000 1.55 +++ moused.c 16 May 2002 14:15:42 -0000 @@ -1718,8 +1718,8 @@ return 0; } - act->dx = (char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F)); - act->dy = (char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F)); + act->dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F)); + act->dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F)); break; case MOUSE_PROTO_GLIDEPOINT: /* GlidePoint */ @@ -1728,8 +1728,8 @@ MouseMan+ */ act->button = (act->obutton & (MOUSE_BUTTON2DOWN | MOUSE_BUTTON4DOWN)) | butmapmss[(pBuf[0] & MOUSE_MSS_BUTTONS) >> 4]; - act->dx = (char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F)); - act->dy = (char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F)); + act->dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F)); + act->dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F)); break; case MOUSE_PROTO_MSC: /* MouseSystems Corp */ @@ -1737,15 +1737,15 @@ case MOUSE_PROTO_MARIQUA: /* Mariqua */ #endif act->button = butmapmsc[(~pBuf[0]) & MOUSE_MSC_BUTTONS]; - act->dx = (char)(pBuf[1]) + (char)(pBuf[3]); - act->dy = - ((char)(pBuf[2]) + (char)(pBuf[4])); + act->dx = (signed char)(pBuf[1]) + (signed char)(pBuf[3]); + act->dy = - ((signed char)(pBuf[2]) + (signed char)(pBuf[4])); break; case MOUSE_PROTO_JOGDIAL: /* JogDial */ if (rBuf == 0x6c) - act->dz=-1; + act->dz = -1; if (rBuf == 0x72) - act->dz=1; + act->dz = 1; if (rBuf == 0x64) act->button = MOUSE_BUTTON1DOWN; if (rBuf == 0x75) @@ -1792,8 +1792,8 @@ case MOUSE_PROTO_BUS: /* Bus */ case MOUSE_PROTO_INPORT: /* InPort */ act->button = butmapmsc[(~pBuf[0]) & MOUSE_MSC_BUTTONS]; - act->dx = (char)pBuf[1]; - act->dy = - (char)pBuf[2]; + act->dx = (signed char)pBuf[1]; + act->dy = - (signed char)pBuf[2]; break; case MOUSE_PROTO_PS2: /* PS/2 */ @@ -1822,7 +1822,7 @@ case MOUSE_MODEL_INTELLI: case MOUSE_MODEL_NET: /* wheel data is in the fourth byte */ - act->dz = (char)pBuf[3]; + act->dz = (signed char)pBuf[3]; if ((act->dz >= 7) || (act->dz <= -7)) act->dz = 0; /* some compatible mice may have additional buttons */ @@ -1969,10 +1969,10 @@ case MOUSE_PROTO_SYSMOUSE: /* sysmouse */ act->button = butmapmsc[(~pBuf[0]) & MOUSE_SYS_STDBUTTONS]; - act->dx = (char)(pBuf[1]) + (char)(pBuf[3]); - act->dy = - ((char)(pBuf[2]) + (char)(pBuf[4])); + act->dx = (signed char)(pBuf[1]) + (signed char)(pBuf[3]); + act->dy = - ((signed char)(pBuf[2]) + (signed char)(pBuf[4])); if (rodent.level == 1) { - act->dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1))/2; + act->dz = ((signed char)(pBuf[5] << 1) + (signed char)(pBuf[6] << 1)) >> 1; act->button |= ((~pBuf[7] & MOUSE_SYS_EXTBUTTONS) << 3); } break; -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message