diff options
author | Thomas Haller <thaller@redhat.com> | 2015-12-21 10:55:38 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-12-26 16:43:49 +0100 |
commit | bdfcf02da3b268798e45608df96697ed899760fa (patch) | |
tree | 495af6409e8ef9a78111bceebbaf9df2cf0ef938 /shared/nm-test-libnm-utils.h | |
parent | f354d5f0fcf1515cd484350e0ba9cea23d676f96 (diff) | |
download | NetworkManager-bdfcf02da3b268798e45608df96697ed899760fa.tar.gz |
libnm/tests: add NMTSTC_SERVICE_INFO_SETUP() macro
Diffstat (limited to 'shared/nm-test-libnm-utils.h')
-rw-r--r-- | shared/nm-test-libnm-utils.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/shared/nm-test-libnm-utils.h b/shared/nm-test-libnm-utils.h index 667ba90db6..290feea2e4 100644 --- a/shared/nm-test-libnm-utils.h +++ b/shared/nm-test-libnm-utils.h @@ -22,6 +22,8 @@ #include "nm-test-utils.h" +/*****************************************************************************/ + typedef struct { GDBusConnection *bus; GDBusProxy *proxy; @@ -32,6 +34,21 @@ typedef struct { NMTstcServiceInfo *nmtstc_service_init (void); void nmtstc_service_cleanup (NMTstcServiceInfo *info); +static inline void _nmtstc_auto_service_cleanup (NMTstcServiceInfo **info) +{ + if (info && *info) { + nmtstc_service_cleanup (*info); + *info = NULL; + } +} + +#define NMTSTC_SERVICE_INFO_SETUP(sinfo) \ + NM_PRAGMA_WARNING_DISABLE ("-Wunused-variable") \ + __attribute__ ((cleanup(_nmtstc_auto_service_cleanup))) NMTstcServiceInfo *sinfo = nmtstc_service_init (); \ + NM_PRAGMA_WARNING_REENABLE + +/*****************************************************************************/ + #if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB) NMDevice *nmtstc_service_add_device (NMTstcServiceInfo *info, |