Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755610AbcKDUYH (ORCPT ); Fri, 4 Nov 2016 16:24:07 -0400 Received: from mout.gmx.net ([212.227.17.22]:65075 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754760AbcKDUWe (ORCPT ); Fri, 4 Nov 2016 16:22:34 -0400 Subject: Re: Coding Style: Reverse XMAS tree declarations ? To: Joe Perches , David Miller , lsanfil@marvell.com References: <20161103.155816.642712588084106823.davem@davemloft.net> <1478242438.1924.31.camel@perches.com> <581C6A7D.8030704@marvell.com> <20161104.110759.1093635654135143910.davem@davemloft.net> <1478281455.1924.41.camel@perches.com> Cc: madalin.bucur@nxp.com, akpm@linux-foundation.org, corbet@lwn.net, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, oss@buserror.net, ppc@mindchasers.com, pebolle@tiscali.nl, joakim.tjernlund@transmode.se, Randy Dunlap From: Lino Sanfilippo Message-ID: <31ace8dd-1e42-2762-6367-028068d4d816@gmx.de> Date: Fri, 4 Nov 2016 21:06:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1478281455.1924.41.camel@perches.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:THd4zrb+1JCtUDVm1C9D0q3hh3LdX360A5/9efTHgn54qlk5/1x 3Kvs7FfN9v1G3aJeyAgYEu0Ds/pHDm1Dmf+x8ClzqLOHBG8G4RmaDVCIvpfiqW1RkjuNRYF KA5aLS4WnIJeJyMM8SighMSCOsokJwxfWnmsumyuLAjslXEGvoQMpF6MnkOAla1fEV8dewH o3amGZu2WCsAD8b4NScaA== X-UI-Out-Filterresults: notjunk:1;V01:K0:Van8dLIo0vg=:lx6eNK4Q50Nvumt0gPFFhc ziV0BtZvDDQkTTk1rsD1XSLzt1gHFVl46xRSOZgX3crTjNSMJRoicjdyD5ZfdbBVrCB+TdVVj ec6A6Hu+TVwyh39hV61xJMn1VgMXs+qeY4hnoeui/wCgfvXoe3P0TrzI+C69w4cSST56zC3j1 Uw1ZuJbB0FFsaiF6GjbwPCfvfNRbAQAlXy9D20WuQl9WxZtZz6e6fKj0qViIDSS8liiBzYMhd Mep+viC4R7kZaz3OiNfoMUFqzSliAWtOuE8XOGTDGRria6mO2v+S+rEYozdYqyxXHAJ6C8dZc y2/o8gTcaA0vux8KcH4FHX0MKicrPovfyMV9vGWYXjR+kYi9WXbAULbe6YzydoCEVHuRJdsds 6eGo9mNnXfdAshTzylPEY1XOaVbhPmCvC32p6YxCxHeiRPz/Iq3OyK7G8mbGIHlQ17Y3cyf5I 0vRW35Qxm3XI1VhibQ5OT4MRG9YMYFClMKpr2y/QR0ePffM1Gl2j6O/oIWIirttsIZ2xk2R6p dyB2u0fJd598/2mfuiTdxGESbgOBpEMiKMB+7tch5yATXHPczyq1xjSSvZz3ozeBV5/tEEXPD zITe/fAegLCPozl1X/V2v7kCdPUe5uM9jFEd3nU5j9FDHihelEUroAfkw8Q4Zysj7Un4xkXOb pBoWLTCrMwk1Z4zvFR0HWkAL7imaKL+01gy+mdqeEp0vMeIAJYZoYyon3H6X81GGCecKJ07+7 G9sKSJp/uvm+Ou86G4iZRPQJxhereb3Cyg4z/yFhvdDFK7LG7o9epz1XzQfhTqBAFbAhfAHem njJ4Vp7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2095 Lines: 69 On 04.11.2016 18:44, Joe Perches wrote: > On Fri, 2016-11-04 at 11:07 -0400, David Miller wrote: >> From: Lino Sanfilippo >> > On 04.11.2016 07:53, Joe Perches wrote: >> >> CHECK:REVERSE_XMAS_TREE: Prefer ordering declarations longest to >> >> shortest >> >> #446: FILE: drivers/net/ethernet/ethoc.c:446: >> >> + int size = bd.stat >> 16; >> >> + struct sk_buff *skb; >> > should not this case be valid? Optically the longer line is already >> > before the shorter. >> > I think that the whole point in using this reverse xmas tree ordering >> > is to have >> > the code optically tidied up and not to enforce ordering between >> > variable name lengths. >> >> That's correct. > > And also another reason the whole reverse xmas tree > automatic declaration layout concept is IMO dubious. > > Basically, you're looking not at the initial ordering > of automatics as important, but helping find a specific > automatic when reversing from reading code is not always > correct. > > Something like: > > static void function{args,...) > { > [longish list of reverse xmas tree identifiers...] > struct foo *bar = longish_function(args, ...); > struct foobarbaz *qux; > [more identifers] > > [multiple screenfuls of code later...) > > new_function(..., bar, ...); > > [more code...] > } > > and the reverse xmas tree helpfulness of looking up the > type of bar is neither obvious nor easy. > In this case it is IMHO rather the declaration + initialization that makes "bar" hard to find at one glance, not the use of RXT. You could do something like [longish list of reverse xmas tree identifiers...] struct foobarbaz *qux; struct foo *bar; bar = longish_function(args, ...); to increase readability. Personally I find it more readable to always use a separate line for initializations by means of functions (regardless of whether the RXT scheme is used or not). > My preference would be for a bar that serves coffee and alcohol. > At least a bar like this should not be too hard to find :) Regards, Lino