Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp96271pxb; Mon, 16 Aug 2021 00:25:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt2Yo03SXytRRttN2WenTidspmAzQjCo/Wv5wSJ+w1pCaEyK8pgbrY8SOb04Au31aeRw0N X-Received: by 2002:aa7:ccc9:: with SMTP id y9mr18248870edt.329.1629098746832; Mon, 16 Aug 2021 00:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629098746; cv=none; d=google.com; s=arc-20160816; b=dU6++QPQI1GTZwoWFXs2sv/0ke+VXml6Onvm3NHnrCzNckMMonng1BZlCvj9YTezdc hlZF1A6wCCDYL4SZ2bWnsuxqzZWfVdRlk3m+gp97lwEplk/qzVbxxMOZWeeWKuf0KkXS DZAORG1Xmhp/JS9+AeN5f4ZxucwTMuJIRnzyQmqPvqjWN+6kULZnjVRFoLTNcGLVOGWz d5E8nYFHQYjIEd4Z7tggi7s1YkAZvB4m7Wwfpf29nkSUQd72a0iAskQNkokpDE5HUddA 9pAYSlGsWjLpqM92VfBN4J/Db2G8fOAC2z55JwbuT5KaQgWqwB7eJ6rLKzcQZSFvF80D uGig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KpEK3KVv4gdJEMERAyk5EYCGJBKw8tT8UtZLGJNCPAw=; b=gUSP4EaZXD979akczN/Tro7sw8sUMzW//NKl8sOf7csCCLXX9oEHNNClJqz/gIT5E2 +ZpURuYL0qdFrwxaQS4R3Yt1KYvvKLKhc3MymF3m7ep7YYQbZqOGjmeLAeVs6bXo1eUN HDJWuM5juhj7gaIuP6oWkpe4usvTMKSJsWCGUkXBBNX9ThW032BauoRzcGDdR5UO0w/T UFXBhtCmPRBX5tkgUId0cgbQPXk722hY4B1DGuI57qQMvn0StcFAUYg3qn6lXsiG4wMk hnVAxYWGD35XD9AArIZUgvqFS9QChZTsh0M6JdqcWNnSTR9Alg7OwEyk/FpCoHL1+8Jb MCRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=QxNmD8G1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yc20si7924412ejb.399.2021.08.16.00.25.23; Mon, 16 Aug 2021 00:25:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=QxNmD8G1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234032AbhHPHYZ (ORCPT + 99 others); Mon, 16 Aug 2021 03:24:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233725AbhHPHYZ (ORCPT ); Mon, 16 Aug 2021 03:24:25 -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 02BE9C061764; Mon, 16 Aug 2021 00:23:54 -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=KpEK3KVv4gdJEMERAyk5EYCGJBKw8tT8UtZLGJNCPAw=; b=QxNmD8G1f0oZcP7EGYLwHP3wk 8gkPE5GbcwcTtH/GIh+KBR1vVM5Fh1Pqe2A9dhLh11HPntRDCm7PXvvj8KlNTpP384LAG1p/O8cXL bdeNsvfSjnTt8YHdfdNBJ2fv/pgASv0CfMbVir4BbXjByU5v6Lv20ZE3XP2AzpKq5ic/olS5Whk0+ S/reez+avL4MI9pqCguARKTd6qMpVx7fvwgqC/WeV5BGzMMDJTV4pGfPrlVdWw4UkhId8Y0vHrqbi dAq0EOUt+PlENuDRmSipiyKTbtOAUJYLuyKXIq7oei0qfGv9pK4X/SAUWOZyJdgbOpslw6zWO77yI Noylnv8wA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:47356) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mFWyJ-0007RQ-Qx; Mon, 16 Aug 2021 08:23:47 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1mFWyH-0007nW-1w; Mon, 16 Aug 2021 08:23:45 +0100 Date: Mon, 16 Aug 2021 08:23:45 +0100 From: "Russell King (Oracle)" To: Dan Carpenter Cc: Al Viro , Christophe JAILLET , Leon Romanovsky , Joe Perches , Dwaipayan Ray , Andy Whitcroft , Lukas Bulwahn , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Julia Lawall Subject: Re: [PATCH] checkpatch: prefer = {} initializations to = {0} Message-ID: <20210816072344.GG22278@shell.armlinux.org.uk> References: <20210805104353.GD26417@kili> <1b94e688-a070-998a-3014-96bcbaed4cae@wanadoo.fr> <20210816065552.GE1931@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210816065552.GE1931@kadam> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 16, 2021 at 09:55:53AM +0300, Dan Carpenter wrote: > On Sat, Aug 14, 2021 at 02:52:31PM +0000, Al Viro wrote: > > On Sat, Aug 14, 2021 at 03:59:22PM +0200, Christophe JAILLET wrote: > > > > > > +# prefer = {}; to = {0}; > > > > + if ($line =~ /= \{ *0 *\}/) { > > > > + WARN("ZERO_INITIALIZER", > > > > + "= {} is preferred over = {0}\n" . $herecurr); > > > > Sigh... "is preferred over" by whom? Use the active voice, would you? > > > > > [1] and [2] state that {} and {0} don't have the same effect. So if correct, > > > this is not only a matter of style. > > > > > > When testing with gcc 10.3.0, I arrived at the conclusion that both {} and > > > {0} HAVE the same behavior (i.e the whole structure and included structures > > > are completely zeroed) and I don't have a C standard to check what the rules > > > are. > > > gcc online doc didn't help me either. > > > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf, but empty > > initializer-list is gccism anyway. > > > > Section 6.7.8 is the one to look through there. > > That's out of date. It changed in C11. Both = { 0 } and = { } will > clear out struct holes. The = { } GCC extension has always initialized > struct holes. > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf > > For partial initializations then all the padding is zeroed. > Unfortunately if you fully initialize the struct then padding is not > initialized. If we're going to discuss which C standard applies to the kernel, then... As Kbuild passes -std=gnu89, the kernel expects C89 behaviour with GNU extensions from the compiler, both C99 and C11 are not that relevant, although the GNU extensions include some bits from these standards. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!