lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 8 Apr 2007 08:24:57 -0500
From:	"Scott Preece" <sepreece@...il.com>
To:	"Stefan Richter" <stefanr@...6.in-berlin.de>
Cc:	"David Brownell" <david-b@...bell.net>,
	"Jan Engelhardt" <jengelh@...ux01.gwdg.de>,
	"Randy Dunlap" <randy.dunlap@...cle.com>,
	"Tony Lindgren" <tony@...mide.com>, linux-kernel@...r.kernel.org,
	"David Brownell" <dbrownell@...rs.sourceforge.net>
Subject: Re: coding style for long conditions (WAS: Re: [PATCH 25/90] ... blinky leds!!)

On 4/6/07, Stefan Richter <stefanr@...6.in-berlin.de> wrote:
> David Brownell wrote:
> [...]
> >>> 1   if (To control chain reactions, your odds
> >>> 2                   Improve if you've got cadmium rods) {
> >>> 3           In your fission reactor
> >>> 4           Their lack is a factor
> >>> 5   }
> >>> 6   In screams of "A meltdown! Ye gods!"
> >>>
> >>> Now, the former makes it hard to tell what's condition vs consequent.
> >>> (Or whatever the correct technical term is in cases like these.)
> >> My fu dictates that continuation lines (line 2 in this example)
> >> should have more indent than line 1,
> >
> > Yes.  Where "indent" is measured -- always!! -- in tabs.
> > Documentation/Coding style is quite explicit on that point:
> >
> >       Outside of comments, documentation and except in Kconfig,
> >       spaces are never used for indentation ...
>
> I usually indent this way if expressions exceed the 80 columns limit:
>
>         if (foo___________ &&
>             bar___________) {
>                 doit;
>         }
---

I disagree vigorously - the operators should be at the front of the
line, so that the logical structure is clear. [The editor I'm doing
this in won't let me use tabs, so I won't even try to do an
example...]

As other people have noted in this thread, it's a rule that would earn
Emerson's "foolish consistency" label, if it actually were followed
slavishly. In fact, the kernel looks like people tend to do the right
thing, rather than always following the letter of the law.

Tab indenting is a good rule for the general case, but there are also
places (and breaking long conditionals is at the top of the list)
where it's much more important to express the structure, and the
structure has too many logical sub-points to line up with the
relatively small number of 8-space tabs available in an 80-character
line.

Of course, expressions too complicated to fit the rule are also a sign
that you might want to simplify things...

scott
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists