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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88E82C43217 for ; Mon, 17 Jan 2022 18:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242181AbiAQSFV (ORCPT ); Mon, 17 Jan 2022 13:05:21 -0500 Received: from relay038.a.hostedemail.com ([64.99.140.38]:19625 "EHLO relay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242087AbiAQSFT (ORCPT ); Mon, 17 Jan 2022 13:05:19 -0500 Received: from omf01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F0F6325307; Mon, 17 Jan 2022 18:05:17 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA id 817716000E; Mon, 17 Jan 2022 18:05:07 +0000 (UTC) Message-ID: Subject: Re: list iterator spacing: clang-format vs checkpatch From: Joe Perches To: "Jason A. Donenfeld" , Miguel Ojeda Cc: Andrew Lunn , LKML Date: Mon, 17 Jan 2022 10:05:15 -0800 In-Reply-To: References: <3cbaf145ee577f017cf7aea953c9dd1eb88ed4b4.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 817716000E X-Stat-Signature: sggpbsqu86ytmdasds6m67ecweokaouf X-Rspamd-Server: rspamout07 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+TONOwT8Ea+r8Fe4q7nQp8jsSucvMhp3w= X-HE-Tag: 1642442707-812029 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2022-01-17 at 13:47 +0100, Jason A. Donenfeld wrote: > Hey again, Rehi. > Four years later I went through basically the same motions: "oh hey I > should clean this up", "I'll start with clang format", "oh cool it > adds spaces before the iterator paren so it looks like a normal for > loop to me", "that seems so reasonable; I love clang format", "oh no > checkpatch.pl complains; I hope it's wrong", "I wonder if anybody has > thought about this before", "oh, look, I asked about this already in > 2018." Original thread: https://lore.kernel.org/lkml/CAHmME9ofzanQTBD_WYBRW49d+gM77rCdh8Utdk4+PM9n_bmKwA@mail.gmail.com/ > So, here we are again. I'm wondering: > - Can we switch to spaces before iterator parens? Still doubtful because the kernel sources has ~150:1 preference for no space, and it's still just a whitespace convention... $ git grep -P '\b\w*for_each\w*\(' | wc -l 31920 $ git grep -P '\b\w*for_each\w*\s+\(' | wc -l 196 > - If not, is clang-format ever going to be fixed to quit adding them? Doubtful as it's likely the .clang-format for_each list is just out of date for your particular for_each type use and the scripted bit that it uses to create them hasn't be updated in awhile. Also that scripted bit only works on files in include/ and not anything locally defined. in .clang-format: # Taken from: # git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \ # | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ # | sort | uniq commit 4792f9dd12936ec35deced665ae3a4ca8fe98729 Author: Miguel Ojeda Date: Wed May 12 23:32:39 2021 +0200 clang-format: Update with the latest for_each macro list Re-run the shell fragment that generated the original list. Signed-off-by: Miguel Ojeda checkpatch basically just looks for any use of 'for_each' (?:[a-z_]+|)for_each[a-z_]+) So it has false positives for some functions and not macros.