Re: [PATCH] man: explain role of unsigned long in casts from AS pointers.

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

 



On Fri, Mar 29, 2019 at 4:25 PM Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
>
> Sparse will warn on casts removing the address space of a pointer
> if the destination type is not unsigned long. But the special role
> of 'unsigned long' is not explained in the man page.

You might as well call it "uintptr_t".

And yes, that is the same as "unsigned long" in all sane
implementations, of course, and yes, the Linux kernel tends to prefer
just using "unsigned long" rather than made-up abstract types
internally.

But when explaining it outside of the Linux kernel context, I think
"uintptr_t" might be a bit more appropriate (perhaps with an "aka
unsigned long", since sparse itself internally also has the same "long
and pointer are basically the same - it's the register size" model).

The logic is that an "uintptr_t" cast isn't really a pointer cast,
it's a "get pointer value representation in an integer type" cast.
Which is address-space independent, which can be used as an
explanation of the logic.

                    Linus



[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