+static inline bpfptr_t make_bpfptr_fixed(__kernel_aligned_uintptr_t
ptr, bool is_kernel)
+{
+ if (is_kernel)
+ return KERNEL_BPFPTR((void *) (uintptr_t) ptr);
a cast to (void *) should be sufficient without going through uintptr_t
now.
That results in a CToPtr warning for me:
./include/linux/bpfptr.h:37:24: warning: the following conversion will
result in a CToPtr operation; the behaviour of CToPtr can be confusing
since using CToPtr on an untagged capability will give 0 instead of the
integer value and should therefore be explicitly annotated [-Wcher
i-pointer-conversion]
For PCuABI __kernel_aligned_uintptr_t is __uintcap_t (128b), void* is
64b and uintptr_t should be u64.
I guess the warning here is erroneous since in this code path, in theory
it should be the kernel calling this with a 64b kernel ptr, so ptr
should contain a 64b integer representation in __uintcap_t
(__kernel_uintptr_t), with nothing in the top bits.
Explicit cast to uintptr_t then tells the compiler there is no chance
this __uintcap_t contains a capability so no CToPtr warning. I'm not
sure exactly. Would be interested if anyone understands that differently.