Skip to contentSkip to conversation

starfire: set_vlan_mode contains dead code in a while loop

DISCUSSION Colin King (gmail) 1 participant 1 message Mar 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

There is an issue in function set_vlan_mode with code that is never executed in the following commit:

commit 5da96be53a16a62488316810d0c7c5d58ce3ee4f

Author: Jiri Pirko <[email protected]>
Date:   Wed Jul 20 04:54:31 2011 +0000

starfire: do vlan cleanup

The issue is as follows:

static u32 set_vlan_mode(struct netdev_private *np)

{
        u32 ret = VlanMode;
        u16 vid;
        void __iomem *filter_addr = np->base + HashTable + 8;
        int vlan_count = 0;

        for_each_set_bit(vid, np->active_vlans, VLAN_N_VID) {
                if (vlan_count == 32)
                        break;
                writew(vid, filter_addr);
                filter_addr += 16;
                vlan_count++;
        }
        if (vlan_count == 32) {
                ret |= PerfectFilterVlan;
                while (vlan_count < 32) {
                        writew(0, filter_addr);
                        filter_addr += 16;
                        vlan_count++;
                }
        }
        return ret;
}

If vlan_count is 32 then the while loop is currently dead code since vlan_count cannot be less than 32 (so the loop is never executed).

This logic seems broken.

Colin