starfire: set_vlan_mode contains dead code in a while loop

From: Colin King (gmail) <hidden>
Date: 2026-03-10 15:05:50
Also in: lkml

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 [off-list ref]
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

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help