Re: intended use of "safe"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx>
> 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux