[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFysXNSJMHL-rKZ_fvPP3t357zTC-6hyHmh=S6K-Qx0WbQ@mail.gmail.com>
Date: Wed, 27 Feb 2013 08:57:08 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Dave Airlie <airlied@...il.com>,
Mathieu Poirier <mathieu.poirier@...aro.org>
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
arve@...roid.com, kernel-team@...roid.com,
John Stultz <john.stultz@...aro.org>,
Alan Cox <alan@...rguk.ukuu.org.uk>
Subject: Re: [PATCH v4] drivers/tty: Folding Android's keyreset driver in sysRQ
On Tue, Feb 26, 2013 at 11:33 PM, Dave Airlie <airlied@...il.com> wrote:
>
> It looks to me like the weak bit isn't working so well
>
> if (platform_sysrq_reset_seq) {
> for (i = 0; i < ARRAY_SIZE(sysrq_reset_seq); i++) {
> key = platform_sysrq_reset_seq[i];
> 6d: 66 8b 8c 00 00 00 00 mov 0x0(%eax,%eax,1),%cx
> 74: 00
>
> is around where it craps out.
> gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
> Fedora 18 machine.
Hmm. I would love to blame gcc, but no, I think the code is crap.
The whole 'platform_sysrq_reset_seq[]' thing is broken in current git,
and it apparently only happens to work by mistake for most of us.
Doing a "grep" for it shows all three uses:
git grep platform_sysrq_reset_seq
extern unsigned short platform_sysrq_reset_seq[] __weak;
if (platform_sysrq_reset_seq) {
key = platform_sysrq_reset_seq[i];
and the thing is, if it is declared as an array (not a pointer), then
I think it is perfectly understandable that when then testing the
*address* of that array, gcc just says "you're stupid, you're testing
something that cannot possibly be NULL, so I'll throw your idiotic
test away".
And gcc would be completely correct. That test is moronic. You just
said that platform_sysrq_reset_seq[] was an external array, there is
no way in hell that is NULL.
Now, if it was a _pointer_, that would be a different thing entirely.
A pointer can have a NULL value. A named array, not so much.
So I *think* the fix might be something like the attached. Totally
untested. It may compile, or it may not.
Linus
Download attachment "patch.diff" of type "application/octet-stream" (1075 bytes)
Powered by blists - more mailing lists