Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3261542imm; Mon, 8 Oct 2018 00:31:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV63u9G+dTk4b9DeB3rcfoWwFPqkDXJaQsr417hsrd26aCc5287FOhakA//2H3OP8GLYhdLOk X-Received: by 2002:a62:7e81:: with SMTP id z123-v6mr23751089pfc.139.1538983919426; Mon, 08 Oct 2018 00:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538983919; cv=none; d=google.com; s=arc-20160816; b=yA0YXM0xdNQEHQB8OEXrG7zYOcrOoszZi0aH/Mc0pGC6s4f0Gp22ljqLs72acram05 n51DQBFIi7sJqlvvz5KWCJINw007blPvRUDE9JoA76C+yIP5IGPFqKZq+xVRRt41YRKr aZJ/Ww61+hsbz+OdlsoM6yr6gUN5rYqvobASnkYXlaqy106eOfJr3NARzBF0XGUZV0R0 XjaKbPSMyX3VVy8XksPcYR79Yeg6vEZATD644W3liHHRlnbBAI103PqnlKnKcvSX9lPp 0k8LD8RYuVZ4xf6FO9OUKRqPPmG4QsMkjwcGApQX+Qe0dZzJT7zJxYOTZ0pivtok03TJ qVxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JyX0buiN4UVj/jk3Wox3uSReRVqsRY7WN8uICIK1Pys=; b=M3rC9rNqV7GJim3Njp8VTK6sy943zYuelM/G/LrDSSu8ZqLPXaaM3zkgpS+Te35yp6 H1II74mr29F2IAJSHaONYZg0uNkoeZfnrS5k2DCNOPW0cvOUgpKNQQOY0lE5+JZV9Ae7 GOJAisibyrCbxLD7Y0qrwHhWkzNxHClLvBFcFYXKwi+WCO1Fsh8thpTwkVlz9FNM5FKv pnB1CmwXyZvNtn7jFnxMNS3Kl8SZ0AoeXW23KMsYAmp4rgb2n04LPO50LliYC4vRfELh ls5++52eM/LNcqG/cGfvGfaAZxbbORgDhexbOJ7YgXydME+E4kyk9ueURBuTVfDNW/7W 2Sag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AMI4WBjI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11-v6si18646739pla.245.2018.10.08.00.31.44; Mon, 08 Oct 2018 00:31:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AMI4WBjI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726722AbeJHOll (ORCPT + 99 others); Mon, 8 Oct 2018 10:41:41 -0400 Received: from mail-lj1-f175.google.com ([209.85.208.175]:35236 "EHLO mail-lj1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbeJHOll (ORCPT ); Mon, 8 Oct 2018 10:41:41 -0400 Received: by mail-lj1-f175.google.com with SMTP id o14-v6so16918766ljj.2 for ; Mon, 08 Oct 2018 00:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JyX0buiN4UVj/jk3Wox3uSReRVqsRY7WN8uICIK1Pys=; b=AMI4WBjIOp4OOjp2KFAad6YS3nUnN27clw3eYAzeJDZt3BVcKgy7cNvFiSBYx7Z9h1 HNp1ytiaSJ1knRxKXNuZj8baDyzw7ZrDSwjckLom7A1mpAkOo6kjYIhreV2ZiOzphZCx K7azKKGi10m5uv0JcLRaMbQhPtDevSrUSuS3Rv8gJtzf8pZ2nA46yh/5FXQA0y/UKOo8 m6+S30MFCHyZT9CvK7bHxEFQ6BFlCKaaWCzpAIB196xBr5vJp8OTDEsX3xNymcU2YzPt TUNPTAtkq8njRqwJq2DsFIYI86mdbSh2AizwpGJuUXrOb66buEl0riVPpVLXHCJfAKnG SUyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JyX0buiN4UVj/jk3Wox3uSReRVqsRY7WN8uICIK1Pys=; b=nELD7Ly8MB30VIhlvVl+S2+lOTs0GOmn0ENyhfQ71vuxW7yl9BvmMS6A9i9rOWre7y WryQgwyuPPM6naqLOOh/TK1Xugkw5hNMbuk8sl8MB/jHA2xlmthtksTRMFgH9awRCWre 3EWbapT03rGuszkGQ5jzVz9rbmLWUFjdkvuHBAvk2veDXGsO9bk/PLpRwWgiZrrVCdJd GuokwmqvaPMe7VQksCg+MAFA1e4cG3dVdJ6M1UIB1ijXcyFscjJ8dZctGW7CNH70+oVh +afLNBxlavDfZq2wXCKOTgvAOtq9gg25+S+MaXbog4c/57/s6oZZ5PZ+3x9LHj00zoqG jVzQ== X-Gm-Message-State: ABuFfoghYuDJSr8v7NJHZZui6Za5N/Nu9YPeQUJWlE7Uxo+Db7xq7B91 uqr7453imLf+TVWYoQgdNJ/C/dC6Qlvcyttmdq8= X-Received: by 2002:a2e:8684:: with SMTP id l4-v6mr14602184lji.52.1538983879835; Mon, 08 Oct 2018 00:31:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Miguel Ojeda Date: Mon, 8 Oct 2018 09:31:08 +0200 Message-ID: Subject: Re: list iterator spacing: clang-format vs checkpatch To: Jason@zx2c4.com Cc: Joe Perches , Andrew Lunn , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, On Mon, Oct 8, 2018 at 4:01 AM Jason A. Donenfeld wrote: > > Hi Joe, Miguel, others, > > The shiny new .clang-format file lists a number of nice iterators in > the ForEachMacros category, the consequence being that there is a > space between the iterator name and the opening parenthesis. This > strikes me as the right thing to do. > > However, checkpatch.pl complains about it: > > WARNING: space prohibited between function name and open parenthesis '(' > #65: FILE: ratelimiter.c:65: > + hlist_for_each_entry_safe (entry, temp, &table_v4[i], hash) { > > It would seem that .clang-format is right and checkpatch.pl is wrong? Checking quickly, it would seem most of the kernel does not put a space there (a minority does), e.g.: git grep 'list_for_each[a-zA-Z0-9_]* (' | wc -l # 67 git grep 'list_for_each[a-zA-Z0-9_]*(' | wc -l # 13892 So in that sense, checkpatch.pl is right (even if it is not a function call). Now, I put the list there because otherwise clang-format would put braces in the next line, which looks even worse. I am not sure if there is a way to make clang-format do what we need: * SpaceBeforeParens does not have an option to distinguish normal loops from macro ones. * SpaceBeforeRangeBasedForLoopColon does not do it (which makes sense, but it was a nice try :-) We would probably need to implement SpaceBeforeForEachMacros (or a new option for SpaceBeforeParens). I haven't had the time to look into adding the missing support for the few things that the kernel style requires, sadly, but it is in my TODO list. Cheers, Miguel