public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] ppc4xx: Read pipeline depth set to 4 for PPC440SP/SPE, PPC405EX, PPC460EX/GT/SX processors
Date: Wed, 13 Aug 2008 22:56:32 +0200	[thread overview]
Message-ID: <20080813205632.AECF8248CD@gemini.denx.de> (raw)
In-Reply-To: <0CA0A16855646F4FA96D25A158E299D604DB40F8@SDCEXCHANGE01.ad.amcc.com>

Dear "Prodyut Hazarika",

In message <0CA0A16855646F4FA96D25A158E299D604DB40F8@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"

  reply	other threads:[~2008-08-13 20:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-13  4:43 [U-Boot] [PATCH] ppc4xx: Read pipeline depth set to 4 for PPC440SP/SPE, PPC405EX, PPC460EX/GT/SX processors fkan at amcc.com
2008-08-13  5:37 ` Wolfgang Denk
2008-08-13  6:26   ` Stefan Roese
2008-08-13  6:44     ` Wolfgang Denk
2008-08-13 13:59     ` Prodyut Hazarika
2008-08-13 14:24       ` Stefan Roese
2008-08-13 17:13   ` Scott Wood
2008-08-13 18:31     ` Wolfgang Denk
2008-08-13 18:44       ` Scott Wood
2008-08-13 19:04   ` prodyut hazarika
2008-08-13 19:16     ` Prodyut Hazarika
2008-08-13 20:08       ` Wolfgang Denk
2008-08-13 20:19         ` Prodyut Hazarika
2008-08-13 20:56           ` Wolfgang Denk [this message]
2008-08-13 20:01     ` Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2008-08-13 18:10 fkan at amcc.com
2008-08-13 20:10 ` Wolfgang Denk

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=20080813205632.AECF8248CD@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox