libnm: minor refactoring by using g_clear_object() and nm_str_not_empty()

This commit is contained in:
Thomas Haller
2016-10-12 19:49:46 +02:00
parent c4198d45e3
commit 21d7aa9204
2 changed files with 4 additions and 18 deletions

View File

@@ -520,10 +520,7 @@ clean_up_aps (NMDeviceWifi *self, gboolean in_dispose)
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
if (priv->active_ap) {
g_object_unref (priv->active_ap);
priv->active_ap = NULL;
}
g_clear_object (&priv->active_ap);
aps = priv->aps;
@@ -722,10 +719,7 @@ state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
case NM_DEVICE_STATE_DISCONNECTED:
case NM_DEVICE_STATE_FAILED:
/* Just clear active AP; don't clear the AP list unless wireless is disabled completely */
if (priv->active_ap) {
g_object_unref (priv->active_ap);
priv->active_ap = NULL;
}
g_clear_object (&priv->active_ap);
_nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT);
priv->rate = 0;
_nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIFI_BITRATE);
@@ -764,8 +758,7 @@ access_point_removed (NMDeviceWifi *self, NMAccessPoint *ap)
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
if (ap == priv->active_ap) {
g_object_unref (priv->active_ap);
priv->active_ap = NULL;
g_clear_object (&priv->active_ap);
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT);
priv->rate = 0;

View File

@@ -2084,16 +2084,9 @@ done:
const char *
nm_device_get_physical_port_id (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (priv->physical_port_id && *priv->physical_port_id)
return priv->physical_port_id;
else
return NULL;
return nm_str_not_empty (NM_DEVICE_GET_PRIVATE (device)->physical_port_id);
}
/**