Skip to contentSkip to conversation

net: ethernet: starfire: while loop that is never executed

DISCUSSION Colin King (gmail) 1 participant 1 message Oct 29, 2024

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

Hi,

There is a while-loop in function set_vlan_mode in source drivers/net/ethernet/adaptec/starfire.c that currently never gets executed, the code is as follows:

        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;

the while (vlan_count < 32) loop will never get executed because the outer if statement is only executed if val_count is equal to 32 hence val_count < 32 will be false. I'm assuming the while loop is filing the unused slots with zero, so I suspect the code should be:

         if (vlan_count == 32)
                ret |= PerfectFilterVlan;

         while (vlan_count < 32) {
                writew(0, filter_addr);
                filter_addr += 16;
                vlan_count++;
         }

..however I can't find any info on this H/W and I can't test it, so I'm not confident my assumption here is correct.

Colin