• Arnd Bergmann's avatar
    net: hns: avoid gcc-7.0.1 warning for uninitialized data · 834a61d4
    Arnd Bergmann authored
    hns_dsaf_set_mac_key() calls dsaf_set_field() on an uninitialized field,
    which will then change only a few of its bits, causing a warning with
    the latest gcc:
    
    hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_mac_uc_entry':
    hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       (origin) &= (~(mask)); \
                ^~
    hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_mac_mc_entry':
    hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_add_mac_mc_port':
    hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_del_mac_entry':
    hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_rm_mac_addr':
    hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_del_mac_mc_port':
    hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_get_mac_uc_entry':
    hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_get_mac_mc_entry':
    hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    
    The code is actually correct since we always set all 16 bits of the
    port_vlan field, but gcc correctly points out that the first
    access does contain uninitialized data.
    
    This initializes the field to zero first before setting the
    individual bits.
    
    Fixes: 5483bfcb ("net: hns: modify tcam table and set mac key")
    Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    834a61d4
hns_dsaf_main.c 92.9 KB