From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 70487C433F5 for ; Mon, 20 Sep 2021 12:49:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5309460F6B for ; Mon, 20 Sep 2021 12:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233587AbhITMvF (ORCPT ); Mon, 20 Sep 2021 08:51:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236007AbhITMvC (ORCPT ); Mon, 20 Sep 2021 08:51:02 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9537DC061574 for ; Mon, 20 Sep 2021 05:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zPbk7FSzoDNjkUglXnkYbQsblfsq5zLr1n7fNPKCYI8=; b=1rfo8yqR11OR1uPNFPpoiWblGP G8rr7FvWvm8S2rRA+/1XHHCKS89Up+Xw7I2nj5GFDEEvA8aiYss9hfJg97TI+YjiaQkPM1qnI1gmj m17k68bmqGBV7RRHE/S70aiO4BnmoH5BCfWb40AtCGzCrhsxWY7BwcpFTi21DpdxGig2yPXPCeefT SIeJLzfnCu4QoiHMnphlp6s3VjohUpzrptOFtKapNDv9GPqqgHrHf894PGKPt0Ezui6dk4fh6Q4E8 +NtTXFWxPLyCGg3gCqmUJSe1700IiFA71fqEBA+q8bxDNxUJ0EAvvUokq6V4sDIy3mwRxnm5r7iAk MgxvMlwA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:54668) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mSIje-0001dE-FM; Mon, 20 Sep 2021 13:49:26 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mSIjb-0002J2-6X; Mon, 20 Sep 2021 13:49:23 +0100 Date: Mon, 20 Sep 2021 13:49:23 +0100 From: "Russell King (Oracle)" To: Davide Caratti Cc: "David S. Miller" , Jakub Kicinski , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Marcelo Ricardo Leitner , netdev@vger.kernel.org Subject: Re: [PATCH net] net: sched: fix initialiser warning in sch_frag.c Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Sep 20, 2021 at 11:08:53AM +0200, Davide Caratti wrote: > On Sun, Sep 19, 2021 at 11:40:33PM +0100, Russell King (Oracle) wrote: > > Debian gcc 10.2.1 complains thusly: > > > > net/sched/sch_frag.c:93:10: warning: missing braces around initializer [-Wmissing-braces] > > struct rtable sch_frag_rt = { 0 }; > > ^ > > net/sched/sch_frag.c:93:10: warning: (near initialization for 'sch_frag_rt.dst') [-Wmissing-braces] > > > > Fix it by removing the unnecessary '0' initialiser, leaving the > > braces. > > hello Russell, thanks a lot for reporting! > > > diff --git a/net/sched/sch_frag.c b/net/sched/sch_frag.c > > index 8c06381391d6..ab359d63287c 100644 > > --- a/net/sched/sch_frag.c > > +++ b/net/sched/sch_frag.c > > @@ -90,7 +90,7 @@ static int sch_fragment(struct net *net, struct sk_buff *skb, > > } > > > > if (skb_protocol(skb, true) == htons(ETH_P_IP)) { > > - struct rtable sch_frag_rt = { 0 }; > > + struct rtable sch_frag_rt = { }; > > this surely fixes the -Wmissing-braces, but then -Wpedantic > would complain about usage of GNU extension (I just tried on godbolt > with x86_64 gcc 11.2): > > warning: ISO C forbids empty initializer braces [-Wpedantic] > > While we are fixing this, probably the best thing is to initialize the > 'dst' struct member to 0: in my understanding this should be sufficient > to let the compiler fill all the struct members with 0. > > Oh, and I might have inserted a similar thing in openvswitch kernel > module (see [1]), if you agree I will send a patch that fixes this as > well. WDYT? ISO C may forbid it, but the kernel build uses -std=gnu89 - which is c89 with GNU extensions. One of the GNU extensions is to allow the empty initialiser, which means "initialise all members of this struct to zero". However, as I say, this was found using gcc 4.9.4 under 5.14, where 4.9.4 is a permissable compiler. However, under 5.15-rc it is no longer so the patch should not be applied to development kernels. It leaves the question open whether it should be fixed in stable or not, since stable kernels _do_ permit gcc 4.9.4. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!