platform: don't use static temporary cache_id
This only saves some typing at a few places. In general, avoid static variables, so drop it in favor of a stack-allocated cache_id.
This commit is contained in:
@@ -2740,9 +2740,13 @@ process_events (NMPlatform *platform)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define cache_lookup_all_objects(type, platform, obj_type, visible_only) \
|
#define cache_lookup_all_objects(type, platform, obj_type, visible_only) \
|
||||||
((const type *const*) nmp_cache_lookup_multi (NM_LINUX_PLATFORM_GET_PRIVATE ((platform))->cache, \
|
({ \
|
||||||
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, (obj_type), (visible_only)), \
|
NMPCacheId _cache_id; \
|
||||||
NULL))
|
\
|
||||||
|
((const type *const*) nmp_cache_lookup_multi (NM_LINUX_PLATFORM_GET_PRIVATE ((platform))->cache, \
|
||||||
|
nmp_cache_id_init_object_type (&_cache_id, (obj_type), (visible_only)), \
|
||||||
|
NULL)); \
|
||||||
|
})
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
@@ -3179,9 +3183,10 @@ static void
|
|||||||
cache_prune_candidates_record_all (NMPlatform *platform, NMPObjectType obj_type)
|
cache_prune_candidates_record_all (NMPlatform *platform, NMPObjectType obj_type)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
NMPCacheId cache_id;
|
||||||
|
|
||||||
priv->prune_candidates = nmp_cache_lookup_all_to_hash (priv->cache,
|
priv->prune_candidates = nmp_cache_lookup_all_to_hash (priv->cache,
|
||||||
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, obj_type, FALSE),
|
nmp_cache_id_init_object_type (&cache_id, obj_type, FALSE),
|
||||||
priv->prune_candidates);
|
priv->prune_candidates);
|
||||||
_LOGt ("cache-prune: record %s (now %u candidates)", nmp_class_from_type (obj_type)->obj_type_name,
|
_LOGt ("cache-prune: record %s (now %u candidates)", nmp_class_from_type (obj_type)->obj_type_name,
|
||||||
priv->prune_candidates ? g_hash_table_size (priv->prune_candidates) : 0);
|
priv->prune_candidates ? g_hash_table_size (priv->prune_candidates) : 0);
|
||||||
@@ -3809,10 +3814,11 @@ static GArray *
|
|||||||
link_get_all (NMPlatform *platform)
|
link_get_all (NMPlatform *platform)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
NMPCacheId cache_id;
|
||||||
|
|
||||||
return nmp_cache_lookup_multi_to_array (priv->cache,
|
return nmp_cache_lookup_multi_to_array (priv->cache,
|
||||||
NMP_OBJECT_TYPE_LINK,
|
NMP_OBJECT_TYPE_LINK,
|
||||||
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, NMP_OBJECT_TYPE_LINK, TRUE));
|
nmp_cache_id_init_object_type (&cache_id, NMP_OBJECT_TYPE_LINK, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const NMPlatformLink *
|
static const NMPlatformLink *
|
||||||
@@ -5545,12 +5551,13 @@ static GArray *
|
|||||||
ipx_address_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type)
|
ipx_address_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
NMPCacheId cache_id;
|
||||||
|
|
||||||
nm_assert (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP6_ADDRESS));
|
nm_assert (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP6_ADDRESS));
|
||||||
|
|
||||||
return nmp_cache_lookup_multi_to_array (priv->cache,
|
return nmp_cache_lookup_multi_to_array (priv->cache,
|
||||||
obj_type,
|
obj_type,
|
||||||
nmp_cache_id_init_addrroute_visible_by_ifindex (NMP_CACHE_ID_STATIC,
|
nmp_cache_id_init_addrroute_visible_by_ifindex (&cache_id,
|
||||||
obj_type,
|
obj_type,
|
||||||
ifindex));
|
ifindex));
|
||||||
}
|
}
|
||||||
|
@@ -1024,8 +1024,6 @@ nmp_cache_id_destroy (NMPCacheId *id)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
NMPCacheId _nmp_cache_id_static;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_nmp_cache_id_init (NMPCacheId *id, NMPCacheIdType id_type)
|
_nmp_cache_id_init (NMPCacheId *id, NMPCacheIdType id_type)
|
||||||
{
|
{
|
||||||
@@ -1364,7 +1362,9 @@ nmp_cache_link_connected_needs_toggle (const NMPCache *cache, const NMPObject *m
|
|||||||
&& potential_slave->link.connected) {
|
&& potential_slave->link.connected) {
|
||||||
is_lower_up = TRUE;
|
is_lower_up = TRUE;
|
||||||
} else {
|
} else {
|
||||||
links = (const NMPlatformLink *const *) nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, NMP_OBJECT_TYPE_LINK, FALSE), &len);
|
NMPCacheId cache_id;
|
||||||
|
|
||||||
|
links = (const NMPlatformLink *const *) nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (&cache_id, NMP_OBJECT_TYPE_LINK, FALSE), &len);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
const NMPlatformLink *link = links[i];
|
const NMPlatformLink *link = links[i];
|
||||||
const NMPObject *obj = NMP_OBJECT_UP_CAST ((NMPlatformObject *) link);
|
const NMPObject *obj = NMP_OBJECT_UP_CAST ((NMPlatformObject *) link);
|
||||||
|
@@ -137,9 +137,6 @@ struct _NMPCacheId {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NMPCacheId _nmp_cache_id_static;
|
|
||||||
#define NMP_CACHE_ID_STATIC (&_nmp_cache_id_static)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMPObjectType obj_type;
|
NMPObjectType obj_type;
|
||||||
int addr_family;
|
int addr_family;
|
||||||
|
Reference in New Issue
Block a user