We need to be able to cast from virObjectEventPtr to one of its many subclasses. Some of these subclasses have 8 byte alignment on 32-bit platforms, but virObjectEventPtr only has 4 byte alignment. Previously the virObject base class had 8 byte alignment but this dropped to 4 byte when converted to inherit from GObject. This introduces cast alignment warnings on 32-bit: ../../src/conf/domain_event.c: In function 'virDomainEventDispatchDefaultFunc': ../../src/conf/domain_event.c:1656:30: error: cast increases required alignment of target type [-Werror=cast-align] 1656 | rtcChangeEvent = (virDomainEventRTCChangePtr)event; | ^ ../../src/conf/domain_event.c:1785:34: error: cast increases required alignment of target type [-Werror=cast-align] 1785 | balloonChangeEvent = (virDomainEventBalloonChangePtr)event; | ^ ../../src/conf/domain_event.c:1896:35: error: cast increases required alignment of target type [-Werror=cast-align] 1896 | blockThresholdEvent = (virDomainEventBlockThresholdPtr)event; | ^ ../../src/conf/domain_event.c: In function 'virDomainQemuMonitorEventDispatchFunc': ../../src/conf/domain_event.c:1974:24: error: cast increases required alignment of target type [-Werror=cast-align] 1974 | qemuMonitorEvent = (virDomainQemuMonitorEventPtr)event; | ^ ../../src/conf/domain_event.c: In function 'virDomainQemuMonitorEventFilter': ../../src/conf/domain_event.c:2179:20: error: cast increases required alignment of target type [-Werror=cast-align] 2179 | monitorEvent = (virDomainQemuMonitorEventPtr) event; | ^ Forcing 8-byte alignment on virObjectEventPtr removes the alignment increase during casts to subclasses. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- Technically a build-breaker, but since we don't have any existing usage of __attribute__((aligned)), I wanted to get a second opinion on this approach. One alternative approach would be to switch one of the current "int" fields in virObjectEvent to "long long". src/conf/object_event_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/object_event_private.h b/src/conf/object_event_private.h index b31441c53a..126464a9a5 100644 --- a/src/conf/object_event_private.h +++ b/src/conf/object_event_private.h @@ -42,7 +42,7 @@ typedef void virConnectObjectEventGenericCallback cb, void *cbopaque); -struct _virObjectEvent { +struct __attribute__((aligned(4))) _virObjectEvent { virObject parent; int eventID; virObjectMeta meta; -- 2.24.1