diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index e1569cdbab..5301436855 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -17891,7 +17891,7 @@ dispose(GObject *object) priv->sriov.next = NULL; } - g_clear_object(&priv->l3cfg); + g_clear_object(&priv->l3cfg_); g_clear_object(&priv->l3ipdata_4.ip_config); g_clear_object(&priv->l3ipdata_6.ip_config); diff --git a/src/libnm-glib-aux/nm-glib.h b/src/libnm-glib-aux/nm-glib.h index 2dc86d7b4e..0436d13554 100644 --- a/src/libnm-glib-aux/nm-glib.h +++ b/src/libnm-glib-aux/nm-glib.h @@ -45,28 +45,40 @@ __g_type_ensure(GType type) /*****************************************************************************/ -#if !GLIB_CHECK_VERSION(2, 34, 0) +/* glib 2.58+ defines an improved, type-safe variant of g_clear_pointer(). Reimplement + * that. + * + * Note that we also have nm_clear_pointer() which is similar to g_clear_pointer() + * and also preferred throughout. However, we do use g_clear_object(), which is + * implemented via g_clear_pointer(). So while there are no immediate users of + * g_clear_pointer() (use nm_clear_pointer() instead), there are indirect users + * via g_clear_object(). + * + * Anyway. So the glib 2.58+ version of g_clear_pointer() is only used if GLIB_VERSION_MAX_ALLOWED + * is set, which we don't do. + * + * To get the type-safe variant, reimplement g_clear_pointer() below. This aims to + * be identical to the version of the macro in glib 2.58. + * + * Still, don't use g_clear_pointer() directly (use nm_clear_pointer()). This compat + * implementation exists only for g_clear_object(). + */ +#undef g_clear_pointer -#define g_clear_pointer(pp, destroy) \ - G_STMT_START \ - { \ - G_STATIC_ASSERT(sizeof *(pp) == sizeof(gpointer)); \ - /* Only one access, please */ \ - gpointer *_pp = (gpointer *) (pp); \ - gpointer _p; \ - /* This assignment is needed to avoid a gcc warning */ \ - GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ - \ - _p = *_pp; \ - if (_p) { \ - *_pp = NULL; \ - _destroy(_p); \ - } \ - } \ +#define g_clear_pointer(pp, destroy) \ + G_STMT_START \ + { \ + typeof((pp)) _pp = (pp); \ + typeof(*_pp) _ptr = *_pp; \ + \ + G_STATIC_ASSERT(sizeof *(pp) == sizeof(gpointer)); \ + \ + *_pp = NULL; \ + if (_ptr) \ + (destroy)(_ptr); \ + } \ G_STMT_END -#endif - /*****************************************************************************/ #if !GLIB_CHECK_VERSION(2, 34, 0)