mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 08:18:03 +02:00
cli: don't fail removing non-existing option (pt6)
Part 6, which addresses the issue for VLAN priority maps.
This commit is contained in:
parent
eff01cd256
commit
626aed64e7
1 changed files with 8 additions and 25 deletions
|
|
@ -4164,13 +4164,10 @@ _remove_vlan_xgress_priority_map (const NMMetaEnvironment *environment,
|
||||||
{
|
{
|
||||||
guint32 num;
|
guint32 num;
|
||||||
|
|
||||||
/* If value != NULL, remove by value */
|
|
||||||
if (value) {
|
if (value) {
|
||||||
gboolean ret;
|
gs_strfreev char **prio_map = NULL;
|
||||||
char **prio_map;
|
|
||||||
gs_free char *v = g_strdup (value);
|
|
||||||
|
|
||||||
prio_map = _parse_vlan_priority_maps (v, map_type, TRUE, error);
|
prio_map = _parse_vlan_priority_maps (value, map_type, TRUE, error);
|
||||||
if (!prio_map)
|
if (!prio_map)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (prio_map[1]) {
|
if (prio_map[1]) {
|
||||||
|
|
@ -4179,29 +4176,15 @@ _remove_vlan_xgress_priority_map (const NMMetaEnvironment *environment,
|
||||||
N_("only one mapping at a time is supported; taking the first one (%s)"),
|
N_("only one mapping at a time is supported; taking the first one (%s)"),
|
||||||
prio_map[0]);
|
prio_map[0]);
|
||||||
}
|
}
|
||||||
ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting),
|
nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting),
|
||||||
map_type,
|
map_type,
|
||||||
prio_map[0]);
|
prio_map[0]);
|
||||||
|
return TRUE;
|
||||||
if (!ret)
|
|
||||||
g_set_error (error, 1, 0, _("the property doesn't contain mapping '%s'"), prio_map[0]);
|
|
||||||
g_strfreev (prio_map);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else remove by index */
|
|
||||||
num = nm_setting_vlan_get_num_priorities (NM_SETTING_VLAN (setting), map_type);
|
num = nm_setting_vlan_get_num_priorities (NM_SETTING_VLAN (setting), map_type);
|
||||||
if (num == 0) {
|
if (idx < num)
|
||||||
g_set_error_literal (error, 1, 0, _("no priority to remove"));
|
nm_setting_vlan_remove_priority (NM_SETTING_VLAN (setting), map_type, idx);
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (idx >= num) {
|
|
||||||
g_set_error (error, 1, 0, _("index '%d' is not in the range of <0-%d>"),
|
|
||||||
idx, num - 1);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nm_setting_vlan_remove_priority (NM_SETTING_VLAN (setting), map_type, idx);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue