From patchwork Tue Sep 15 01:44:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Brandeburg X-Patchwork-Id: 260876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C201C43461 for ; Tue, 15 Sep 2020 01:45:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 250C620771 for ; Tue, 15 Sep 2020 01:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726234AbgIOBpl (ORCPT ); Mon, 14 Sep 2020 21:45:41 -0400 Received: from mga06.intel.com ([134.134.136.31]:12864 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726134AbgIOBpW (ORCPT ); Mon, 14 Sep 2020 21:45:22 -0400 IronPort-SDR: mELbKETvW2grvxPBlXDz9D4TYfv69/jjIMin5Goyeg5KxLxxDjbD2XwkaDiufqe4rAicWUDk3z 48BMckKRb/mA== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="220742447" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="220742447" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 18:45:09 -0700 IronPort-SDR: SvHHhOoOUOggm/CWlEGvbrt5lGl7SDfNjx4OdoGo9fMzoQFhH4hC4Tqux5K1MXreoF4gI7gJ4+ 5svY4aYbwx0g== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="482571954" Received: from jbrandeb-saw1.jf.intel.com ([10.166.28.56]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 18:45:09 -0700 From: Jesse Brandeburg To: netdev@vger.kernel.org Cc: Jesse Brandeburg , intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v2 06/10] drivers/net/ethernet: handle one warning explicitly Date: Mon, 14 Sep 2020 18:44:51 -0700 Message-Id: <20200915014455.1232507-7-jesse.brandeburg@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915014455.1232507-1-jesse.brandeburg@intel.com> References: <20200915014455.1232507-1-jesse.brandeburg@intel.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org While fixing the W=1 builds, this warning came up because the developers used a very tricky way to get structures initialized to a non-zero value, but this causes GCC to warn about an override. In this case the override was intentional, so just disable the warning for this code with a macro that results in disabling the warning for compiles on GCC versions after 8. NOTE: the __diag_ignore macro currently only accepts a second argument of 8 (version 80000) Signed-off-by: Jesse Brandeburg --- drivers/net/ethernet/renesas/sh_eth.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 586642c33d2b..c63304632935 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -45,6 +45,15 @@ #define SH_ETH_OFFSET_DEFAULTS \ [0 ... SH_ETH_MAX_REGISTER_OFFSET - 1] = SH_ETH_OFFSET_INVALID +/* use some intentionally tricky logic here to initialize the whole struct to + * 0xffff, but then override certain fields, requiring us to indicate that we + * "know" that there are overrides in this structure, and we'll need to disable + * that warning from W=1 builds. GCC has supported this option since 4.2.X, but + * the macros available to do this only define GCC 8. + */ +__diag_push(); +__diag_ignore(GCC, 8, "-Woverride-init", + "logic to initialize all and then override some is OK"); static const u16 sh_eth_offset_gigabit[SH_ETH_MAX_REGISTER_OFFSET] = { SH_ETH_OFFSET_DEFAULTS, @@ -332,6 +341,7 @@ static const u16 sh_eth_offset_fast_sh3_sh2[SH_ETH_MAX_REGISTER_OFFSET] = { [TSU_ADRH0] = 0x0100, }; +__diag_pop(); static void sh_eth_rcv_snd_disable(struct net_device *ndev); static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev);