All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'Lino Sanfilippo'" <LinoSanfilippo@gmx.de>,
	Joe Perches <joe@perches.com>, David Miller <davem@davemloft.net>,
	"lsanfil@marvell.com" <lsanfil@marvell.com>
Cc: "madalin.bucur@nxp.com" <madalin.bucur@nxp.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"corbet@lwn.net" <corbet@lwn.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"oss@buserror.net" <oss@buserror.net>,
	"ppc@mindchasers.com" <ppc@mindchasers.com>,
	"pebolle@tiscali.nl" <pebolle@tiscali.nl>,
	"joakim.tjernlund@transmode.se" <joakim.tjernlund@transmode.se>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: RE: Coding Style: Reverse XMAS tree declarations ?
Date: Mon, 7 Nov 2016 11:00:49 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB021646E@AcuExch.aculab.com> (raw)
In-Reply-To: <31ace8dd-1e42-2762-6367-028068d4d816@gmx.de>

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

WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: 'Lino Sanfilippo' <LinoSanfilippo@gmx.de>,
	Joe Perches <joe@perches.com>, David Miller <davem@davemloft.net>,
	"lsanfil@marvell.com" <lsanfil@marvell.com>
Cc: "madalin.bucur@nxp.com" <madalin.bucur@nxp.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"corbet@lwn.net" <corbet@lwn.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"oss@buserror.net" <oss@buserror.net>,
	"ppc@mindchasers.com" <ppc@mindchasers.com>,
	"pebolle@tiscali.nl" <pebolle@tiscali.nl>,
	"joakim.tjernlund@transmode.se" <joakim.tjernlund@transmode.se>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: RE: Coding Style: Reverse XMAS tree declarations ?
Date: Mon, 7 Nov 2016 11:00:49 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB021646E@AcuExch.aculab.com> (raw)
In-Reply-To: <31ace8dd-1e42-2762-6367-028068d4d816@gmx.de>

From: Lino Sanfilippo
> Sent: 04 November 2016 20:07
...
> In this case it is IMHO rather the declaration + initialization that make=
s
> "bar" hard to find at one glance, not the use of RXT. You could do someth=
ing like
>=20
>  	[longish list of reverse xmas tree identifiers...]
>  	struct foobarbaz *qux;
>  	struct foo *bar;
>=20
>  	bar =3D longish_function(args, ...);
>=20
> to increase readability.
>=20
> Personally I find it more readable to always use a separate line for init=
ializations
> by means of functions (regardless of whether the RXT scheme is used or no=
t).

I find it best to only use initialisers for 'variables' that are (mostly) c=
onstant.
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

  reply	other threads:[~2016-11-07 11:04 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 20:17 [PATCH net-next v6 00/10] dpaa_eth: Add the QorIQ DPAA Ethernet driver Madalin Bucur
2016-11-02 20:17 ` Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 01/10] devres: add devm_alloc_percpu() Madalin Bucur
2016-11-02 20:17   ` Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 02/10] dpaa_eth: add support for DPAA Ethernet Madalin Bucur
2016-11-02 20:17   ` Madalin Bucur
2016-11-03 19:58   ` David Miller
2016-11-04  6:53     ` Coding Style: Reverse XMAS tree declarations ? (was Re: [PATCH net-next v6 02/10] dpaa_eth: add support for DPAA Ethernet) Joe Perches
2016-11-04 11:01       ` Lino Sanfilippo
2016-11-04 15:07         ` Coding Style: Reverse XMAS tree declarations ? David Miller
2016-11-04 17:44           ` Joe Perches
2016-11-04 20:06             ` Lino Sanfilippo
2016-11-07 11:00               ` David Laight [this message]
2016-11-07 11:00                 ` David Laight
2016-11-04 17:05       ` Coding Style: Reverse XMAS tree declarations ? (was Re: [PATCH net-next v6 02/10] dpaa_eth: add support for DPAA Ethernet) Randy Dunlap
2016-11-04 19:48         ` David VomLehn
2016-11-07  8:05       ` Michael Ellerman
2016-11-07  8:05         ` Michael Ellerman
2016-11-07 15:43     ` [PATCH net-next v6 02/10] dpaa_eth: add support for DPAA Ethernet Madalin-Cristian Bucur
2016-11-07 15:43       ` Madalin-Cristian Bucur
2016-11-07 15:43       ` Madalin-Cristian Bucur
2016-11-07 15:55       ` David Miller
2016-11-07 16:32         ` Madalin-Cristian Bucur
2016-11-07 16:32           ` Madalin-Cristian Bucur
2016-11-07 16:32           ` Madalin-Cristian Bucur
2016-11-07 16:39           ` David Miller
2016-11-07 16:59             ` Madalin-Cristian Bucur
2016-11-07 16:59               ` Madalin-Cristian Bucur
2016-11-07 16:59               ` Madalin-Cristian Bucur
2016-11-09 17:16     ` Madalin-Cristian Bucur
2016-11-09 17:16       ` Madalin-Cristian Bucur
2016-11-09 17:18       ` David Miller
2016-11-07 16:25   ` Joakim Tjernlund
2016-11-07 16:25     ` Joakim Tjernlund
2016-11-02 20:17 ` [PATCH net-next v6 03/10] dpaa_eth: add option to use one buffer pool set Madalin Bucur
2016-11-02 20:17   ` Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 04/10] dpaa_eth: add ethtool functionality Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 05/10] dpaa_eth: add ethtool statistics Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 06/10] dpaa_eth: add sysfs exports Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 07/10] dpaa_eth: add trace points Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 08/10] arch/powerpc: Enable FSL_PAMU Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 09/10] arch/powerpc: Enable FSL_FMAN Madalin Bucur
2016-11-02 20:17 ` [PATCH net-next v6 10/10] arch/powerpc: Enable dpaa_eth Madalin Bucur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=063D6719AE5E284EB5DD2968C1650D6DB021646E@AcuExch.aculab.com \
    --to=david.laight@aculab.com \
    --cc=LinoSanfilippo@gmx.de \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=joakim.tjernlund@transmode.se \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lsanfil@marvell.com \
    --cc=madalin.bucur@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss@buserror.net \
    --cc=pebolle@tiscali.nl \
    --cc=ppc@mindchasers.com \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.