Typecasting a void pointer to unsigned long in zsmalloc.c
Greg KH
greg at kroah.com
Thu Jan 23 13:23:33 EST 2025
On Thu, Jan 23, 2025 at 05:58:10PM +0000, Alex Hogen wrote:
> >> Shouldn't there be a special type for doing this type of conversion?
>
> > That type is "unsigned long" :)
>
> Wouldn't "uintptr_t" be a more explicit type for storing pointer addresses as integers? It seems to me it has the advantage of expressing intent better for us human readers. See <linux/types.h>. Yes, it is currently defined as an "unsigned long."
"unitptr_t" came years, if not decades, after the policy of "a pointer
fits into an unsigned long" was the rule (i.e. from the very first
release of Linux.
And those crazy _t types are for userspace code, don't use them in the
kernel, there's no need.
thanks,
greg k-h
More information about the Kernelnewbies
mailing list