RE: [PATCH] hid-magicmouse: Correct parsing of large X and Y motions.

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

 



From: ext Michael Poole [mdpoole@xxxxxxxxxxx]
>ext-phil.2.carmody@xxxxxxxxx writes:
>
>[snip]
>>>+/* Function shamelessly borrowed from hid-core.c. */
>>>+
>>>+static s32 snto32(__u32 value, unsigned n)
>>>+{
>>>+       switch (n) {
>>>+       case 8:  return ((__s8)value);
>>>+       case 16: return ((__s16)value);
>>>+       case 32: return ((__s32)value);
>>
>> Beware - this relies on sane behaviour from the current and future compilers, as the C standard doesn't mandate what should happen when shortening out of range signed values. [n869.txt: 6.3.1.1.#3]
>
>That's good to know.  There's probably some much more complicated, but
>portable, way to write the operation -- I suspect we'll continue to rely
>on the compiler to be sane.
>
>>>+       }
>>>+       return value & (1 << (n - 1)) ? value | (-1 << n) : value;
>>
>> That signed left shift, however, is good old fashioned undefined behaviour. [n869.txt 6.5.7.#4]
>
>Which version is that from?

A text version of n869, which looks like it suffered a little in conversion to not-quite-ASCII.

>  The copy of C99 I have says the resulting
>value is -1 * (2 ** n) if that value can be represented.  (A 6 May 2005
>committee draft of TC2 says the same thing.)  Until n > 31, the behavior
>should be standard-defined.

Looking at the pdfs, agreed, My mistake. I shall have to 'fix' the non-ASCII in my text version, as I much prefer greppable text to pdfs.

Phil--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux