From c678e459cfce306d44fa580e74c1e5652edfa2ea Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 13 Jan 2020 15:32:14 +0100 Subject: core: improve implementation of NM_DEVICE_DEFINE_LINK_TYPES() macro 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. --- src/devices/nm-device-private.h | 13 ++++++------- 1 file 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; \ })\ ) -- cgit v1.2.1