linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: microsoft, do not use compound literal
@ 2012-11-12  9:16 Jiri Slaby
  2012-11-12  9:23 ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2012-11-12  9:16 UTC (permalink / raw)
  To: jkosina; +Cc: linux-input, linux-kernel, jirislaby

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.)

On x86_64, memcmp is a function, so I did not see the error.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 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


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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: microsoft, do not use compound literal
  2012-11-12  9:16 [PATCH] HID: microsoft, do not use compound literal Jiri Slaby
@ 2012-11-12  9:23 ` Geert Uytterhoeven
  2012-11-12 12:15   ` Jiri Kosina
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2012-11-12  9:23 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: jkosina, linux-input, linux-kernel, jirislaby

On Mon, Nov 12, 2012 at 10:16 AM, Jiri Slaby <jslaby@suse.cz> 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@suse.cz>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
>  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@linux-m68k.org

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-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: microsoft, do not use compound literal
  2012-11-12  9:23 ` Geert Uytterhoeven
@ 2012-11-12 12:15   ` Jiri Kosina
  2012-11-12 12:30     ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2012-11-12 12:15 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Jiri Slaby, linux-input, linux-kernel, jirislaby

On Mon, 12 Nov 2012, Geert Uytterhoeven wrote:

> On Mon, Nov 12, 2012 at 10:16 AM, Jiri Slaby <jslaby@suse.cz> 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.

Still the patch needs string.h include addition, otherwise you still are 
able to come up with m68k config that doesn't build, do I understand it 
correctly?

Thanks,

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: microsoft, do not use compound literal
  2012-11-12 12:15   ` Jiri Kosina
@ 2012-11-12 12:30     ` Geert Uytterhoeven
  2012-11-12 12:35       ` Jiri Slaby
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2012-11-12 12:30 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Jiri Slaby, linux-input, linux-kernel, jirislaby

On Mon, Nov 12, 2012 at 1:15 PM, Jiri Kosina <jkosina@suse.cz> wrote:
> On Mon, 12 Nov 2012, Geert Uytterhoeven wrote:
>> On Mon, Nov 12, 2012 at 10:16 AM, Jiri Slaby <jslaby@suse.cz> 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.
>
> Still the patch needs string.h include addition, otherwise you still are
> able to come up with m68k config that doesn't build, do I understand it
> correctly?

No.

My comment was purely cosmetic, as it applies to the quoted compiler error
messages only.

Your latest version doesn't use memcmp() anymore, so I think there's no need to
include <linux/string.h> anymore.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: microsoft, do not use compound literal
  2012-11-12 12:30     ` Geert Uytterhoeven
@ 2012-11-12 12:35       ` Jiri Slaby
  2012-11-12 12:42         ` Geert Uytterhoeven
  2012-11-12 14:46         ` Jiri Kosina
  0 siblings, 2 replies; 7+ messages in thread
From: Jiri Slaby @ 2012-11-12 12:35 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Jiri Kosina, linux-input, linux-kernel, jirislaby

On 11/12/2012 01:30 PM, Geert Uytterhoeven wrote:
> My comment was purely cosmetic, as it applies to the quoted compiler error
> messages only.

Ah, I see. When you are applying the patch Jiri, could you remove errors
about line 50 from the commit log? What I wanted to have there
apparently was only "hid-microsoft.c:51:18: error: macro "memcmp" passed
6 arguments, but takes just 3".

> Your latest version doesn't use memcmp() anymore, so I think there's no need to
> include <linux/string.h> anymore.

s/Your/His/ perhaps :). Otherwise I'd be confused -- did Jiri send some
other version?

thanks,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: microsoft, do not use compound literal
  2012-11-12 12:35       ` Jiri Slaby
@ 2012-11-12 12:42         ` Geert Uytterhoeven
  2012-11-12 14:46         ` Jiri Kosina
  1 sibling, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2012-11-12 12:42 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Jiri Kosina, linux-input, linux-kernel, jirislaby

On Mon, Nov 12, 2012 at 1:35 PM, Jiri Slaby <jslaby@suse.cz> wrote:
> On 11/12/2012 01:30 PM, Geert Uytterhoeven wrote:
>> My comment was purely cosmetic, as it applies to the quoted compiler error
>> messages only.
>
> Ah, I see. When you are applying the patch Jiri, could you remove errors
> about line 50 from the commit log? What I wanted to have there
> apparently was only "hid-microsoft.c:51:18: error: macro "memcmp" passed
> 6 arguments, but takes just 3".

Right.

>> Your latest version doesn't use memcmp() anymore, so I think there's no need to
>> include <linux/string.h> anymore.
>
> s/Your/His/ perhaps :). Otherwise I'd be confused -- did Jiri send some
> other version?

Doh, I'm (still) not awake, and didn't notice there are two different
Jiri's in this thread...

Sorry for the confusion.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] HID: microsoft, do not use compound literal
  2012-11-12 12:35       ` Jiri Slaby
  2012-11-12 12:42         ` Geert Uytterhoeven
@ 2012-11-12 14:46         ` Jiri Kosina
  1 sibling, 0 replies; 7+ messages in thread
From: Jiri Kosina @ 2012-11-12 14:46 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Geert Uytterhoeven, linux-input, linux-kernel, jirislaby

On Mon, 12 Nov 2012, Jiri Slaby wrote:

> > My comment was purely cosmetic, as it applies to the quoted compiler error
> > messages only.
> 
> Ah, I see. When you are applying the patch Jiri, could you remove errors
> about line 50 from the commit log? What I wanted to have there
> apparently was only "hid-microsoft.c:51:18: error: macro "memcmp" passed
> 6 arguments, but takes just 3".

Thanks. I have removed the misleading build failures from the changelog 
and applied.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-11-12 14:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-12  9:16 [PATCH] HID: microsoft, do not use compound literal Jiri Slaby
2012-11-12  9:23 ` Geert Uytterhoeven
2012-11-12 12:15   ` Jiri Kosina
2012-11-12 12:30     ` Geert Uytterhoeven
2012-11-12 12:35       ` Jiri Slaby
2012-11-12 12:42         ` Geert Uytterhoeven
2012-11-12 14:46         ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).