Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp852671pxt; Thu, 5 Aug 2021 13:22:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ4HILbvP8xgarokQhnSr62vejIRYxmqdBkp/rfsNzOnbeh4c87e/epND+pFBIsr0A5jr2 X-Received: by 2002:a17:906:411b:: with SMTP id j27mr3986387ejk.390.1628194962855; Thu, 05 Aug 2021 13:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628194962; cv=none; d=google.com; s=arc-20160816; b=0TcyWsGZsPiv5I3AA/igrSrXxiuChbuOiZGd4E+3IMYh8bNCOhXkknX3AzCOzxQbjq SmOiczOc/uY/jRdGYX0ywkmPznkYtHViHVIaXuN2qNYq7rUGufBNWYbfB41/oXK0y4WD ixT3SdK8lfqZsWcMvabioOc/5EGDZOMIY+TZ0eI35ya5XDL3CKs0USavOpZv7gWP6tFP +dX5G+lLsSR5cv/C2TJMAqNkZlz4LTFzl4YSkHBmW51XIjoea4cR1j6fRvZRRnO81+Sg JSKen+smBJn1DOU/zo2pWcKw5WQZHCe1AsnVCtLJFBdE6BCyrsv4IkaxEY4+DU+6IxA+ tzPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:ironport-hdrordr; bh=1slDHSAzGGMlv+lgMKqeBCwASJ5bwKihvzfSBbl3AOo=; b=vVLEkQHCtqzggXEBwzMFXhGZgf1Wgj8w0LrPrKa4z9qFepRzCkkKQwmgoCRE8BiDrf C8XJz4ykMmCQbpZ/3MmTE0wW07N/l0Kitg1HjFcTUVLlGigfKsOwYC+4bgoHEM56+dg5 7E3q5p+Yxfl6waPFFwFRvIr7m5kWMPuM3WclVrHCK8oXn8aZ2q+CiKJ8bS/Oncbwx8Ib KTJKd5M3Qy26spcypcchKRPm0M0To8BLQsOSDKwdNAH2dA/8A1A6sHc1jWFoaqAslb9T 0DynBez3xmTc29SarrHwOPrCk21eUH9jfGBrAYbgwQgX86Vt62ARepM6wovIhWcUF3Gq KWtw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l15si6478685ejg.444.2021.08.05.13.22.19; Thu, 05 Aug 2021 13:22:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241095AbhHESSN (ORCPT + 99 others); Thu, 5 Aug 2021 14:18:13 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:8798 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241085AbhHESSM (ORCPT ); Thu, 5 Aug 2021 14:18:12 -0400 IronPort-HdrOrdr: =?us-ascii?q?A9a23=3ABEs77KNyV830xsBcT63255DYdb4zR+YMi2TD?= =?us-ascii?q?iHoBLiC9I/bo8/xGws5rsCMc0AxhJk3I6urwSZVoIEmsqqKdhLNhW4tKMzOWxF?= =?us-ascii?q?dARrsO0WLd+Uy/J8STzJ8B6U4CSdkyNDSTNykEsS+g2njjLz9I+rDum8zG9IWu?= =?us-ascii?q?tgYUcexzUdAC0+4eMHfGLqRYfngWOXNTLuvE2iMznUvcRZ1hVLXAOpBqZZm5mz?= =?us-ascii?q?UL/KiWOSIuNloC0k2jnDmo4Ln1H1yzxREFSQ5Cxr8k7CzsjxH5zr/LiYD19jbs?= =?us-ascii?q?k0voq7hGktrozdVOQOaWjNIOFznqggG0IKx8Rry5uiwvqu3H0idlrDCMmWZhAy?= =?us-ascii?q?w/g0mhP11dkyGdmTUI4wxerkMK/GXowkcK+aTCNXYH4oR69MVkm1DimjodVZlH?= =?us-ascii?q?odF29lPck5JWCBfJm2DU/sHSUQ5nmw6dvBMZ4KguZ/M2a/pEVFY9l+YiFQVuYd?= =?us-ascii?q?s9NRO/16wdLclFJOSZxM8TSU+TdHjfo2lpzJiNcx0IcCuucww8lvep8xJ/uTRY?= =?us-ascii?q?9g8j7uQ5uVssnahdd7B0o9vpCZlJvplqCu8uKZhlDONEe8GwEWCle3Lx2U+pUC?= =?us-ascii?q?La/Zs8Sjvwgo+y5K9w6PCheZQOwpd3kJPdUElAvWp3f071E8WB0JBC7xiIGQyG?= =?us-ascii?q?LH/Q49Ab44I8tqz3RbLtPyHGQFcyk9G4q/FaBsHAQf68NJ9fHvemJ2rzHoRC2R?= =?us-ascii?q?H4RvBpWDEjueguy5wGsn6107b2w9fRx5nmmd7oVc3Q+RZNYBKMPkc+?= X-IronPort-AV: E=Sophos;i="5.84,296,1620684000"; d="scan'208";a="522911521" Received: from 173.121.68.85.rev.sfr.net (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Aug 2021 20:17:56 +0200 Date: Thu, 5 Aug 2021 20:17:56 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Joe Perches cc: Dan Carpenter , Andy Whitcroft , cocci , Dwaipayan Ray , Lukas Bulwahn , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] checkpatch: prefer = {} initializations to = {0} In-Reply-To: Message-ID: References: <20210805104353.GD26417@kili> <117021b44dc9ba570a0f48736d14a267a8701d0a.camel@perches.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Aug 2021, Joe Perches wrote: > On Thu, 2021-08-05 at 05:27 -0700, Joe Perches wrote: > > On Thu, 2021-08-05 at 13:43 +0300, Dan Carpenter wrote: > > > The "= {};" style empty struct initializer is preferred over = {0}. > > > It avoids the situation where the first struct member is a pointer and > > > that generates a Sparse warning about assigning using zero instead of > > > NULL. Also it's just nicer to look at. > > Perhaps a cocci script like the below could help too: > > $ cat zero_init_struct.cocci > @@ > identifier name; > identifier t; > @@ > > struct name t = { > - 0 > }; > > @@ > identifier name; > identifier t; > identifier member; > @@ > > struct name t = { > ..., > .member = { > - 0 > }, > ..., > }; My test turns up over 1900 occurrences. There is the question of whether {} or { } is preferred. The above semantic patch replaces {0} by {} and ( 0 } by { }. julia