summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-02-22 21:19:18 +0100
committerThomas Haller <thaller@redhat.com>2022-03-13 12:02:08 +0100
commit6f948fcd2e651a3511f5d9d9f0e75581dcc33a6f (patch)
tree4f7924580c2b864c5b67723c406a60fe3c33eeba
parentde61722efe8a43c282004d4dcb8293fed037368a (diff)
core: use nm_dbus_manager_lookup_object_with_type()
I think this makes it clearer that we should always look for a certain type, because NMDBusManager tracks all D-Bus objects.
-rw-r--r--src/core/devices/wifi/nm-wifi-ap.c7
-rw-r--r--src/core/devices/wifi/nm-wifi-p2p-peer.c9
-rw-r--r--src/core/nm-checkpoint-manager.c9
-rw-r--r--src/core/nm-manager.c13
-rw-r--r--src/core/settings/nm-settings.c6
5 files changed, 27 insertions, 17 deletions
diff --git a/src/core/devices/wifi/nm-wifi-ap.c b/src/core/devices/wifi/nm-wifi-ap.c
index ac0b748a51..825a5aa8f1 100644
--- a/src/core/devices/wifi/nm-wifi-ap.c
+++ b/src/core/devices/wifi/nm-wifi-ap.c
@@ -1037,9 +1037,10 @@ nm_wifi_ap_lookup_for_device(NMDevice *device, const char *exported_path)
g_return_val_if_fail(NM_IS_DEVICE(device), NULL);
- ap = nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
- exported_path);
- if (!ap || !NM_IS_WIFI_AP(ap) || ap->wifi_device != device)
+ ap = nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
+ NM_TYPE_WIFI_AP,
+ exported_path);
+ if (!ap || ap->wifi_device != device)
return NULL;
return ap;
diff --git a/src/core/devices/wifi/nm-wifi-p2p-peer.c b/src/core/devices/wifi/nm-wifi-p2p-peer.c
index 0a17427067..8ccb2a4d5e 100644
--- a/src/core/devices/wifi/nm-wifi-p2p-peer.c
+++ b/src/core/devices/wifi/nm-wifi-p2p-peer.c
@@ -139,10 +139,11 @@ nm_wifi_p2p_peer_lookup_for_device(NMDevice *device, const char *exported_path)
g_return_val_if_fail(NM_IS_DEVICE(device), NULL);
- peer = (NMWifiP2PPeer *) nm_dbus_manager_lookup_object(
- nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
- exported_path);
- if (!peer || !NM_IS_WIFI_P2P_PEER(peer) || peer->wifi_device != device)
+ peer =
+ nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
+ NM_TYPE_WIFI_P2P_PEER,
+ exported_path);
+ if (!peer || peer->wifi_device != device)
return NULL;
return peer;
diff --git a/src/core/nm-checkpoint-manager.c b/src/core/nm-checkpoint-manager.c
index 4a3e7aafba..6c9ea2a634 100644
--- a/src/core/nm-checkpoint-manager.c
+++ b/src/core/nm-checkpoint-manager.c
@@ -259,10 +259,11 @@ nm_checkpoint_manager_lookup_by_path(NMCheckpointManager *self, const char *path
g_return_val_if_fail(self, NULL);
- checkpoint =
- nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(GET_MANAGER(self))),
- path);
- if (!checkpoint || !NM_IS_CHECKPOINT(checkpoint)) {
+ checkpoint = nm_dbus_manager_lookup_object_with_type(
+ nm_dbus_object_get_manager(NM_DBUS_OBJECT(GET_MANAGER(self))),
+ NM_TYPE_CHECKPOINT,
+ path);
+ if (!checkpoint) {
g_set_error(error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_INVALID_ARGUMENTS,
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
index c2a8f61350..88488befa0 100644
--- a/src/core/nm-manager.c
+++ b/src/core/nm-manager.c
@@ -1159,8 +1159,10 @@ active_connection_get_by_path(NMManager *self, const char *path)
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
NMActiveConnection *ac;
- ac = nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)), path);
- if (!ac || !NM_IS_ACTIVE_CONNECTION(ac) || c_list_is_empty(&ac->active_connections_lst))
+ ac = nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)),
+ NM_TYPE_ACTIVE_CONNECTION,
+ path);
+ if (!ac || c_list_is_empty(&ac->active_connections_lst))
return NULL;
nm_assert(c_list_contains(&priv->active_connections_lst_head, &ac->active_connections_lst));
@@ -1292,8 +1294,11 @@ nm_manager_get_device_by_path(NMManager *self, const char *path)
g_return_val_if_fail(path, NULL);
- device = nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)), path);
- if (!device || !NM_IS_DEVICE(device) || c_list_is_empty(&device->devices_lst))
+ device =
+ nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)),
+ NM_TYPE_DEVICE,
+ path);
+ if (!device || c_list_is_empty(&device->devices_lst))
return NULL;
nm_assert(c_list_contains(&priv->devices_lst_head, &device->devices_lst));
diff --git a/src/core/settings/nm-settings.c b/src/core/settings/nm-settings.c
index 6619d3e0a2..6589291131 100644
--- a/src/core/settings/nm-settings.c
+++ b/src/core/settings/nm-settings.c
@@ -3201,8 +3201,10 @@ nm_settings_get_connection_by_path(NMSettings *self, const char *path)
priv = NM_SETTINGS_GET_PRIVATE(self);
connection =
- nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)), path);
- if (!connection || !NM_IS_SETTINGS_CONNECTION(connection))
+ nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)),
+ NM_TYPE_SETTINGS_CONNECTION,
+ path);
+ if (!connection)
return NULL;
nm_assert(c_list_contains(&priv->connections_lst_head, &connection->_connections_lst));