mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 06:10:14 +01:00
platform: fix "-Wcast-align" warning on i686 in nmp_object_ref()
With gcc-12.2.1-4.fc37 on i686 we get:
./src/libnm-platform/nmp-object.h: In function 'nmp_object_ref':
./src/libnm-platform/nmp-object.h:626:12: error: cast increases required alignment of target type [-Werror=cast-align]
626 | return (const NMPObject *) nm_dedup_multi_obj_ref((const NMDedupMultiObj *) obj);
| ^
cc1: all warnings being treated as errors
Work around that be increasing the alignment of NMDedupMultiObj.
It has no downsides, because we usually put a NMDedupMultiObj in heap
allocated memory, which is already suitably aligned. Or we put it on
the stack, where wasting a few bytes for the alignment doesn't matter.
We basically never embed NMDedupMultiObj in an array where the increase
of alignment would waste additional space.
This commit is contained in:
parent
63b34ac78a
commit
052ed480a6
2 changed files with 4 additions and 2 deletions
|
|
@ -37,6 +37,8 @@ typedef enum _NMDedupMultiIdxMode {
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NMDedupMultiObj_Align (MAX(_nm_alignof(void *), _nm_alignof(gint64)))
|
||||
|
||||
struct _NMDedupMultiObj {
|
||||
union {
|
||||
NMObjBaseInst parent;
|
||||
|
|
@ -44,7 +46,7 @@ struct _NMDedupMultiObj {
|
|||
};
|
||||
NMDedupMultiIndex *_multi_idx;
|
||||
guint _ref_count;
|
||||
};
|
||||
} _nm_align(_NMDedupMultiObj_Align);
|
||||
|
||||
struct _NMDedupMultiObjClass {
|
||||
NMObjBaseClass parent;
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ struct _NMPObject {
|
|||
NMPlatformMptcpAddr mptcp_addr;
|
||||
NMPObjectMptcpAddr _mptcp_addr;
|
||||
};
|
||||
};
|
||||
} _nm_alignas(NMDedupMultiObj);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue