Re: [PATCH] HID: microsoft, do not use compound literal

From: Geert Uytterhoeven
Date: Mon Nov 12 2012 - 04:23:37 EST


On Mon, Nov 12, 2012 at 10:16 AM, Jiri Slaby <jslaby@xxxxxxx> wrote:
> In patch "HID: microsoft: fix invalid rdesc for 3k kbd" I fixed
> support for MS 3k keyboards. However the added check using memcmp and
> a compound statement breaks build on architectures where memcmp is a
> macro with parameters. The error looks there like (m68k-linux-gnu-gcc
> 4.1.2):
> hid-microsoft.c:51:18: error: macro "memcmp" passed 6 arguments, but takes just 3
> hid-microsoft.c: In function âms_report_fixupâ:
> drivers/hid/hid-microsoft.c:50: error: âmemcmpâ undeclared (first use in this function)
> hid-microsoft.c:50: error: (Each undeclared identifier is reported only once
> /hid-microsoft.c:50: error: for each function it appears in.)

The above 3 lines were actually from a build with a different config
--- which I didn't
notice at that time --- where <linux/string.h> was not indirectly included.

> On x86_64, memcmp is a function, so I did not see the error.
>
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> Reported-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> ---
> drivers/hid/hid-microsoft.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
> index f676c01..6fcd466 100644
> --- a/drivers/hid/hid-microsoft.c
> +++ b/drivers/hid/hid-microsoft.c
> @@ -46,9 +46,9 @@ static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
> rdesc[559] = 0x45;
> }
> /* the same as above (s/usage/physical/) */
> - if ((quirks & MS_RDESC_3K) && *rsize == 106 &&
> - !memcmp((char []){ 0x19, 0x00, 0x29, 0xff },
> - &rdesc[94], 4)) {
> + if ((quirks & MS_RDESC_3K) && *rsize == 106 && rdesc[94] == 0x19 &&
> + rdesc[95] == 0x00 && rdesc[96] == 0x29 &&
> + rdesc[97] == 0xff) {
> rdesc[94] = 0x35;
> rdesc[96] = 0x45;
> }
> --
> 1.8.0

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/