From a0b295590754b800d2b6a0e55e72425ca1bd24b0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 4 May 2020 18:09:32 +0200 Subject: [PATCH] shared: add NM_ENSURE_NOT_NULL() macro --- shared/nm-glib-aux/nm-macros-internal.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h index 8c0aa21820..637d62bb5d 100644 --- a/shared/nm-glib-aux/nm-macros-internal.h +++ b/shared/nm-glib-aux/nm-macros-internal.h @@ -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