All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: Johan Hedberg <johan.hedberg@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 1/3] plugins/sixaxis: Fix cable pairing not working
Date: Wed, 08 Nov 2017 12:06:24 +0100	[thread overview]
Message-ID: <1510139184.3313.4.camel@hadess.net> (raw)
In-Reply-To: <20171108074930.GA11778@x1c.lan>

On Wed, 2017-11-08 at 09:49 +0200, Johan Hedberg wrote:
> Hi Bastien,
> 
> On Tue, Nov 07, 2017, Bastien Nocera wrote:
> > In 6c467e9, get_pairing_type() was modified to return a structure
> > that's
> > allocated on the stack. While not a problem for the direct callers,
> > as the function is defined as "inline", function that expected to
> > return
> > this structure themselves would fail, as the stack would be
> > trampled
> > upon on function exit.
> 
> The devices array inside get_pairing() is declared as static, so I
> don't
> see how this can be on the stack?

Looks like I chased down a wild goose, and that while it "fixed" my
problem, the root cause was something completely different. There's a
new patch coming up.

>  Are these the structures you're
> referring to? That said, it seems weird to have an inline function
> declare a static variable, since then every single caller of the
> function would cause another static variable to be allocated, right?
> It
> seems to me that if the function is still desired to be inline then
> the
> cable_pairing array should at least be moved into some c-file, so
> that
> it only gets created once. Perhaps a better solution is however to
> stop
> having get_pairing() as inline to begin with?

The reason to having this inline in a shared header was explained in
the commit message I believe. We need this code both in the
core/builtin input plugin and in the sixaxis plugin. We'd either need
to make this function public in the core, meaning in the external
plugin API, or copy/pasted between the 2 parts, both of which are
inconvenient.

If the function wasn't inline, we'd have 2 functions with the same
name, and the external plugin, sixaxis in this case, would fail to
load.

      reply	other threads:[~2017-11-08 11:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 18:23 [PATCH 1/3] plugins/sixaxis: Fix cable pairing not working Bastien Nocera
2017-11-07 18:23 ` [PATCH 2/3] core/device: Add support for setting SDP record Bastien Nocera
2017-11-07 18:23 ` [PATCH 3/3] plugins/sixaxis: Provide DualShock 3 SDP record while adding new device Bastien Nocera
2017-11-08 11:29   ` Bastien Nocera
2017-11-08  7:49 ` [PATCH 1/3] plugins/sixaxis: Fix cable pairing not working Johan Hedberg
2017-11-08 11:06   ` Bastien Nocera [this message]

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=1510139184.3313.4.camel@hadess.net \
    --to=hadess@hadess.net \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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.