Skip to content

Cast via uintptr_t when converting between integers and pointers

Alex Richardson requested to merge arichardson/kwin:intptr-casts into master

When casting from integer to pointer, promoting the integer to (u)intptr_t will ensure that the resulting type can be converted to a pointer without problems. These two casts changed in this commit trigger a warning when building for CHERI-enabled architectures such as Arm Morello. This is not just limited to CHERI, the cast from xcb_pixmap_t (uint32_t) to void* should also be flagged by -Wint-to-void-pointer-cast when using Clang, however, it appears that warning only handles C-style casts, and not reinterpret_cast (https://github.com/llvm/llvm-project/issues/53964).

Merge request reports