From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: NeilBrown <neilb@suse.de>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
ksummit@lists.linux.dev, Julia Lawall <julia.lawall@inria.fr>
Subject: Re: Potential static analysis ideas
Date: Mon, 26 Jul 2021 11:11:50 +0200 [thread overview]
Message-ID: <CAMuHMdX8vC-U6O5GVrppiDPBnKb+7xOt-DNQF6C7KMc=8TWxUQ@mail.gmail.com> (raw)
In-Reply-To: <CAK8P3a3bA2D6FXHEOdqaOCm=++0DudZmuPnR+GJvWpF0LmZtDQ@mail.gmail.com>
Hi Arnd,
On Mon, Jul 26, 2021 at 10:52 AM Arnd Bergmann <arnd@arndb.de> wrote:
> On Mon, Jul 26, 2021 at 10:39 AM Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > On Mon, Jul 26, 2021 at 10:21 AM Arnd Bergmann <arnd@arndb.de> wrote:
> > > >
> > > > e) either a valid pointer, NULL, or an error pointer
> > > >
> > > > The last pattern is seen with the various *get*_optional() functions.
> > >
> > > I would always consider those the exact bug that I meant with "because
> > > everyone gets those wrong". I think the idea of the "optional" functions is
> > > that you have two implementations b) and d) and pick one of them
> > > at compile time. To the caller this means either an error pointer or
> > > success, but checking for NULL is a bug in the caller, while conditionally
> > > returning NULL or ERR_PTR() would be a bug in the interface.
> >
> > e) is not for optional kernel features, but for optional hardware
> > functionality. So it is not known at compile time, but depends on
> > e.g. the DTB. See e.g. devm_clk_get_optional().
>
> Ah right, I forgot we had those as well. However, I suppose no amount
> of annotation is going to help with those, as far as the checker is concerned,
> I would just leave this as not annotated. At least with the clk API,
> the callers are not able to dereference the pointer because the definition
> of 'struct clk' is private to drivers/clk/clk.c.
And the clk API supports calling further clock ops with a NULL pointer,
which eases handling optional clocks.
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
next prev parent reply other threads:[~2021-07-26 9:12 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-23 19:10 Potential static analysis ideas Dan Carpenter
2021-07-24 13:33 ` Geert Uytterhoeven
2021-07-24 13:40 ` Julia Lawall
2021-07-24 14:08 ` Arnd Bergmann
2021-07-24 23:18 ` Laurent Pinchart
2021-07-24 23:45 ` NeilBrown
2021-07-26 7:25 ` Arnd Bergmann
2021-07-26 7:53 ` Geert Uytterhoeven
2021-07-26 8:20 ` Arnd Bergmann
2021-07-26 8:39 ` Geert Uytterhoeven
2021-07-26 8:52 ` Arnd Bergmann
2021-07-26 9:11 ` Geert Uytterhoeven [this message]
2021-07-26 8:55 ` Julia Lawall
2021-07-26 9:08 ` Hannes Reinecke
2021-07-26 9:16 ` Geert Uytterhoeven
2021-07-26 9:28 ` Julia Lawall
2021-07-26 9:35 ` Hannes Reinecke
2021-07-26 10:03 ` Julia Lawall
2021-07-26 17:54 ` James Bottomley
2021-07-26 18:16 ` Linus Torvalds
2021-07-26 21:53 ` NeilBrown
2021-07-26 18:31 ` Laurent Pinchart
2021-07-26 9:17 ` Dan Carpenter
2021-07-26 9:13 ` Dan Carpenter
2021-07-26 21:43 ` NeilBrown
2021-07-26 7:05 ` Dan Carpenter
2021-07-26 15:50 ` Paul E. McKenney
2021-07-27 9:38 ` Dan Carpenter
2021-07-27 9:50 ` Geert Uytterhoeven
2021-07-27 16:06 ` Paul E. McKenney
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='CAMuHMdX8vC-U6O5GVrppiDPBnKb+7xOt-DNQF6C7KMc=8TWxUQ@mail.gmail.com' \
--to=geert@linux-m68k.org \
--cc=arnd@arndb.de \
--cc=dan.carpenter@oracle.com \
--cc=julia.lawall@inria.fr \
--cc=ksummit@lists.linux.dev \
--cc=laurent.pinchart@ideasonboard.com \
--cc=neilb@suse.de \
/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 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).