From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936646AbcKDRoX (ORCPT ); Fri, 4 Nov 2016 13:44:23 -0400 Received: from smtprelay0005.hostedemail.com ([216.40.44.5]:46810 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934996AbcKDRoV (ORCPT ); Fri, 4 Nov 2016 13:44:21 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3873:3874:4250:4321:5007:6742:7576:8603:9010:10004:10400:10848:11026:11232:11473:11658:11783:11914:12043:12296:12679:12740:13069:13160:13229:13311:13357:13439:13894:14181:14659:14721:21080:21324:21451:30012:30029:30054:30056:30070:30089:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: cats34_427352c471b11 X-Filterd-Recvd-Size: 2602 Message-ID: <1478281455.1924.41.camel@perches.com> Subject: Re: Coding Style: Reverse XMAS tree declarations ? From: Joe Perches To: David Miller , lsanfil@marvell.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 Date: Fri, 04 Nov 2016 10:44:15 -0700 In-Reply-To: <20161104.110759.1093635654135143910.davem@davemloft.net> References: <20161103.155816.642712588084106823.davem@davemloft.net> <1478242438.1924.31.camel@perches.com> <581C6A7D.8030704@marvell.com> <20161104.110759.1093635654135143910.davem@davemloft.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.1-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. My preference would be for a bar that serves coffee and alcohol.