summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-12-01 10:56:09 +0100
committerThomas Haller <thaller@redhat.com>2016-12-01 10:57:35 +0100
commitce2d1f062b4e376e8e424985da3a1abdc9d6daeb (patch)
treee45e6c6b43a99689820da3ad52da81fa411c00d3
parentfde46d7e65af555963920873a975f87e715839ef (diff)
downloadNetworkManager-ce2d1f062b4e376e8e424985da3a1abdc9d6daeb.tar.gz
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.
-rw-r--r--src/platform/nm-linux-platform.c19
-rw-r--r--src/platform/nmp-object.c6
-rw-r--r--src/platform/nmp-object.h3
3 files changed, 16 insertions, 12 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index e41a639a30..c2404e13c4 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -2740,9 +2740,13 @@ process_events (NMPlatform *platform)
/*****************************************************************************/
#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)), \
- NULL))
+ ({ \
+ NMPCacheId _cache_id; \
+ \
+ ((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)
{
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
+ NMPCacheId cache_id;
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);
_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);
@@ -3809,10 +3814,11 @@ static GArray *
link_get_all (NMPlatform *platform)
{
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
+ NMPCacheId cache_id;
return nmp_cache_lookup_multi_to_array (priv->cache,
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 *
@@ -5545,12 +5551,13 @@ static GArray *
ipx_address_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type)
{
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));
return nmp_cache_lookup_multi_to_array (priv->cache,
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,
ifindex));
}
diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c
index 48cec7bf74..936c41f270 100644
--- a/src/platform/nmp-object.c
+++ b/src/platform/nmp-object.c
@@ -1024,8 +1024,6 @@ nmp_cache_id_destroy (NMPCacheId *id)
/*****************************************************************************/
-NMPCacheId _nmp_cache_id_static;
-
static void
_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) {
is_lower_up = TRUE;
} 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++) {
const NMPlatformLink *link = links[i];
const NMPObject *obj = NMP_OBJECT_UP_CAST ((NMPlatformObject *) link);
diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h
index b6d6709c4e..664f9b53ee 100644
--- a/src/platform/nmp-object.h
+++ b/src/platform/nmp-object.h
@@ -137,9 +137,6 @@ struct _NMPCacheId {
};
};
-extern NMPCacheId _nmp_cache_id_static;
-#define NMP_CACHE_ID_STATIC (&_nmp_cache_id_static)
-
typedef struct {
NMPObjectType obj_type;
int addr_family;