summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-01-13 15:32:14 +0100
committerThomas Haller <thaller@redhat.com>2020-01-17 08:28:33 +0100
commitc678e459cfce306d44fa580e74c1e5652edfa2ea (patch)
treec84c02118b1c05cff55cbb5bc5a8f07df4b26371
parente3a3311f0ab72134fae609f0efde2ac5f070abfe (diff)
downloadNetworkManager-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.h13
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; \
})\
)