libnm: avoid compiler warning about uninitalized variable in...

libnm: avoid compiler warning about uninitalized variable in nm_setting_bridge_port_remove_vlan_by_vid()

With LTO, compiler warns:

    libnm-core/nm-setting-bridge-port.c: In function nm_setting_bridge_port_remove_vlan_by_vid:
    libnm-core/nm-setting-bridge-port.c:252:6: error: v_start may be used uninitialized in this function [-Werror=maybe-uninitialized]
      252 |   if (v_start == vid_start && v_end == vid_end) {
          |      ^
    libnm-core/nm-setting-bridge-port.c:239:10: note: v_start was declared here
      239 |  guint16 v_start, v_end;
          |          ^
    libnm-core/nm-setting-bridge-port.c:252:28: error: v_end may be used uninitialized in this function [-Werror=maybe-uninitialized]
      252 |   if (v_start == vid_start && v_end == vid_end) {
          |                            ^
    libnm-core/nm-setting-bridge-port.c:239:19: note: v_end was declared here
      239 |  guint16 v_start, v_end;
          |                   ^

Avoid the (false positive) warning.
parent 69798fa6
......@@ -236,18 +236,20 @@ nm_setting_bridge_port_remove_vlan_by_vid (NMSettingBridgePort *setting,
guint16 vid_end)
{
NMSettingBridgePortPrivate *priv;
guint16 v_start, v_end;
NMBridgeVlan *vlan;
guint i;
if (vid_end == 0)
vid_end = vid_start;
g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), FALSE);
priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting);
for (i = 0; i < priv->vlans->len; i++) {
vlan = (NMBridgeVlan *) priv->vlans->pdata[i];
NMBridgeVlan *vlan = priv->vlans->pdata[i];
guint16 v_start = 0;
guint16 v_end = 0;
nm_bridge_vlan_get_vid_range (vlan, &v_start, &v_end);
if (v_start == vid_start && v_end == vid_end) {
g_ptr_array_remove_index (priv->vlans, i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment