Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752724AbcKGLE0 convert rfc822-to-8bit (ORCPT ); Mon, 7 Nov 2016 06:04:26 -0500 Received: from smtp-out6.electric.net ([192.162.217.188]:56814 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbcKGLEY (ORCPT ); Mon, 7 Nov 2016 06:04:24 -0500 From: David Laight To: "'Lino Sanfilippo'" , Joe Perches , 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 Subject: RE: Coding Style: Reverse XMAS tree declarations ? Thread-Topic: Coding Style: Reverse XMAS tree declarations ? Thread-Index: AQHSNsKkqI/V4mVdyUGN+Ig8+jyW6aDJQHkAgAQctlA= Date: Mon, 7 Nov 2016 11:00:49 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB021646E@AcuExch.aculab.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> <31ace8dd-1e42-2762-6367-028068d4d816@gmx.de> In-Reply-To: <31ace8dd-1e42-2762-6367-028068d4d816@gmx.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 989 Lines: 27 From: Lino Sanfilippo > Sent: 04 November 2016 20:07 ... > 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). I find it best to only use initialisers for 'variables' that are (mostly) constant. If something need to be set to NULL in case a search fails, set it to NULL just before the loop. Don't put initialisation on the declaration 'because you can'. Difficulty in spotting the type of a variable is why (IMHO) you should but all declarations at the top of a function (except, maybe, temporaries needed for a few lines). David