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) \
? 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; \
})\
)