device: various minor style cleanup

This commit is contained in:
Thomas Haller 2019-08-22 07:41:34 +02:00
parent 7bf8c45b19
commit 7fd50f2789
6 changed files with 31 additions and 22 deletions

View file

@ -94,7 +94,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
dirfd = nm_platform_sysctl_open_netdir (nm_device_get_platform (device), nm_device_get_ifindex (device), ifname_verified);
if (dirfd < 0) {
if (!strcmp (transport_mode, "datagram"))
if (nm_streq (transport_mode, "datagram"))
return NM_ACT_STAGE_RETURN_SUCCESS;
else {
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_INFINIBAND_MODE);

View file

@ -357,12 +357,12 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
/* Nothing to do for TUN devices */
if (priv->props.type == IFF_TUN)
return NM_ACT_STAGE_RETURN_SUCCESS;
if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE))
return NM_ACT_STAGE_RETURN_FAILURE;
if (priv->props.type == IFF_TUN) {
/* Nothing to do for TUN devices */
} else {
if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE))
return NM_ACT_STAGE_RETURN_FAILURE;
}
return NM_ACT_STAGE_RETURN_SUCCESS;
}

View file

@ -497,7 +497,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
if (s_vlan) {
gs_free NMVlanQosMapping *ingress_map = NULL;
gs_free NMVlanQosMapping *egress_map = NULL;
guint n_ingress_map = 0, n_egress_map = 0;
guint n_ingress_map = 0;
guint n_egress_map = 0;
_nm_setting_vlan_get_priorities (s_vlan,
NM_VLAN_INGRESS_MAP,
@ -520,7 +521,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
n_egress_map);
}
return ret;
return NM_ACT_STAGE_RETURN_SUCCESS;
}
static guint32

View file

@ -660,7 +660,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
* have a PID, then we must fail.
*/
cfg = teamdctl_config_get_raw (priv->tdc);
if (cfg && nm_streq0 (cfg, nm_setting_team_get_config (s_team))) {
if ( cfg
&& nm_streq0 (cfg, nm_setting_team_get_config (s_team))) {
_LOGD (LOGD_TEAM, "using existing matching teamd config");
return NM_ACT_STAGE_RETURN_SUCCESS;
}
@ -684,8 +685,10 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
return NM_ACT_STAGE_RETURN_POSTPONE;
}
return teamd_start (device, connection) ?
NM_ACT_STAGE_RETURN_POSTPONE : NM_ACT_STAGE_RETURN_FAILURE;
if (!teamd_start (device, connection))
return NM_ACT_STAGE_RETURN_FAILURE;
return NM_ACT_STAGE_RETURN_POSTPONE;
}
static void

View file

@ -1716,6 +1716,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
NMActStageReturn ret;
NMWifiAP *ap = NULL;
gs_unref_object NMWifiAP *ap_fake = NULL;
NMActRequest *req;
NMConnection *connection;
NMSettingWireless *s_wireless;
@ -1741,7 +1742,9 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
goto add_new;
ap_path = nm_active_connection_get_specific_object (NM_ACTIVE_CONNECTION (req));
ap = ap_path ? nm_wifi_ap_lookup_for_device (NM_DEVICE (self), ap_path) : NULL;
ap = ap_path
? nm_wifi_ap_lookup_for_device (NM_DEVICE (self), ap_path)
: NULL;
if (ap) {
set_current_ap (self, ap, TRUE);
return NM_ACT_STAGE_RETURN_SUCCESS;
@ -1767,19 +1770,19 @@ add_new:
* until the real one is found in the scan list (Ad-Hoc or Hidden), or until
* the device is deactivated (Ad-Hoc or Hotspot).
*/
ap = nm_wifi_ap_new_fake_from_connection (connection);
g_return_val_if_fail (ap != NULL, NM_ACT_STAGE_RETURN_FAILURE);
ap_fake = nm_wifi_ap_new_fake_from_connection (connection);
if (!ap_fake)
g_return_val_if_reached (NM_ACT_STAGE_RETURN_FAILURE);
if (nm_wifi_ap_is_hotspot (ap))
nm_wifi_ap_set_address (ap, nm_device_get_hw_address (device));
if (nm_wifi_ap_is_hotspot (ap_fake))
nm_wifi_ap_set_address (ap_fake, nm_device_get_hw_address (device));
g_object_freeze_notify (G_OBJECT (self));
ap_add_remove (self, TRUE, ap, FALSE);
ap_add_remove (self, TRUE, ap_fake, FALSE);
g_object_thaw_notify (G_OBJECT (self));
set_current_ap (self, ap, FALSE);
set_current_ap (self, ap_fake, FALSE);
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
g_object_unref (ap);
nm_dbus_object_get_path (NM_DBUS_OBJECT (ap_fake)));
return NM_ACT_STAGE_RETURN_SUCCESS;
}

View file

@ -593,7 +593,9 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
req = nm_device_get_act_request (device);
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
return nm_modem_act_stage1_prepare (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, req, out_failure_reason);
return nm_modem_act_stage1_prepare (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem,
req,
out_failure_reason);
}
static NMActStageReturn