All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andre McCurdy" <armccurdy@gmail.com>
To: Seebs <seebs@seebs.net>
Cc: openembedded-core <openembedded-core@lists.openembedded.org>
Subject: Re: [OE-core] [PATCH pseudo 4/4] Do not return address of local variable
Date: Wed, 28 Jul 2021 13:49:17 -0700	[thread overview]
Message-ID: <CAJ86T=WvqW64bxW+qWon5ahuyJMqy4H=nhJBhUfwy9jKM4X8SQ@mail.gmail.com> (raw)
In-Reply-To: <20210728151641.667338a5@seebsdell>

On Wed, Jul 28, 2021 at 1:16 PM Seebs <seebs@seebs.net> wrote:
>
> On Wed, 28 Jul 2021 11:36:22 +0200
> "Damian Wrobel" <dwrobel@ertelnet.rybnik.pl> wrote:
>
> > Do I correctly assume that pseudo_client_op() has to be fully
> > reentrant?
>
> No. It's never been even a tiny bit reentrant. We used to do the
> allocate and free thing, and it was incredibly expensive, and the
> nature of the thing requires confidence that we never, ever, have
> more than one thing writing and reading over the socket at a time,
> so it's just Not Reentrant. During one call to pseudo_client_op,
> there will never be another, and all the IPC stuff uses a single
> consistent local buffer that it returns the address of.
>
> Declaring that as static without changing the initializer would indeed
> break everything -- we rely on the initializer working. Changing it to
> static means it only gets initialized once...
>
> Changing it to:
>
>         static pseudo_msg_t msg;
>         msg = pseudo_msg_t { .type = PSEUDO_MSG_OP };
>
> would probably be fine, because then it'd be initialized. Otherwise,
> we'd get failures when msg got overwritten and reused.
>
> Or just changing `result = &msg` to something like `result =
> &xattrdb_data`, which would be nonsensical but it turns out not to
> matter, as the only caller that reaches this case is the caller
> that's just checking yes/no "is the return value not a null pointer".

If the caller only cares about yes/no then how about returning 1/0
instead of a pointer?

  reply	other threads:[~2021-07-28 20:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 11:49 [PATCH pseudo 1/4] Remove -fno-strict-aliasing and -Wno-deprecated-declarations Damian Wrobel
2021-07-27 11:49 ` [PATCH pseudo 2/4] Do not pass null argument to pseudo_diag() Damian Wrobel
2021-07-27 15:48   ` [OE-core] " Seebs
2021-07-27 11:49 ` [PATCH pseudo 3/4] Use -pthread instead of -lpthread Damian Wrobel
2021-07-27 11:49 ` [PATCH pseudo 4/4] Do not return address of local variable Damian Wrobel
2021-07-27 15:47   ` [OE-core] " Seebs
2021-07-27 16:30     ` Damian Wrobel
2021-07-27 16:52       ` Seebs
2021-07-28  9:36         ` Damian Wrobel
2021-07-28 20:16           ` Seebs
2021-07-28 20:49             ` Andre McCurdy [this message]
2021-07-28 20:53               ` Seebs
2021-07-29 12:37             ` [OE-core] [PATCH pseudo 4/4] Do not return address of local variable - unverified Damian Wrobel
2021-07-29 15:08               ` Seebs
2021-07-27 15:49 ` [OE-core] [PATCH pseudo 1/4] Remove -fno-strict-aliasing and -Wno-deprecated-declarations Seebs
2021-07-27 16:35   ` Damian Wrobel
2021-07-27 16:46     ` Seebs

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='CAJ86T=WvqW64bxW+qWon5ahuyJMqy4H=nhJBhUfwy9jKM4X8SQ@mail.gmail.com' \
    --to=armccurdy@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=seebs@seebs.net \
    --subject='Re: [OE-core] [PATCH pseudo 4/4] Do not return address of local variable' \
    /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

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.