On Sun, Apr 10, 2011 at 9:58 PM, Peter Hutterer
<[email protected]> wrote:
> On Sun, Apr 10, 2011 at 09:15:51PM -0500, [email protected] wrote:
>> From: Chris Bagwell <[email protected]>
>>
>> Since btn is a bit location, compute how may bytes it would require
>> before comparing to sizeof().
>>
>> Signed-off-by: Chris Bagwell <[email protected]>
>> ---
>>
>> Since last patch, change approach to see how many bytes to
>> store this button # in instead of converting sizeof() to # of
>> bits.  This is to make it easier to switch to bits_to_bytes()
>> routine in xserver's include/misc.h.
>>
>> I chose not to use that though because I think its kinda heavy handed
>> requirement to have users install X server headers just to compile
>> this input module.  Also, I'm not sure how to get access to server
>> header files anyways.  I'm sure a file called "misc.h" isn't installed
>> to /usr/include?  And that means configure would need modification as well.
>
> this is depressing. though I replied to you twice in this thread, I couldn't
> remember it and wrote the other patch from scratch...
>
> anyway. we already requite users to install X server header files, otherwise
> we wouldn't have all the APIs required to compile the driver. misc.h is in
> /usr/include/xorg/, the same directory where xf86Xinput.h and others vital
> API bits are located. we also already require misc.h for max() in wcmCommon.c.

Good to know.  Thanks for the info.

>
> the hunk for this change now would be:
>
> diff --git a/src/wcmUSB.c b/src/wcmUSB.c
> index 1219530..c168c59 100644
> --- a/src/wcmUSB.c
> +++ b/src/wcmUSB.c
> @@ -1054,7 +1054,7 @@ static int mod_buttons(int buttons, int btn, int state)
>  {
>        int mask;
>
> -       if (btn >= sizeof(int) * 8)
> +       if (bits_to_bytes(btn + 1) > sizeof(int))
>        {
>                xf86Msg(X_ERROR, "%s: Invalid button number %d. Insufficient "
>                                "storage\n", __func__, btn);
>
>
> not sure which one is easier to read.
>

I think your version is plenty easy to read.  I'd go for that.

Chris

> Cheers,
>  Peter
>
>>  src/wcmUSB.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/wcmUSB.c b/src/wcmUSB.c
>> index 9ff59ea..061b0af 100644
>> --- a/src/wcmUSB.c
>> +++ b/src/wcmUSB.c
>> @@ -1054,7 +1054,7 @@ static int mod_buttons(int buttons, int btn, int state)
>>  {
>>       int mask;
>>
>> -     if (btn >= sizeof(int))
>> +     if ((btn+7) >> 3 > sizeof(int))
>>       {
>>               xf86Msg(X_ERROR, "%s: Invalid button number %d. Insufficient "
>>                               "storage\n", __func__, btn);
>> --
>> 1.7.4.2
>

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to