From 464b51acdeb46620114a54ebf74f5feb39ebb55c Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Fri, 12 Aug 2022 10:18:05 +0000 Subject: [PATCH] dbus-internals: use size_t in _DBUS_ALIGN_VALUE() When targeting CHERI-enabled architectures such as Arm Morello, performing a bitwise and with uintptr_t values can result in an ambiguous operation compiler warning. Fix this warning by telling compiler which operand is (potentially) a pointer and which one is an integer by changing the boundary type to size_t. This change has no functional effect on other architectures but is required to build with -Werror for Morello. Example warning message: ``` warning: binary expression on capability types 'unsigned __intcap' and 'unsigned __intcap'; it is not clear which should be used as the source of provenance; currently provenance is inherited from the left-hand side [-Wcheri-provenance] _dbus_assert (_DBUS_ALIGN_VALUE (insert_at, 8) == (unsigned) insert_at); ``` --- dbus/dbus-internals.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index c7967d241..deee366f5 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -277,7 +277,8 @@ _dbus_assert_error_xor_bool (const DBusError *error, */ #define _DBUS_ALIGN_VALUE(this, boundary) \ - (( ((uintptr_t)(this)) + (((uintptr_t)(boundary)) -1)) & (~(((uintptr_t)(boundary))-1))) + ((((uintptr_t) (this)) + (((size_t) (boundary)) - 1)) & \ + (~(((size_t) (boundary)) - 1))) #define _DBUS_ALIGN_ADDRESS(this, boundary) \ ((void*)_DBUS_ALIGN_VALUE(this, boundary)) -- 2.47.3