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 E6671C433EF for ; Mon, 27 Sep 2021 09:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD7F661157 for ; Mon, 27 Sep 2021 09:23:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233659AbhI0JYr (ORCPT ); Mon, 27 Sep 2021 05:24:47 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:43035 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233638AbhI0JYo (ORCPT ); Mon, 27 Sep 2021 05:24:44 -0400 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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