From Linux PARISC Wiki
Jump to: navigation, search

Sparse is a tool to do compile-time checks on C code. Sparse can create a parse tree of C code, similar to a GCC frontend. Using this parse tree, it is possible to create additional compile-time checks of source code, in addition to what regular C provides.

For example, a system call can be passed a userspace pointer. In regular C, this will simply be a void *. However, the kernel cannot directly dereference this pointer. There is no syntax to denote this restriction in regular C, and if a kernel developer makes a mistake, s/he will only discover it at runtime, probably in the form of a kernel crash. Sparse allows a developer to encode this restriction by annotating the pointer as void __user *, where __user denotes a separate address space.

There are currently three address spaces recognized by the kernel:

  • User address space, annotated with __user
  • Kernel address space, no annotation
  • I/O memory address space, annotated with __iomem

These are defined in include/linux/compiler.h

More information about sparse can be found at and The sparse mailing list is at

The sparse source code is kept in BitKeeper at bk://, snapshots can be found at

Personal tools