diff options
author | Thomas Haller <thaller@redhat.com> | 2022-05-19 15:58:53 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-05-19 16:08:01 +0200 |
commit | 835554a4dba8638dc6f837a74719ed175f8f52c7 (patch) | |
tree | aa71ed73c70103c00c41e8643da34a424f17cda6 | |
parent | 705e776776ad38d5765c626a0729413eda9ac604 (diff) | |
download | NetworkManager-835554a4dba8638dc6f837a74719ed175f8f52c7.tar.gz |
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.
-rw-r--r-- | src/libnm-glib-aux/nm-shared-utils.c | 3 | ||||
-rw-r--r-- | src/libnm-glib-aux/tests/test-shared-general.c | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c index f7ee4caeaa..67a4d58852 100644 --- a/src/libnm-glib-aux/nm-shared-utils.c +++ b/src/libnm-glib-aux/nm-shared-utils.c @@ -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)); /*****************************************************************************/ diff --git a/src/libnm-glib-aux/tests/test-shared-general.c b/src/libnm-glib-aux/tests/test-shared-general.c index 5e9310f5ac..a5ef62f2ec 100644 --- a/src/libnm-glib-aux/tests/test-shared-general.c +++ b/src/libnm-glib-aux/tests/test-shared-general.c @@ -24,10 +24,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)); /*****************************************************************************/ |