Skip to content

Commit

Permalink
man: explain role of uintptr_t & unsigned long in casts from AS pointers
Browse files Browse the repository at this point in the history
Sparse will warn on casts removing the address space of a pointer
if the destination type is not uintptr_t or unsigned long. But the
special role of these 2 types is not explained in the man page.

So, add an explanation for them in the description of -Waddress-space.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
  • Loading branch information
lucvoo committed Mar 30, 2019
1 parent b3daa62 commit c4c9935
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions sparse.1
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ Sparse allows an extended attribute
on pointers, which designates a pointer target in address space \fIid\fR (an
identifier or a constant integer).
With \fB\-Waddress\-space\fR, Sparse treats pointers with
identical target types but different address spaces as distinct types. To
override this warning, such as for functions which convert pointers between
address spaces, use a type that includes \fB__attribute__((force))\fR.
identical target types but different address spaces as distinct types and
will warn accordingly.

Sparse will also warn on casts which remove the address space (casts to an
integer type or to a plain pointer type). An exception to this is when the
destination type is \fBuintptr_t\fR (or \fBunsigned long\fR) since such casts
are often used to "get a pointer value representation in an integer type" and
such values are independent of the address space.

To override these warnings, use a type that includes \fB__attribute__((force))\fR.

Sparse issues these warnings by default. To turn them off, use
\fB\-Wno\-address\-space\fR.
Expand Down

0 comments on commit c4c9935

Please sign in to comment.