glib-aux/tests: fix and extend static assertions for NMIPAddr alignment

On m68k, integers are 2-byte aligned. Hence the assertion was wrong.

What we really want to check, is that NMIPAddr has not a smaller
alignment than in_addr_t and similar.

While at it, also assert the alignment for NMEtherAddr.

(cherry picked from commit 835554a4db)
This commit is contained in:
Thomas Haller 2022-05-19 15:58:53 +02:00
parent 6169ad5930
commit d1d91a91f4
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 7 additions and 4 deletions

View file

@ -133,6 +133,9 @@ nm_ip_addr_set_from_variant(int addr_family, gpointer dst, GVariant *variant, in
G_STATIC_ASSERT(ETH_ALEN == sizeof(struct ether_addr));
G_STATIC_ASSERT(ETH_ALEN == 6);
G_STATIC_ASSERT(ETH_ALEN == sizeof(NMEtherAddr));
G_STATIC_ASSERT(_nm_alignof(struct ether_addr) <= _nm_alignof(NMEtherAddr));
/*****************************************************************************/

View file

@ -23,10 +23,10 @@ G_STATIC_ASSERT(NM_AF_INET_SIZE == sizeof(in_addr_t));
G_STATIC_ASSERT(NM_AF_INET_SIZE == sizeof(struct in_addr));
G_STATIC_ASSERT(NM_AF_INET6_SIZE == sizeof(struct in6_addr));
G_STATIC_ASSERT(4 == _nm_alignof(in_addr_t));
G_STATIC_ASSERT(4 == _nm_alignof(struct in_addr));
G_STATIC_ASSERT(4 == _nm_alignof(struct in6_addr));
G_STATIC_ASSERT(4 == _nm_alignof(NMIPAddr));
G_STATIC_ASSERT(_nm_alignof(in_addr_t) <= _nm_alignof(NMIPAddr));
G_STATIC_ASSERT(_nm_alignof(struct in_addr) <= _nm_alignof(NMIPAddr));
G_STATIC_ASSERT(_nm_alignof(struct in6_addr) <= _nm_alignof(NMIPAddr));
G_STATIC_ASSERT(_nm_alignof(NMEtherAddr) <= _nm_alignof(NMIPAddr));
/*****************************************************************************/