[Fontconfig] fontconfig: Branch 'main'
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 20 06:27:53 UTC 2021
src/fcint.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit ab4761ff8718ce252b4f625a979e0430658a8330
Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
Date: Mon Jul 12 15:06:32 2021 +0100
fcint: add casts to allow building with stricter compilers
When targeting CHERI, casts between pointers and integers must use
(u)intptr_t. uintptr_t values contains pointer bounds (and additional
metadata), whereas other integer types do not. This change also adds a
cast to FcOffsetToPtr() to silence a compiler warning that triggers if
the compiler cannot statically infer which side of an arithmetic operation
is the pointer operand and which one is the offset/mask.
diff --git a/src/fcint.h b/src/fcint.h
index 612287f..f7141c1 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -152,16 +152,16 @@ FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int));
#define FcIsEncodedOffset(p) ((((intptr_t) (p)) & 1) != 0)
/* Encode offset in a pointer of type t */
-#define FcOffsetEncode(o,t) ((t *) ((o) | 1))
+#define FcOffsetEncode(o,t) ((t *) (intptr_t) ((o) | 1))
/* Decode a pointer into an offset */
#define FcOffsetDecode(p) (((intptr_t) (p)) & ~1)
/* Compute pointer offset */
-#define FcPtrToOffset(b,p) ((intptr_t) (p) - (intptr_t) (b))
+#define FcPtrToOffset(b,p) ((ptrdiff_t) ((intptr_t) (p) - (intptr_t) (b)))
/* Given base address, offset and type, return a pointer */
-#define FcOffsetToPtr(b,o,t) ((t *) ((intptr_t) (b) + (o)))
+#define FcOffsetToPtr(b,o,t) ((t *) ((intptr_t) (b) + (ptrdiff_t) (o)))
/* Given base address, encoded offset and type, return a pointer */
#define FcEncodedOffsetToPtr(b,p,t) FcOffsetToPtr(b,FcOffsetDecode(p),t)
More information about the Fontconfig
mailing list