[U-Boot] [PATCH] ppc4xx: Read pipeline depth set to 4 for PPC440SP/SPE, PPC405EX, PPC460EX/GT/SX processors
Wolfgang Denk
wd at denx.de
Wed Aug 13 22:56:32 CEST 2008
Dear "Prodyut Hazarika",
In message <0CA0A16855646F4FA96D25A158E299D604DB40F8 at SDCEXCHANGE01.ad.amcc.com> you wrote:
>
> > > #if defined(CONFIG_440EP) || defined (CONFIG_440GR) || \
> > > ^^ space here ^^ space here
> > > defined(CONFIG_440EPX) || defined(CONFIG_440GR)
>
> > This is not what we are talking about. This part of the code is OK.
>
> I want to understand why is space alignment okay here. The coding
The intention of vertical alignment is to make code look "nice". Com-
puters don't care (at least to the best of my knowledge), but humans
seem to find it easier if code is neatly aligned in columns.
For example, compare this example (randomly selected - it's from
include/4xx_i2c.h):
(1)
#define IIC_OK 0
#define IIC_NOK 1
#define IIC_NOK_LA 2 /* Lost arbitration */
#define IIC_NOK_ICT 3 /* Incomplete transfer */
#define IIC_NOK_XFRA 4 /* Transfer aborted */
#define IIC_NOK_DATA 5 /* No data in buffer */
#define IIC_NOK_TOUT 6 /* Transfer timeout */
#define IIC_TIMEOUT 1 /* 1 second */
against:
(2)
#define IIC_OK 0
#define IIC_NOK 1
#define IIC_NOK_LA 2 /* Lost arbitration */
#define IIC_NOK_ICT 3 /* Incomplete transfer */
#define IIC_NOK_XFRA 4 /* Transfer aborted */
#define IIC_NOK_DATA 5 /* No data in buffer */
#define IIC_NOK_TOUT 6 /* Transfer timeout */
#define IIC_TIMEOUT 1 /* 1 second */
Which is nicer, and easier to read - (1) or (2)?
Now if you have something that starts "#if defined(..)" in the first
line, then it seems only natural to me that (assuming we have to add
another line, which actually is an indication of a coding problem in
the first place), it should be aligned such that the "defined()"
parts start in the same column. So the second line would follow like
this:
#if defined(foo) ... || \
defined(bar)
There is no law, no written rule for that, just common sense and a a
certain amount of esthetical sensation.
> guidelines state that we must use tabs for vertical alignment. Does this
> rule not apply to defines? If so, the coding guidelines doc should be
> updated.
I'm sorry, but it would exceed my capabilities as an author to put
that in writing. Feel free to add to the wiki and improve the
description there yourself if you feel it needs it.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Es sind überhaupt nur die Dummköpfe, die sich den Befehlen der Mäch-
tigen widersetzen. Um sie zu ruinieren ist es genug, ihre Befehle
treu zu erfüllen. - Peter Hacks: "Die schöne Helena"
More information about the U-Boot
mailing list