mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-28 20:20:34 +01:00
device: inline check_changed_options() in can_reapply_change()
Code doesn't get simpler by having more functions -- if these functions
are only called once.
What actually is a problem is repeated, redundant code. Like the list of
bond options that can be reapplied. But the function didn't help to
avoid repeating the list.
(cherry picked from commit f807b68376)
This commit is contained in:
parent
7030cd2c8b
commit
97f7d4f64f
1 changed files with 26 additions and 30 deletions
|
|
@ -561,35 +561,6 @@ create_and_realize (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_changed_options (NMSettingBond *s_a, NMSettingBond *s_b, GError **error)
|
||||
{
|
||||
const char **option_list;
|
||||
|
||||
option_list = nm_setting_bond_get_valid_options (NULL);
|
||||
|
||||
for (; *option_list; ++option_list) {
|
||||
const char *name = *option_list;
|
||||
|
||||
/* We support changes to these */
|
||||
if (NM_IN_STRSET (name, OPTIONS_REAPPLY_FULL))
|
||||
continue;
|
||||
|
||||
/* Reject any other changes */
|
||||
if (!nm_streq0 (nm_setting_bond_get_option_normalized (s_a, name),
|
||||
nm_setting_bond_get_option_normalized (s_b, name))) {
|
||||
g_set_error (error,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
"Can't reapply '%s' bond option",
|
||||
name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
can_reapply_change (NMDevice *device,
|
||||
const char *setting_name,
|
||||
|
|
@ -602,13 +573,38 @@ can_reapply_change (NMDevice *device,
|
|||
|
||||
/* Only handle bond setting here, delegate other settings to parent class */
|
||||
if (nm_streq (setting_name, NM_SETTING_BOND_SETTING_NAME)) {
|
||||
NMSettingBond *s_a = NM_SETTING_BOND (s_old);
|
||||
NMSettingBond *s_b = NM_SETTING_BOND (s_new);
|
||||
const char **option_list;
|
||||
|
||||
if (!nm_device_hash_check_invalid_keys (diffs,
|
||||
NM_SETTING_BOND_SETTING_NAME,
|
||||
error,
|
||||
NM_SETTING_BOND_OPTIONS))
|
||||
return FALSE;
|
||||
|
||||
return check_changed_options (NM_SETTING_BOND (s_old), NM_SETTING_BOND (s_new), error);
|
||||
option_list = nm_setting_bond_get_valid_options (NULL);
|
||||
|
||||
for (; *option_list; ++option_list) {
|
||||
const char *name = *option_list;
|
||||
|
||||
/* We support changes to these */
|
||||
if (NM_IN_STRSET (name, OPTIONS_REAPPLY_FULL))
|
||||
continue;
|
||||
|
||||
/* Reject any other changes */
|
||||
if (!nm_streq0 (nm_setting_bond_get_option_normalized (s_a, name),
|
||||
nm_setting_bond_get_option_normalized (s_b, name))) {
|
||||
g_set_error (error,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
"Can't reapply '%s' bond option",
|
||||
name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
device_class = NM_DEVICE_CLASS (nm_device_bond_parent_class);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue