Re: [PATCH] Input: spaceball - fix parsing of movement data packets

From: Leo L. Schwab
Date: Tue Dec 21 2021 - 05:32:15 EST


On Mon, Dec 20, 2021 at 12:59:21AM -0800, Dmitry Torokhov wrote:
> Could we write
>
> for (i == 0; i < ARRAY_SIZE(spaceball_axes); i++)
> input_report_abs(dev, spaceball_axes[i],
> (__s16)(get_unaligned_be16(&data[i * 2]);
>
> instead?
>
It's not as readable, but sure, I could do that.

> for (i == 0; i < ARRAY_SIZE(spaceball_axes); i++)
^^
Pretty sure you didn't mean that :-).

> input_report_abs(dev, spaceball_axes[i],
> (__s16)(get_unaligned_be16(&data[i * 2]);
^^^^^^^
I'm new here, but it seems odd that an array index (shift plus add
to the base pointer) is preferred over a direct pointer reference.

> (__s16)(get_unaligned_be16(&data[i * 2]);
^^^^^^^^^^^^^^^^^^
Ooo! Didn't know about this; thank you!

Schwab