From patchwork Fri Mar 24 22:02:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9644073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B12A6020B for ; Fri, 24 Mar 2017 22:04:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A9D423E64 for ; Fri, 24 Mar 2017 22:04:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E1C226E75; Fri, 24 Mar 2017 22:04:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E13C23E64 for ; Fri, 24 Mar 2017 22:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932749AbdCXWEE (ORCPT ); Fri, 24 Mar 2017 18:04:04 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:52372 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932271AbdCXWD4 (ORCPT ); Fri, 24 Mar 2017 18:03:56 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MaaYD-1cbwFq1Dfl-00K9YL; Fri, 24 Mar 2017 23:03:11 +0100 From: Arnd Bergmann To: "David S . Miller" , Doug Ledford Cc: Arnd Bergmann , Lijun Ou , "Wei Hu(Xavier)" , Daode Huang , Kejian Yan , Qianqian Xie , Wei Yongjun , Yisen Zhuang , Salil Mehta , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Date: Fri, 24 Mar 2017 23:02:50 +0100 Message-Id: <20170324220250.2193128-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170324220250.2193128-1-arnd@arndb.de> References: <20170324220250.2193128-1-arnd@arndb.de> X-Provags-ID: V03:K0:wR6VKPObCt0lCVhoFHsatQj99GBXF+VNvUX8xAX7F8+Wcuhf8nR y9P4eRbqnntv/6X1RzeMAdLuz+VtiKI4QqycUHTuOc4PWPjv01dnkaQg3lfydcbcNFZejfH kW7c8kInZQGj6srKvKT69YYOsGKoeh9IRs+pumsrWNObnb+LUpWXafBlfvQtZh6EPbtK1Nn i/NYIBggT46rpY48dDUDw== X-UI-Out-Filterresults: notjunk:1; V01:K0:VxVXQTbF2q0=:uQm2pRYJb8fP2BnotpSPEE q4hAezx4HY64V0hAYbYNKdVMbTBy1PEUQAl9dbK6eKrhHw61ywmhqcNbQobHe3IW9Z8KceHeq ai3D8v5LIjwAoCpuHexUF8HgajlT10sePqscfoWVKSiqGp/EOGCThddhcXuXEps+wsgpqNbOL cJxhBQHJX6KillyJQQ/wQTzpnxsZ7n/TehuCbACdheS+Wwdyk8rR/3NGWJzUXQWMKb0BbQ8vZ x0kENDL2d6QWR6GXlT11qE5vwX+hAf6I9ptr4WdPxipnGaKwaYf0T+xTikFlZkGZiSSBBhIvI +M8ty0e2/OfLZeFcnHFXfq6oTbbXNGkT6JYX/eclVuRxNe3W+TnWMEuiZcog9wGzeAVCcu8fv rJyfM4nfU+cgtk9R/FoV0hW9xTzHyNwq6wIwe0xn5hU3Iw/tJLSxEOSyL9VHgMdwLLIHg0Ubm crqqDTmhwUMswrBSDRaGQYFZOfKeaK2sMRxzr5xDzxk6GFx84zMhkGKPBb1yFXCsENtoP1i2+ ZQc95BIndvBGj9CdlSO93/b2nRmhFPW8iMUTm51/i0mBmzacgWVbSu3mgfzVcfHcZNBlCUnx9 3bhPyQaFxmt0p4KY7iMYwZZ6cOwE0wFEzfs6VxVfg8iKU46zbsY3Hk+BHjo3m0ooLoHNKX5p+ qR5vCnQm3kb9+jiwfLI7xtI9X/P5xk8jt5Z+itl1pWtL7e3stTghrWDQQ4fbNphwc6ew= Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 cd93657abe87..403ea9db6dbd 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,