shared: add NM_ENSURE_NOT_NULL() macro

This commit is contained in:
Thomas Haller 2020-05-04 18:09:32 +02:00
parent 6e9967939b
commit a0b2955907
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -630,6 +630,14 @@ NM_G_ERROR_MSG (GError *error)
NM_CONSTCAST_FULL (type, (obj), _obj, GObject, ##__VA_ARGS__); \
})
#define NM_ENSURE_NOT_NULL(ptr) \
({ \
typeof (ptr) _ptr = (ptr); \
\
nm_assert (_ptr != NULL); \
_ptr; \
})
#if _NM_CC_SUPPORT_GENERIC
/* returns @value, if the type of @value matches @type.
* This requires support for C11 _Generic(). If no support is