From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755871AbdCWO4u (ORCPT ); Thu, 23 Mar 2017 10:56:50 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:64184 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754136AbdCWO4s (ORCPT ); Thu, 23 Mar 2017 10:56:48 -0400 From: Arnd Bergmann To: Yisen Zhuang , Salil Mehta , "David S. Miller" Cc: Arnd Bergmann , Daode Huang , Qianqian Xie , Kejian Yan , Wei Yongjun , oulijun , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Date: Thu, 23 Mar 2017 15:55:50 +0100 Message-Id: <20170323145610.54695-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:VUSWNyipvQKZZwZFvraNnrguOYIAy19MiTbOTdZri9UfXZLRyge TLOkfghT9xfgYvJdbMs+ICImhoUBofOZfRwUBF9wqEo5N8sSNN5xf8NgJGirsQes2dtanCm MVWLThzKoI6/QfoEYA2MObaCzt19qJGrMgVyYE/jWazRPPGBznisJlgHrdAl1VEbRxfWfZS cTPN9lhXHRbz/eI+hi8yQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:1/pxyPx7Jqk=:j+vXk5M3RW7u1MeEDb+56U UmBfpGeExOVcEx4g00ZKtxhDUlCwPnlI4SzqiWxyCp47nyAkTEC5KlEe7eJCBao2ALpIkZV7w fOD4+01HpSQrGl+Q8T42249jzwC+5834v00Tcr+fvVM9SQobAuzpkGsyvHk/dbi3U6FrUpZBI 7PZ6hVskGNdtwN9CqSDj04CDs+POj7P8oFuHQFIFSxqjcqlbjGhU+He5bhcyz5lpnUnW+JWSv ++2uOb134ZAfp/RwQ3jC3WrMgVcjkgBMarEBZs8iUYRPUgufuleZNWzhBCkY4dgJewrnbhWk4 xZZxZJ+luhxpYbOzDKVAq+N91HapdYCAXkk4TEMHm4zDnIjDE/ZvtZfcNSF/aTucfTWIy/JLs DtMq9VZFTtJpioz1Nio8FpdgNiKDeKq00f7rJlQ9fDkptMmHad7odxwELSjkdObWPFxJGNMlY pyjsujxxO5tPVRruGqGtOq23XlpNRhGd21eB/KhFNju6fWo8nJeedTGef4CGUTXQava46ug9z xuom9fOZktMNA1vFem2Zq4EECYzP6VlauFIj0MgFlHEJ1nvpwWX2A0i1CW7XFY5LcbOhCNRrO QAmbVwlU1SPdLDdcr5cZ7pv1YteqfxLKi61/duIazF4sW3RkxKAqzb1h+eBaB9mcAy+Ph6KXT 7ypXoSWDjMunOAOzrl5utaM6OeZTINFVfHsLBGAc1uF0UcwOzsGGmOzEQJWnQMOt8dkU= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: 5483bfcb169c ("net: hns: modify tcam table and set mac key") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c index 90dbda792614..1ec6d4bb6044 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c @@ -1519,6 +1519,7 @@ static void hns_dsaf_set_mac_key( mac_key->high.bits.mac_3 = addr[3]; mac_key->low.bits.mac_4 = addr[4]; mac_key->low.bits.mac_5 = addr[5]; + mac_key->low.bits.port_vlan = 0; dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_VLAN_M, DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id); dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M, -- 2.9.0