mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-09 15:50:26 +01:00
glib-aux: ensure alignment for nm_ether_addr_zero
In practice, this does not cause an issue, because NMEtherAddr quite
quite obviously only contains uint8 values and has alignment 1.
It's still ugly to case nm_ip_addr_zero to NMEtherAddr if they are
entirely unrelated types.
Fixes: 58e2ba0535 ('glib-aux: drop ethernet fields from NMIPAddr union')
This commit is contained in:
parent
f2f23a0f26
commit
d960ef823d
2 changed files with 6 additions and 1 deletions
|
|
@ -8,6 +8,11 @@ typedef union _NMIPAddr {
|
|||
in_addr_t addr4;
|
||||
struct in_addr addr4_struct;
|
||||
struct in6_addr addr6;
|
||||
|
||||
/* This union field only exists, so that it's guaranteed that NMIPAddr has
|
||||
* a suitable alignment. We use that with nm_ether_addr_zero macro, that
|
||||
* aliases nm_ip_addr_zero. */
|
||||
NMEtherAddr _ether_addr;
|
||||
} NMIPAddr;
|
||||
|
||||
#define NM_IP_ADDR_INIT \
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ extern const union _NMIPAddr nm_ip_addr_zero;
|
|||
|
||||
/* Let's reuse nm_ip_addr_zero also for nm_ether_addr_zero. It's a union that
|
||||
* also contains a NMEtherAddr field. */
|
||||
#define nm_ether_addr_zero (*((const NMEtherAddr *) ((gconstpointer) &nm_ip_addr_zero)))
|
||||
#define nm_ether_addr_zero (*((const NMEtherAddr *) &nm_ip_addr_zero))
|
||||
|
||||
static inline int
|
||||
nm_ether_addr_cmp(const NMEtherAddr *a, const NMEtherAddr *b)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue