Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp852406pxt; Thu, 5 Aug 2021 13:22:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzALT4rfIul7ppa7pbXU9sLR0IzgfBxxXTmuoyfMYznbldrmQmmcV9pfJm2Uzq/y/5VAGG X-Received: by 2002:a92:d24b:: with SMTP id v11mr490990ilg.169.1628194931543; Thu, 05 Aug 2021 13:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628194931; cv=none; d=google.com; s=arc-20160816; b=oZSuCaKKh3xD47szqMpBpTi68jRAace/ilN+OkGPPKV9zaY2sYkvcUVWbbsgGvtHv7 e29wcaFZrmeR7qmEUedSf/OKmhX3lDYy+53mBRz6pGlrawsOCmZK3Bq45OibqADv0Elk SsigcIv7mqN4WPVUoLchAAwSVw1AfdBZtz85+R65yH4qKATPvtELDo7fFqofsZorCfVQ cOyT5z4yMFsXvaW5p9n3DMu+cmd1yvtnxm3g1Jh9HJD3qEtr/mcuSC71eSMfl7ST2jWC ZCxkEoQs8psxtIb440U5HSVNzzTj9JWuRhnyPzNcTmCZc/Wsg2TdTwRS3zWKiNt7Hle2 9LkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=rZk/J2ug661Qn6eHNZE0EH0KLpl5P47RfrCn2ihlFxs=; b=Z9FlcIxQvYB6nU9f27TWi49dFwvbQB2ORaS+ulSgBxbp49xF0d5R7P21o6UWNR0LIG qsaKQ64KxdATEjFpNd2LjwYHULKUmRPDXeXh7HUMev+oAlH6GHCFnF/SfGpktHaxTW4C v/rVvoi8IL3dJkJN+ZsMv5p/1Ci2EXaG8zyL0b+1Xs5HrAMrMexIgFzV7rEGKMJ5tTYa sj7x7bs4l03B4izyx0zgH9f8lrIGU9by1bM2yUvw52Z4rGq3/pou615wayTZBSft4jbc 9vFUy8QV1KK3r+QAhYiJcLq6OiUBp8ZYh6ufdCh7b3OG2CDzgS4kE8PuDozMo73KJdm1 GgVg== 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 d2si6198130iow.58.2021.08.05.13.21.59; Thu, 05 Aug 2021 13:22:11 -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 S241257AbhHES2c (ORCPT + 99 others); Thu, 5 Aug 2021 14:28:32 -0400 Received: from smtprelay0094.hostedemail.com ([216.40.44.94]:55362 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241221AbhHES2b (ORCPT ); Thu, 5 Aug 2021 14:28:31 -0400 Received: from omf02.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id 891DA1802EF2E; Thu, 5 Aug 2021 18:28:16 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA id 399661D42F7; Thu, 5 Aug 2021 18:28:15 +0000 (UTC) Message-ID: <83ffab14de1c2af00d38d532ffecdda1f9e936ab.camel@perches.com> Subject: Re: [PATCH] checkpatch: prefer = {} initializations to = {0} From: Joe Perches To: Julia Lawall Cc: Dan Carpenter , Andy Whitcroft , cocci , Dwaipayan Ray , Lukas Bulwahn , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Thu, 05 Aug 2021 11:28:14 -0700 In-Reply-To: References: <20210805104353.GD26417@kili> <117021b44dc9ba570a0f48736d14a267a8701d0a.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 399661D42F7 X-Spam-Status: No, score=1.32 X-Stat-Signature: 7rw1go6hi8mn6wqjk1fshxtz18ke3nac X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/ZNcsWtRe/4qfW85P24gjRbPtTDpFDiZc= X-HE-Tag: 1628188095-557803 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2021-08-05 at 20:17 +0200, Julia Lawall wrote: > 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 { }. I saw that and I don't recall how to force one style or another to be output.