ifcfg-rh: avoid cloning vlans array in write_bridge_vlans()

This commit is contained in:
Thomas Haller 2021-05-06 17:09:06 +02:00
parent 72e8336fdc
commit 7065d75b91
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1552,17 +1552,20 @@ write_team_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
static gboolean
write_bridge_vlans(NMSetting * setting,
const char *property_name,
gboolean is_port,
shvarFile * ifcfg,
const char *key,
GError ** error)
{
gs_unref_ptrarray GPtrArray *vlans = NULL;
NMBridgeVlan * vlan;
nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(0, FALSE);
guint i;
GPtrArray * vlans;
NMBridgeVlan * vlan;
nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(0, FALSE);
guint i;
g_object_get(setting, property_name, &vlans, NULL);
if (is_port)
vlans = _nm_setting_bridge_port_get_vlans(NM_SETTING_BRIDGE_PORT(setting));
else
vlans = _nm_setting_bridge_get_vlans(NM_SETTING_BRIDGE(setting));
if (!vlans || !vlans->len)
return TRUE;
@ -1818,11 +1821,7 @@ write_bridge_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired
svSetValueStr(ifcfg, "BRIDGING_OPTS", opts->str);
g_string_free(opts, TRUE);
if (!write_bridge_vlans((NMSetting *) s_bridge,
NM_SETTING_BRIDGE_VLANS,
ifcfg,
"BRIDGE_VLANS",
error))
if (!write_bridge_vlans((NMSetting *) s_bridge, FALSE, ifcfg, "BRIDGE_VLANS", error))
return FALSE;
svSetValueStr(ifcfg, "TYPE", TYPE_BRIDGE);
@ -1873,11 +1872,7 @@ write_bridge_port_setting(NMConnection *connection, shvarFile *ifcfg, GError **e
svSetValueStr(ifcfg, "BRIDGING_OPTS", string->str);
g_string_free(string, TRUE);
if (!write_bridge_vlans((NMSetting *) s_port,
NM_SETTING_BRIDGE_PORT_VLANS,
ifcfg,
"BRIDGE_PORT_VLANS",
error))
if (!write_bridge_vlans((NMSetting *) s_port, TRUE, ifcfg, "BRIDGE_PORT_VLANS", error))
return FALSE;
return TRUE;