summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-11-06 17:19:33 +0100
committerThomas Haller <thaller@redhat.com>2020-11-09 17:53:16 +0100
commitd75c31afd02b0b68bb925109d146c95150474035 (patch)
tree8187f85e0489915fd5c62f3c0611d5db83cd0c9a
parentcc35dc3bdf5f76cac5ed37127ca89eef18bb9998 (diff)
downloadNetworkManager-d75c31afd02b0b68bb925109d146c95150474035.tar.gz
device: refactor NMDevice's can_reapply_change() to return early
Don't have if-else-if structure, if we can always return from an "if" block, once we matched the setting-name.
-rw-r--r--src/devices/nm-device.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index df3669aceb..b77d0fd36a 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -12387,28 +12387,34 @@ can_reapply_change(NMDevice * self,
NM_SETTING_CONNECTION_LLDP,
NM_SETTING_CONNECTION_MDNS,
NM_SETTING_CONNECTION_LLMNR);
- } else if (NM_IN_STRSET(setting_name,
- NM_SETTING_USER_SETTING_NAME,
- NM_SETTING_PROXY_SETTING_NAME,
- NM_SETTING_IP4_CONFIG_SETTING_NAME,
- NM_SETTING_IP6_CONFIG_SETTING_NAME)) {
+ }
+
+ if (NM_IN_STRSET(setting_name,
+ NM_SETTING_USER_SETTING_NAME,
+ NM_SETTING_PROXY_SETTING_NAME,
+ NM_SETTING_IP4_CONFIG_SETTING_NAME,
+ NM_SETTING_IP6_CONFIG_SETTING_NAME))
return TRUE;
- } else if (nm_streq(setting_name, NM_SETTING_WIRED_SETTING_NAME)
- && NM_IN_SET(NM_DEVICE_GET_CLASS(self)->get_configured_mtu,
- nm_device_get_configured_mtu_wired_parent,
- nm_device_get_configured_mtu_for_wired)) {
- return nm_device_hash_check_invalid_keys(diffs,
- NM_SETTING_WIRED_SETTING_NAME,
- error,
- NM_SETTING_WIRED_MTU);
- } else {
- g_set_error(error,
- NM_DEVICE_ERROR,
- NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
- "Can't reapply any changes to '%s' setting",
- setting_name);
- return FALSE;
+
+ if (nm_streq(setting_name, NM_SETTING_WIRED_SETTING_NAME)) {
+ if (NM_IN_SET(NM_DEVICE_GET_CLASS(self)->get_configured_mtu,
+ nm_device_get_configured_mtu_wired_parent,
+ nm_device_get_configured_mtu_for_wired)) {
+ return nm_device_hash_check_invalid_keys(diffs,
+ NM_SETTING_WIRED_SETTING_NAME,
+ error,
+ NM_SETTING_WIRED_MTU);
+ }
+ goto out_fail;
}
+
+out_fail:
+ g_set_error(error,
+ NM_DEVICE_ERROR,
+ NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
+ "Can't reapply any changes to '%s' setting",
+ setting_name);
+ return FALSE;
}
static void