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.
This commit is contained in:
Thomas Haller 2020-01-13 15:32:14 +01:00
parent 0cb0ee0482
commit 86787e0278

View file

@ -180,15 +180,14 @@ void nm_device_commit_mtu (NMDevice *self);
((NM_NARG (__VA_ARGS__) == 0) \ ((NM_NARG (__VA_ARGS__) == 0) \
? NULL \ ? NULL \
: ({ \ : ({ \
static const struct { \ const NMLinkType _types[NM_NARG (__VA_ARGS__) + 1] = { \
const NMLinkType types[NM_NARG (__VA_ARGS__)]; \ __VA_ARGS__ \
const NMLinkType sentinel; \ _NM_MACRO_COMMA_IF_ARGS (__VA_ARGS__) \
} _link_types = { \ NM_LINK_TYPE_NONE, \
.types = { __VA_ARGS__ }, \
.sentinel = NM_LINK_TYPE_NONE, \
}; \ }; \
\ \
_link_types.types; \ nm_assert (_types[NM_NARG (__VA_ARGS__)] == NM_LINK_TYPE_NONE); \
_types; \
})\ })\
) )