Re: coding style for long conditions

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Brownell <david-b@...>
Cc: Stefan Richter <stefanr@...>, Jan Engelhardt <jengelh@...>, Randy Dunlap <randy.dunlap@...>, Tony Lindgren <tony@...>, <linux-kernel@...>
Date: Friday, April 6, 2007 - 5:38 pm

[I can't believe I'm stepping into an indentation flamewar, but here goes...]

> Please change your coding style to conform to Documentation/CodingStyle.
>
> *** Only indent with tabs!! ***
>
> Every one of those examples violates that simple rule.

Yes, Documentation/CodingStyle says that we should only indent with
tabs. However, that simple rule has to be interpreted with some
common sense, and the case of multi-line if conditions is definitely a
case where using only tabs makes code much less readable.

If you want an excuse, you could say that in code like

if (foo___________ &&
bar___________) {
doit;

that the line with "bar" on it is properly indented with one tab
(since it is part of the if statement that is also indented one tab),
and then four spaces are used to align the "bar" with the previous
line. So only tabs are used for indentation, and the spaces after the
tab are used for alignment, and the letter of the law is observed.

If you have a git tree handy, you can do "git show 68380b58" and see
that Linus himself wrote:

if (get_wq_data(work) == cwq
&& work_pending(work)
&& !list_empty(&work->entry)) {

I have to admit that I would have put the &&s at the ends of the
previous lines rather than where Linus put them, but... egads! Linus
put spaces before the &&s to line them up nicely!

"more in the breach" and all that I guess...

- R.
-

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 20/90] ARM: OMAP: gpio init section cleanups, Tony Lindgren, (Wed Apr 4, 2:04 pm)
[PATCH 21/90] ARM: OMAP: gpio object shrinkage, cleanup, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 23/90] ARM: OMAP: PalmZ71 extra brace fix, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 24/90] ARM: OMAP: Fix typo in gpio, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Dmitry Torokhov, (Wed Apr 4, 4:47 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, David Brownell, (Wed Apr 4, 4:59 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Jan Engelhardt, (Wed Apr 4, 4:06 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, David Brownell, (Wed Apr 4, 4:51 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Jan Engelhardt, (Wed Apr 4, 10:15 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Randy Dunlap, (Thu Apr 5, 12:18 am)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, David Brownell, (Thu Apr 5, 2:19 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Jan Engelhardt, (Thu Apr 5, 4:35 pm)
Re: coding style for long conditions, Junio C Hamano, (Sat Apr 7, 4:01 am)
Re: coding style for long conditions, David Brownell, (Mon Apr 9, 11:14 am)
Re: coding style for long conditions, Roland Dreier, (Fri Apr 6, 5:38 pm)
Re: coding style for long conditions, Scott Preece, (Mon Apr 9, 11:45 am)
Re: coding style for long conditions, David Brownell, (Fri Apr 6, 6:05 pm)
Re: coding style for long conditions, Jan Engelhardt, (Fri Apr 6, 6:07 pm)
Re: coding style for long conditions, David Brownell, (Fri Apr 6, 6:43 pm)
Re: coding style for long conditions, Zan Lynx, (Fri Apr 6, 5:50 pm)
Re: coding style for long conditions (WAS: Re: [PATCH 25/90]..., Jeremy Fitzhardinge, (Fri Apr 6, 5:37 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Dmitry Torokhov, (Wed Apr 4, 4:42 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, David Brownell, (Wed Apr 4, 3:13 pm)
[PATCH 27/90] ARM: OMAP: Add minimal OMAP2430 support, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 28/90] ARM: OMAP: USB peripheral support on H4, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Pavel Machek, (Fri Apr 6, 8:09 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Russell King, (Sun Apr 8, 8:07 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Pavel Machek, (Sun Apr 8, 8:12 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Russell King, (Sun Apr 8, 10:40 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Pavel Machek, (Mon Apr 9, 7:13 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Russell King, (Sun Apr 8, 9:58 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Dagfinn Ilmari , (Sun Apr 8, 8:31 am)
[PATCH 30/90] ARM: OMAP: Palm Zire71 minor fixes, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 31/90] ARM: OMAP: plat-omap changes for 2430 SDP, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 32/90] ARM: OMAP: Basic support for siemens sx1, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 35/90] ARM: OMAP: speed up gpio irq handling, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 36/90] ARM: OMAP: Fix typo in board-h4.h, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 37/90] ARM: OMAP: MPUIO wake updates, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 38/90] ARM: OMAP: Sync headers with linux-omap, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 39/90] ARM: OMAP: Sync core code with linux-omap, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 42/90] ARM: OMAP: Tabify mux.c, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 43/90] ARM: OMAP: TUSB EVM init, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 43/90] ARM: OMAP: TUSB EVM init, Randy Dunlap, (Wed Apr 4, 2:44 pm)
Re: [PATCH 43/90] ARM: OMAP: TUSB EVM init, Tony Lindgren, (Thu Apr 5, 10:42 am)
[PATCH 44/90] ARM: OMAP: Add mailbox support for IVA, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 45/90] ARM: OMAP: Update omap h2 defconfig, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 46/90] ARM: OMAP: Add omap osk defconfig, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 47/90] ARM: OMAP: Fix gpmc header, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 48/90] ARM: OMAP: I2C-1 init fix for 2430, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 52/90] ARM: OMAP: cleanup apollon board, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 53/90] ARM: OMAP: Fix warning in timer32k.c, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 53/90] ARM: OMAP: Fix warning in timer32k.c, Randy Dunlap, (Wed Apr 4, 3:14 pm)
Re: [PATCH 53/90] ARM: OMAP: Fix warning in timer32k.c, Tony Lindgren, (Thu Apr 5, 11:15 am)
[PATCH 54/90] ARM: OMAP: Update timer32k.c to compile, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 55/90] ARM: OMAP: H3 workqueue fixes, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 55/90] ARM: OMAP: H3 workqueue fixes, Tony Lindgren, (Thu Apr 5, 11:17 am)
[PATCH 63/90] ARM: OMAP: Merge PM code from N800 tree, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 64/90] ARM: OMAP: Fix warning in pm.c, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 64/90] ARM: OMAP: Fix warning in pm.c, Tony Lindgren, (Thu Apr 5, 11:18 am)
[PATCH 69/90] ARM: OMAP: add SoSSI clock, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 79/90] ARM: OMAP: fix H4 dependencies again, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 80/90] ARM: OMAP: partial LED fixes, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 81/90] ARM: OMAP: omap2/pm.c build fix, Tony Lindgren, (Wed Apr 4, 2:06 pm)
[PATCH 82/90] ARM: OMAP: restore CONFIG_GENERIC_TIME, Tony Lindgren, (Wed Apr 4, 2:06 pm)
[PATCH 88/90] ARM: OMAP: OSK led fixes, Tony Lindgren, (Wed Apr 4, 2:06 pm)