linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* intended use of "safe"?
@ 2011-08-11 17:14 Ben Pfaff
  2011-08-12 17:47 ` Christopher Li
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Pfaff @ 2011-08-11 17:14 UTC (permalink / raw)
  To: linux-sparse

It looks like the sparse "safe" attribute warns about use of
"safe" values as conditional expressions.  It's not obvious to me
when I would find that useful.

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.

Thanks,

Ben.
-- 
Ben Pfaff 
http://benpfaff.org


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: intended use of "safe"?
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Li @ 2011-08-12 17:47 UTC (permalink / raw)
  To: blp; +Cc: linux-sparse

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.
--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: intended use of "safe"?
  2011-08-12 17:47 ` Christopher Li
@ 2011-08-12 17:58   ` Josh Triplett
  0 siblings, 0 replies; 3+ messages in thread
From: Josh Triplett @ 2011-08-12 17:58 UTC (permalink / raw)
  To: Christopher Li; +Cc: blp, linux-sparse

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-12 17:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).