linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: Christopher Li <sparse@chrisli.org>
Cc: blp@cs.stanford.edu, linux-sparse@vger.kernel.org
Subject: Re: intended use of "safe"?
Date: Fri, 12 Aug 2011 10:58:35 -0700	[thread overview]
Message-ID: <20110812175835.GA1735@leaf> (raw)
In-Reply-To: <CANeU7Qn25EWmDFuQRhr2_txEhF9hguh=SMUJnNYjLPnCR2MDNg@mail.gmail.com>

On Fri, Aug 12, 2011 at 10:47:11AM -0700, Christopher Li wrote:
> On Thu, Aug 11, 2011 at 10:14 AM, Ben Pfaff <blp@cs.stanford.edu> wrote:
> > What is the intended use of the sparse "safe" attribute?  I do
> > not see any uses of it in Linux (although there is a __safe macro
> > for it).  I don't see any documentation for it either.
> 
> I don't know much about the safe attribute either. I find out the
> commit which introduce the safe attribute by "git blame".
> 
> If a pointer is never NULL, there is not need to test the pointer.
> 
> Chris
> 
> commit 98f14350c26518f0f5c45632d145a218d468d8b8
> Author: Linus Torvalds <torvalds@ppc970.osdl.org>
> Date:   Fri Apr 16 18:19:30 2004 -0700
> 
>     Introduce "safe" pointer expressions.
> 
>     These are defined to never be NULL or nontrapping, and could
>     help code generation, but right now only cause a warning if
>     they are tested in a conditional.

That does actually seem useful.  The Linux kernel has various structures
with pointers that should never be NULL, and documenting that in a
compiler-visible way seems like a feature.

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2011-08-12 17:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-11 17:14 intended use of "safe"? Ben Pfaff
2011-08-12 17:47 ` Christopher Li
2011-08-12 17:58   ` Josh Triplett [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=20110812175835.GA1735@leaf \
    --to=josh@joshtriplett.org \
    --cc=blp@cs.stanford.edu \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.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 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).