mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-09 20:30:20 +01:00
shared: propagate constness in _NM_GET_PRIVATE_PTR()
The _NM_GET_PRIVATE() macro already preserved and propagated
the constness of @self to the resulting private pointer.
_NM_GET_PRIVATE_PTR() didn't do that. Extend the macro,
to make that possible.
(cherry picked from commit bdfdabea51)
This commit is contained in:
parent
5d940b73fe
commit
5282469098
3 changed files with 31 additions and 5 deletions
|
|
@ -263,6 +263,13 @@ NM_G_ERROR_MSG (GError *error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#if (defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9 )))
|
||||
#define _NM_CC_SUPPORT_AUTO_TYPE 1
|
||||
#define _nm_auto_type __auto_type
|
||||
#else
|
||||
#define _NM_CC_SUPPORT_AUTO_TYPE 0
|
||||
#endif
|
||||
|
||||
#if (defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9 ))) || (defined (__clang__))
|
||||
#define _NM_CC_SUPPORT_GENERIC 1
|
||||
#else
|
||||
|
|
@ -372,6 +379,16 @@ NM_G_ERROR_MSG (GError *error)
|
|||
#define _NM_ENSURE_TYPE(type, value) (value)
|
||||
#endif
|
||||
|
||||
#if _NM_CC_SUPPORT_GENERIC
|
||||
#define NM_PROPAGATE_CONST(test_expr, ptr) \
|
||||
(_Generic ((test_expr), \
|
||||
const typeof (*(test_expr)) *: ((const typeof (*(ptr)) *) (ptr)), \
|
||||
default: (_Generic ((test_expr), \
|
||||
typeof (*(test_expr)) *: (ptr)))))
|
||||
#else
|
||||
#define NM_PROPAGATE_CONST(test_expr, ptr) (ptr)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NM_IN_SET_EVAL_1( op, _x, y) (_x == (y))
|
||||
|
|
@ -651,8 +668,17 @@ _notify (obj_type *obj, _PropertyEnums prop) \
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NM_GET_PRIVATE( self, type, is_check, ...) (&(NM_GOBJECT_CAST_NON_NULL (type, (self), is_check, ##__VA_ARGS__)->_priv))
|
||||
#define _NM_GET_PRIVATE_PTR( self, type, is_check, ...) ( (NM_GOBJECT_CAST_NON_NULL (type, (self), is_check, ##__VA_ARGS__)->_priv))
|
||||
#define _NM_GET_PRIVATE(self, type, is_check, ...) (&(NM_GOBJECT_CAST_NON_NULL (type, (self), is_check, ##__VA_ARGS__)->_priv))
|
||||
#if _NM_CC_SUPPORT_AUTO_TYPE
|
||||
#define _NM_GET_PRIVATE_PTR(self, type, is_check, ...) \
|
||||
({ \
|
||||
_nm_auto_type _self = NM_GOBJECT_CAST_NON_NULL (type, (self), is_check, ##__VA_ARGS__); \
|
||||
\
|
||||
NM_PROPAGATE_CONST (_self, _self->_priv); \
|
||||
})
|
||||
#else
|
||||
#define _NM_GET_PRIVATE_PTR(self, type, is_check, ...) (NM_GOBJECT_CAST_NON_NULL (type, (self), is_check, ##__VA_ARGS__)->_priv)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -1163,9 +1163,9 @@ nm_device_get_ip_iface (NMDevice *self)
|
|||
}
|
||||
|
||||
int
|
||||
nm_device_get_ip_ifindex (NMDevice *self)
|
||||
nm_device_get_ip_ifindex (const NMDevice *self)
|
||||
{
|
||||
NMDevicePrivate *priv;
|
||||
const NMDevicePrivate *priv;
|
||||
|
||||
g_return_val_if_fail (self != NULL, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ int nm_device_get_ifindex (NMDevice *dev);
|
|||
gboolean nm_device_is_software (NMDevice *dev);
|
||||
gboolean nm_device_is_real (NMDevice *dev);
|
||||
const char * nm_device_get_ip_iface (NMDevice *dev);
|
||||
int nm_device_get_ip_ifindex (NMDevice *dev);
|
||||
int nm_device_get_ip_ifindex (const NMDevice *dev);
|
||||
const char * nm_device_get_driver (NMDevice *dev);
|
||||
const char * nm_device_get_driver_version (NMDevice *dev);
|
||||
const char * nm_device_get_type_desc (NMDevice *dev);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue