config: remove unused NMConfig self argument from nm_config_device_state_*() API

nm_config_device_state_*() always access the file system directly,
they don't cache data in NMConfig. Hence, they don't use the
@self argument.

Maybe those functions don't belong to nm-config.h, anyway. For lack
of a better place they are there.

(cherry picked from commit 1940be410c)
This commit is contained in:
Thomas Haller 2017-04-19 15:45:31 +02:00
parent d4c8a3fbf2
commit cd92ee58a6
4 changed files with 10 additions and 21 deletions

View file

@ -12997,7 +12997,7 @@ nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze)
{
gs_free NMConfigDeviceStateData *dev_state = NULL;
dev_state = nm_config_device_state_load (nm_config_get (), ifindex);
dev_state = nm_config_device_state_load (ifindex);
if ( dev_state
&& dev_state->perm_hw_addr_fake
&& nm_utils_hwaddr_aton (dev_state->perm_hw_addr_fake, buf, priv->hw_addr_len)

View file

@ -1926,15 +1926,13 @@ _config_device_state_data_new (int ifindex, GKeyFile *kf)
/**
* nm_config_device_state_load:
* @self: the NMConfig instance
* @ifindex: the ifindex for which the state is to load
*
* Returns: (transfer full): a run state object.
* Must be freed with g_free().
*/
NMConfigDeviceStateData *
nm_config_device_state_load (NMConfig *self,
int ifindex)
nm_config_device_state_load (int ifindex)
{
NMConfigDeviceStateData *device_state;
char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60];
@ -1972,8 +1970,7 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_device_state_managed_type_to_str, NMConfigDe
);
gboolean
nm_config_device_state_write (NMConfig *self,
int ifindex,
nm_config_device_state_write (int ifindex,
NMConfigDeviceStateManagedType managed,
const char *perm_hw_addr_fake,
const char *connection_uuid)
@ -1982,7 +1979,6 @@ nm_config_device_state_write (NMConfig *self,
GError *local = NULL;
gs_unref_keyfile GKeyFile *kf = NULL;
g_return_val_if_fail (NM_IS_CONFIG (self), FALSE);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (!connection_uuid || *connection_uuid, FALSE);
g_return_val_if_fail (managed == NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED || !connection_uuid, FALSE);
@ -2027,8 +2023,7 @@ nm_config_device_state_write (NMConfig *self,
}
void
nm_config_device_state_prune_unseen (NMConfig *self,
GHashTable *seen_ifindexes)
nm_config_device_state_prune_unseen (GHashTable *seen_ifindexes)
{
GDir *dir;
const char *fn;

View file

@ -204,14 +204,12 @@ struct _NMConfigDeviceStateData {
const char *perm_hw_addr_fake;
};
NMConfigDeviceStateData *nm_config_device_state_load (NMConfig *self,
int ifindex);
gboolean nm_config_device_state_write (NMConfig *self,
int ifindex,
NMConfigDeviceStateData *nm_config_device_state_load (int ifindex);
gboolean nm_config_device_state_write (int ifindex,
NMConfigDeviceStateManagedType managed,
const char *perm_hw_addr_fake,
const char *connection_uuid);
void nm_config_device_state_prune_unseen (NMConfig *self, GHashTable *seen_ifindexes);
void nm_config_device_state_prune_unseen (GHashTable *seen_ifindexes);
/*****************************************************************************/

View file

@ -2404,7 +2404,6 @@ platform_link_cb (NMPlatform *platform,
static void
platform_query_devices (NMManager *self)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
GArray *links_array;
NMPlatformLink *links;
int i;
@ -2414,8 +2413,7 @@ platform_query_devices (NMManager *self)
for (i = 0; i < links_array->len; i++) {
gs_free NMConfigDeviceStateData *dev_state = NULL;
dev_state = nm_config_device_state_load (priv->config,
links[i].ifindex);
dev_state = nm_config_device_state_load (links[i].ifindex);
platform_link_added (self,
links[i].ifindex,
@ -4976,16 +4974,14 @@ nm_manager_write_device_state (NMManager *self)
if (perm_hw_addr_fake && !perm_hw_addr_is_fake)
perm_hw_addr_fake = NULL;
if (nm_config_device_state_write (priv->config,
ifindex,
if (nm_config_device_state_write (ifindex,
managed_type,
perm_hw_addr_fake,
uuid))
g_hash_table_add (seen_ifindexes, GINT_TO_POINTER (ifindex));
}
nm_config_device_state_prune_unseen (priv->config,
seen_ifindexes);
nm_config_device_state_prune_unseen (seen_ifindexes);
}
static gboolean