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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93603C433F5 for ; Mon, 27 Sep 2021 09:22:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C0BE36103B for ; Mon, 27 Sep 2021 09:22:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C0BE36103B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 595E5900002; Mon, 27 Sep 2021 05:22:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 545EB6B0072; Mon, 27 Sep 2021 05:22:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 434B9900002; Mon, 27 Sep 2021 05:22:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 3045C6B0071 for ; Mon, 27 Sep 2021 05:22:55 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C342A32070 for ; Mon, 27 Sep 2021 09:22:54 +0000 (UTC) X-FDA: 78632813868.31.6979725 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by imf11.hostedemail.com (Postfix) with ESMTP id E7BB5F0000B5 for ; Mon, 27 Sep 2021 09:22:53 +0000 (UTC) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 18R9Mama021544; Mon, 27 Sep 2021 11:22:36 +0200 Date: Mon, 27 Sep 2021 11:22:36 +0200 From: Willy Tarreau To: David Laight Cc: "'Linus Torvalds'" , Alexey Dobriyan , Linux Kernel Mailing List , Joe Perches , Andrew Morton , "apw@canonical.com" , Christoph Lameter , Daniel Micay , Dennis Zhou , "dwaipayanray1@gmail.com" , Joonsoo Kim , Linux-MM , Lukas Bulwahn , "mm-commits@vger.kernel.org" , Nathan Chancellor , Nick Desaulniers , Miguel Ojeda , Pekka Enberg , David Rientjes , Tejun Heo , Vlastimil Babka , "open list:DOCUMENTATION" Subject: Re: function prototype element ordering Message-ID: <20210927092236.GC20117@1wt.eu> References: <20210910031046.G76dQvPhV%akpm@linux-foundation.org> <202109211630.2D00627@keescook> <202109211757.F38DF644@keescook> <6a85bbbf952949118cc5f93b57d48265@AcuMS.aculab.com> <6a84e8b3fa07483092ae79aeded81797@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6a84e8b3fa07483092ae79aeded81797@AcuMS.aculab.com> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf11.hostedemail.com: domain of w@1wt.eu designates 62.212.114.60 as permitted sender) smtp.mailfrom=w@1wt.eu X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E7BB5F0000B5 X-Stat-Signature: iwhe36b88zx9949hcs3z3xpxihb7jqc5 X-HE-Tag: 1632734573-845883 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Sep 27, 2021 at 08:21:24AM +0000, David Laight wrote: > Putting '} else {' on one line is important when reading code. I used not to like that due to "else if ()" being less readable and less easy to spot, but the arguments you gave regarding the end of screen are valid and are similar to my hate of GNU's broken "while ()" on its own line especially after a "do { }" block where it immediately looks like an accidental infinite loop. However: > But none of this is related to the location of attributes unless > you need to split long lines and put the attribute before the > function name where you may need. > > static struct frobulate * > __inline .... > find_frobulate(....) This is exactly the case where I hate to dig into code looking like that: you build, it fails to find symbol "find_frobulate()", you run "git grep -w find_frobulate" to figure what file provides it, or even "grep ^find_frobulate" if you want. And you find it in frobulate.c. You double-check, you find that frobulate.o was built and linked into your executable. Despite this it fails to find the symbol. Finally you open the file to discover this painful "static" two lines above, which made you waste 3 minutes of your time digging at the wrong place. *Just* for this reason I'm much more careful to always put the type and name on the same line nowadays. > Especially if you need #if around the attributes. This is the only exception I still have to the rule above. But #if by definition require multi-line processing anyway and they're not welcome in the middle of control flows. Willy