diff options
author | Thomas Haller <thaller@redhat.com> | 2020-01-13 15:32:14 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-01-17 08:28:33 +0100 |
commit | c678e459cfce306d44fa580e74c1e5652edfa2ea (patch) | |
tree | c84c02118b1c05cff55cbb5bc5a8f07df4b26371 | |
parent | e3a3311f0ab72134fae609f0efde2ac5f070abfe (diff) | |
download | NetworkManager-th/macro-narg-cleanup.tar.gz |
core: improve implementation of NM_DEVICE_DEFINE_LINK_TYPES() macroth/macro-narg-cleanup
I think it's technically not correct to rely on the "sentinal" field
being immediately after the previous field, due to alignment. Implement
the macro differently.
-rw-r--r-- | src/devices/nm-device-private.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index e87733ef3f..2e33d8a4a7 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -180,15 +180,14 @@ void nm_device_commit_mtu (NMDevice *self); ((NM_NARG (__VA_ARGS__) == 0) \ ? NULL \ : ({ \ - static const struct { \ - const NMLinkType types[NM_NARG (__VA_ARGS__)]; \ - const NMLinkType sentinel; \ - } _link_types = { \ - .types = { __VA_ARGS__ }, \ - .sentinel = NM_LINK_TYPE_NONE, \ + const NMLinkType _types[NM_NARG (__VA_ARGS__) + 1] = { \ + __VA_ARGS__ \ + _NM_MACRO_COMMA_IF_ARGS (__VA_ARGS__) \ + NM_LINK_TYPE_NONE, \ }; \ \ - _link_types.types; \ + nm_assert (_types[NM_NARG (__VA_ARGS__)] == NM_LINK_TYPE_NONE); \ + _types; \ })\ ) |