mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-19 15:31:46 +01:00
glib-aux: make nm_gobject_notify_together_full() macro more robust
If __VA_ARGS__ contains odd arguments, it's not clear that N_ARG() gives
the same as the array initialization. Add a static assert that the
numbers agree to catch wrong usage of the macro.
For example:
nm_gobject_notify_together(setting, a, b, );
This commit is contained in:
parent
321b59e84b
commit
681926ad43
1 changed files with 10 additions and 4 deletions
|
|
@ -620,10 +620,16 @@ nm_str_realloc(char *str)
|
|||
/* invokes _notify() for all arguments (of type _PropertyEnums). Note, that if
|
||||
* there are more than one prop arguments, this will involve a freeze/thaw
|
||||
* of GObject property notifications. */
|
||||
#define nm_gobject_notify_together_full(suffix, obj, ...) \
|
||||
_nm_gobject_notify_together_impl##suffix(obj, \
|
||||
NM_NARG(__VA_ARGS__), \
|
||||
(const _PropertyEnums##suffix[]){__VA_ARGS__})
|
||||
#define nm_gobject_notify_together_full(suffix, obj, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
const _PropertyEnums##suffix _props[] = {__VA_ARGS__}; \
|
||||
\
|
||||
G_STATIC_ASSERT(G_N_ELEMENTS(_props) == NM_NARG(__VA_ARGS__)); \
|
||||
\
|
||||
_nm_gobject_notify_together_impl##suffix(obj, G_N_ELEMENTS(_props), _props); \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define nm_gobject_notify_together(obj, ...) nm_gobject_notify_together_full(, obj, __VA_ARGS__)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue