All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dave Airlie <airlied@gmail.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	arve@android.com, kernel-team@android.com,
	John Stultz <john.stultz@linaro.org>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: [PATCH v4] drivers/tty: Folding Android's keyreset driver in sysRQ
Date: Wed, 27 Feb 2013 10:58:44 -0700	[thread overview]
Message-ID: <512E4954.6060601@linaro.org> (raw)
In-Reply-To: <CA+55aFysXNSJMHL-rKZ_fvPP3t357zTC-6hyHmh=S6K-Qx0WbQ@mail.gmail.com>

On 13-02-27 09:57 AM, Linus Torvalds wrote:
> On Tue, Feb 26, 2013 at 11:33 PM, Dave Airlie <airlied@gmail.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
> 

Your fix is compiling, running and yielding the correct results -
apologies about that.

Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>

  reply	other threads:[~2013-02-27 17:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-11 20:24 [PATCH v4] drivers/tty: Folding Android's keyreset driver in sysRQ mathieu.poirier
2012-11-19  7:25 ` Dmitry Torokhov
     [not found]   ` <CAPM=9tw8mefcYTqELXFbZWZ44a--SNcPnRMAvMSGTiODzRpDhg@mail.gmail.com>
2013-02-27  8:26     ` Dave Airlie
2013-02-27 11:06       ` Dave Airlie
2013-02-27 11:10         ` Dave Airlie
2013-02-27 11:40           ` Dave Airlie
2013-02-27 16:57     ` Linus Torvalds
2013-02-27 17:58       ` Mathieu Poirier [this message]
2013-02-27 18:09         ` Linus Torvalds
2013-02-27 18:26           ` David Howells
2013-02-27 18:49         ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512E4954.6060601@linaro.org \
    --to=mathieu.poirier@linaro.org \
    --cc=airlied@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arve@android.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.