GSIZE_TO_POINTER(): appease stricter compilers

Some compilers (e.g. CHERI LLVM) warn when casting a non-intptr_t integer
type to a pointer. The GSIZE_TO_POINTER() macro thus triggers warnings
which can be silence by casting to guintptr before gpointer.

NB: This macro must not be used to create valid pointers from a integer.
This commit is contained in:
Alex Richardson 2022-12-14 23:55:17 +00:00
parent 8af4f494b1
commit 403f7a10dc

View File

@ -952,7 +952,7 @@
/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT
*/
#define GPOINTER_TO_SIZE(p) ((gsize) (p))
#define GSIZE_TO_POINTER(s) ((gpointer) (gsize) (s))
#define GSIZE_TO_POINTER(s) ((gpointer) (guintptr) (gsize) (s))
/* Provide convenience macros for handling structure
* fields through their offsets.